在Python中,是否有可能从Bar本身获取包含另一个对象Bar的对象,比如说Foo?这是我的意思的一个例子
class Foo(object):
def __init__(self):
self.bar = Bar()
self.text = "Hello World"
class Bar(object):
def __init__(self):
self.newText = foo.text #This is what I want to do,
#access the properties of the container object
foo = Foo()
Run Code Online (Sandbox Code Playgroud)
这可能吗?谢谢!
我在使用Sencha Touch数据存储和localproxy时遇到了一些麻烦.基本上,当使用store.remove(record)方法从存储中删除记录时,记录本身将从内存中删除,但是商店中对它的Id引用不会被删除,所以当页面刷新时,我收到一个可爱的"Uncaught TypeError:无法读取属性'isModel'未定义"
这是商店的代码:
Ext.define("App.store.Data", {
extend: "Ext.data.Store",
requires: "Ext.data.proxy.LocalStorage",
config: {
model: "App.model.Data",
autoSync: true,
proxy: {
type: 'localstorage',
id: 'app-store'
}
}
});
Run Code Online (Sandbox Code Playgroud)
以下是数据编辑器页面上删除按钮的代码
onDeleteHomeworkCommand: function () {
var dataEditor = this.getDataEditor();
var currentData = dataEditor.getRecord();
var dataStore = Ext.getStore("Data");
dataStore.remove(currentData);
dataStore.sync();
this.activateDataList();
},
Run Code Online (Sandbox Code Playgroud)
编辑:
以下是调用remove方法之前数据存储的屏幕截图:

以下是一个:

请注意,ID仍然保留在商店列表中,这会在刷新页面时给出未定义的错误.