本文整理汇总了Python中Products.Archetypes.public.ObjectField.get方法的典型用法代码示例。如果您正苦于以下问题:Python ObjectField.get方法的具体用法?Python ObjectField.get怎么用?Python ObjectField.get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Products.Archetypes.public.ObjectField
的用法示例。
在下文中一共展示了ObjectField.get方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: get
# 需要导入模块: from Products.Archetypes.public import ObjectField [as 别名]
# 或者: from Products.Archetypes.public.ObjectField import get [as 别名]
def get(self, instance, **kwargs):
value = ObjectField.get(self, instance, **kwargs)
if type(value) in types.StringTypes:
# migration from TextField
zpt = ZopePageTemplate(self.getName())
ObjectField.set(self, instance, zpt, **kwargs)
value = ObjectField.get(self, instance, **kwargs)
return value.pt_render(extra_context={'options': kwargs})
示例2: get
# 需要导入模块: from Products.Archetypes.public import ObjectField [as 别名]
# 或者: from Products.Archetypes.public.ObjectField import get [as 别名]
def get(self, instance, **kwargs):
value = ObjectField.get(self, instance, **kwargs)
if type(value) in types.StringTypes:
# migration from TextField
zpt = ZopePageTemplate(self.getName())
ObjectField.set(self, instance, zpt, **kwargs)
value = ObjectField.get(self, instance, **kwargs)
if config.CATCH_RENDER_ERRORS:
try:
return value.pt_render(extra_context={'options': kwargs})
except Exception, e:
return _(u"zpt_field_render_error",
default=u'<div class="error">An error occured while rendering this field</div>')
示例3: getRaw
# 需要导入模块: from Products.Archetypes.public import ObjectField [as 别名]
# 或者: from Products.Archetypes.public.ObjectField import get [as 别名]
def getRaw(self, instance, **kwargs):
body = ObjectField.get(self, instance, **kwargs).body()
p1 = body.find(self._seperator)
if p1 == -1:
# no seperator: we return the whole body
return body
else:
p1 = p1 + len(self._seperator)
p2 = body.find(self._seperator, p1)
return body[p1:p2]
示例4: getRaw
# 需要导入模块: from Products.Archetypes.public import ObjectField [as 别名]
# 或者: from Products.Archetypes.public.ObjectField import get [as 别名]
def getRaw(self, instance, aslist=False, **kwargs):
"""Return the list of UIDs referenced under this fields
relationship
"""
objects = []
uids = ObjectField.get(self, instance, **kwargs)
if uids is None:
uids = []
if not self.multiValued and not aslist:
if uids:
uids = uids[0]
else:
uids = None
return uids
示例5: get
# 需要导入模块: from Products.Archetypes.public import ObjectField [as 别名]
# 或者: from Products.Archetypes.public.ObjectField import get [as 别名]
def get(self, instance, aslist=False, **kwargs):
"""
"""
res = ObjectField.get(self, instance, **kwargs)
if res is None:
return res
if self.multiValued:
resolved = []
for rel in res:
resolved.append(rel.to_object)
else:
resolved = res.to_object
if aslist:
resolved = [resolved]
return resolved
示例6: get
# 需要导入模块: from Products.Archetypes.public import ObjectField [as 别名]
# 或者: from Products.Archetypes.public.ObjectField import get [as 别名]
def get(self, instance, aslist=False, **kwargs):
objects = []
rc = getToolByName(instance, REFERENCE_CATALOG)
uids = ObjectField.get(self, instance, **kwargs)
if uids is None:
uids = []
for uid in uids:
if uid:
objects.append(rc.lookupObject(uid))
if objects:
if not self.multiValued:
return objects[0]
else:
return objects
return []
示例7: get
# 需要导入模块: from Products.Archetypes.public import ObjectField [as 别名]
# 或者: from Products.Archetypes.public.ObjectField import get [as 别名]
def get(self, instance, **kwargs):
zpt = ObjectField.get(self, instance, **kwargs)
return zpt.pt_render(extra_context={'options': kwargs})
示例8: getRaw
# 需要导入模块: from Products.Archetypes.public import ObjectField [as 别名]
# 或者: from Products.Archetypes.public.ObjectField import get [as 别名]
def getRaw(self, instance, **kwargs):
dtml = ObjectField.get(self, instance, **kwargs)
return dtml.read()