如果在继承链中被另一个类覆盖,那么如何在继承链上调用多个类的方法呢?
class Grandfather(object):
def __init__(self):
pass
def do_thing(self):
# stuff
class Father(Grandfather):
def __init__(self):
super(Father, self).__init__()
def do_thing(self):
# stuff different than Grandfather stuff
class Son(Father):
def __init__(self):
super(Son, self).__init__()
def do_thing(self):
# how to be like Grandfather?
Run Code Online (Sandbox Code Playgroud) 我有一个包含CellModels CellCollection的BoardView.我从数据库中获取集合,然后创建CellViews.
这一切都在游泳,直到我尝试通过BoardView上的点击事件访问CellModel.我根本无法获得基础模型......只有视图.有没有办法做到这一点?
我试图在下面包含相关代码:
CellModel = Backbone.Model.extend({});
CellCollection = Backbone.Collection.extend({
model : CellModel
});
CellView = Backbone.View.extend({
className : 'cell',
});
BoardView = Backbone.View.extend({
this.model.cells = new CellCollection();
render : function() {
this.cellList = this.$('.cells');
return this;
},
allCells : function(cells) {
this.cellList.html('');
this.model.cells.each(this.addCell);
return this;
},
addCell : function(cell) {
var view = new Views.CellView({
model : cell
}).render();
this.cellList.append(view.el);
},
events : {
'click .cell' : 'analyzeCellClick',
},
analyzeCellClick : function(e) {
// ?????????
}
});
Run Code Online (Sandbox Code Playgroud)
我需要在BoardView上发生"发生",而不是CellView,因为它涉及特定于电路板的逻辑.
我需要每天将一个非常大(数百万行)的表从一个DB2 DB复制到另一个DB2 DB,我需要使用perl和DBI.
有没有更快的方法来执行此操作,而不是简单地从第一个数据库中获取每行的fetchrow_array并将它们逐个插入到第二个数据库中?这是我得到的:
$sth1 = $udb1 -> prepare($read_query);
$sth1 -> execute();
$sth1 -> bind_columns(\(@row{@{$sth1 -> {NAME_1c}}}));
$sth2 = $udb2 -> prepare($write_query);
while ($sth1 -> fetchrow_arrayref) {
$sth2 -> execute($row{field_name_1}, $row{field_name_2});
}
Run Code Online (Sandbox Code Playgroud)
我从类似的线程实现了一些解决方案,但它仍然很慢.当然必须有更好的方法吗?