本文整理汇总了Python中grano.model.Entity._filter_property方法的典型用法代码示例。如果您正苦于以下问题:Python Entity._filter_property方法的具体用法?Python Entity._filter_property怎么用?Python Entity._filter_property使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类grano.model.Entity
的用法示例。
在下文中一共展示了Entity._filter_property方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: save
# 需要导入模块: from grano.model import Entity [as 别名]
# 或者: from grano.model.Entity import _filter_property [as 别名]
def save(self):
""" Save the entity to the database. Do this only once, after all
properties have been set. """
# fetch existing:
q = Entity.all()
q = q.filter(Entity.project==self.loader.project)
for name, only_active in self.update_criteria:
value = self.properties.get(name).get('value')
attr = self.loader.project.get_attribute('entity', name)
q = Entity._filter_property(q, [attr], value,
only_active=only_active)
entity = q.first()
try:
data = {
'project': self.loader.project,
'author': self.loader.account,
'schemata': self.schemata,
'properties': self.properties
}
self._entity = entities.save(data, entity=entity)
except Invalid, inv:
log.warning("Validation error: %r", inv)
示例2: save
# 需要导入模块: from grano.model import Entity [as 别名]
# 或者: from grano.model.Entity import _filter_property [as 别名]
def save(self):
""" Save the relation to the database. Do this only once, after all
properties have been set. """
# fetch existing:
q = Relation.all()
q = q.filter(Relation.project==self.loader.project)
q = q.filter(Relation.source==self.source.entity)
q = q.filter(Relation.target==self.target.entity)
for name, only_active in self.update_criteria:
value = self.properties.get(name).get('value')
q = Entity._filter_property(q, name, value,
only_active=only_active)
relation = q.first()
try:
data = {
'project': self.loader.project,
'author': self.loader.account,
'schema': self.schemata.pop(),
'properties': self.properties,
'source': self.source.entity,
'target': self.target.entity
}
self._relation = relations.save(data, relation=relation)
except Invalid, inv:
log.warning("Validation error: %r", inv)
示例3: save
# 需要导入模块: from grano.model import Entity [as 别名]
# 或者: from grano.model.Entity import _filter_property [as 别名]
def save(self):
""" Save the entity to the database. Do this only once, after all
properties have been set. """
# fetch existing:
q = Entity.all()
q = q.filter(Entity.project == self.loader.project)
for name, only_active in self.update_criteria:
v = self.properties.get(name).get('value')
q = Entity._filter_property(q, name, v, only_active=only_active)
entity = q.first()
try:
data = {
'project': self.loader.project,
'author': self.loader.account,
'schema': self.schema,
'properties': self.properties
}
self._entity = entities.save(data, entity=entity)
except Invalid, inv:
if not self.loader.ignore_errors:
raise
log.warning("Validation error: %r", inv.asdict())