本文整理匯總了Python中rpc.RPCProxy.default_get方法的典型用法代碼示例。如果您正苦於以下問題:Python RPCProxy.default_get方法的具體用法?Python RPCProxy.default_get怎麽用?Python RPCProxy.default_get使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類rpc.RPCProxy
的用法示例。
在下文中一共展示了RPCProxy.default_get方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: ModelRecordGroup
# 需要導入模塊: from rpc import RPCProxy [as 別名]
# 或者: from rpc.RPCProxy import default_get [as 別名]
#.........這裏部分代碼省略.........
#else:
# ctx['active_id'] = False
return ctx
context = property(getContext, setContext)
def model_add(self, model, position=-1):
#
# To be checked
#
if not model.mgroup is self:
fields = {}
for mf in model.mgroup.fields:
fields[model.mgroup.fields[mf]['name']] = model.mgroup.fields[mf]
self.add_fields(fields, self)
self.add_fields(self.fields, model.mgroup)
model.mgroup = self
if position==-1:
self.models.append(model)
else:
self.models.insert(position, model)
self.current_idx = position
model.parent = self.parent
model.signal_connect(self, 'record-changed', self._record_changed)
return model
def model_new(self, default=True, domain=[], context={}):
newmod = ModelRecord(self.resource, None, group=self,
parent=self.parent, new=True)
newmod.signal_connect(self, 'record-changed', self._record_changed)
if default:
ctx=context.copy()
ctx.update(self.context)
newmod.default_get(domain, ctx)
self.signal('model-changed', newmod)
newmod.list_parent = self.list_parent
newmod.list_group = self.list_group
return newmod
def model_remove(self, model):
idx = self.models.index(model)
self.models.remove(model)
if model.parent:
model.parent.modified = True
if self.models:
self.current_idx = min(idx, len(self.models)-1)
else:
self.current_idx = None
def _record_changed(self, model, signal_data):
self.signal('model-changed', model)
def prev(self):
if self.models and self.current_idx is not None:
self.current_idx = (self.current_idx - 1) % len(self.models)
elif self.models:
self.current_idx = 0
else:
return None
return self.models[self.current_idx]
def next(self):
if self.models and self.current_idx is not None:
self.current_idx = (self.current_idx + 1) % len(self.models)
elif self.models:
self.current_idx = 0
示例2: ModelRecord
# 需要導入模塊: from rpc import RPCProxy [as 別名]
# 或者: from rpc.RPCProxy import default_get [as 別名]
#.........這裏部分代碼省略.........
def failed_validation(self):
invalid_fields = self.rpc.get_invalid_fields()
for item in invalid_fields:
if item in self.mgroup.mfields:
self.mgroup.mfields[item].get_state_attrs(self)['valid'] = False
def save(self, reload=True):
self._check_load()
if not self.id:
value = self.get(get_readonly=False)
self.id = self.rpc.create(value, self.context_get())
if not self.id:
self.failed_validation()
else:
if not self.is_modified():
return self.id
value = self.get(get_readonly=False, get_modifiedonly=True)
context = self.context_get().copy()
self.update_context_with_concurrency_check_data(context)
if not self.rpc.write([self.id], value, context):
self.failed_validation()
return False
self._loaded = False
if reload:
self.reload()
else:
# just reload the CONCURRENCY_CHECK_FIELD
self._reload([CONCURRENCY_CHECK_FIELD])
return self.id
def default_get(self, domain=[], context={}):
if len(self.mgroup.fields):
val = self.rpc.default_get(self.mgroup.fields.keys(), context)
for d in domain:
if d[0] in self.mgroup.fields:
if d[1] == '=':
val[d[0]] = d[2]
if d[1] == 'in' and len(d[2]) == 1:
val[d[0]] = d[2][0]
self.set_default(val)
def name_get(self):
name = self.rpc.name_get([self.id], rpc.session.context)[0]
return name
def validate_set(self):
change = self._check_load()
for fname in self.mgroup.mfields:
field = self.mgroup.mfields[fname]
change = change or not field.get_state_attrs(self).get('valid', True)
field.get_state_attrs(self)['valid'] = True
if change:
self.signal('record-changed')
self.reload()
return change
def validate(self):
self._check_load()
ok = True
for fname in self.mgroup.mfields:
if not self.mgroup.mfields[fname].validate(self):
ok = False
return ok