本文整理汇总了Python中Products.PageTemplates.ZopePageTemplate.ZopePageTemplate.write方法的典型用法代码示例。如果您正苦于以下问题:Python ZopePageTemplate.write方法的具体用法?Python ZopePageTemplate.write怎么用?Python ZopePageTemplate.write使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Products.PageTemplates.ZopePageTemplate.ZopePageTemplate
的用法示例。
在下文中一共展示了ZopePageTemplate.write方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: get_mail_body
# 需要导入模块: from Products.PageTemplates.ZopePageTemplate import ZopePageTemplate [as 别名]
# 或者: from Products.PageTemplates.ZopePageTemplate.ZopePageTemplate import write [as 别名]
def get_mail_body(self, fields, request, context):
"""Returns the mail-body with footer.
"""
schema = get_fields(context)
all_fields = [f for f in fields
# TODO
# if not (f.isLabel() or f.isFileField()) and not (getattr(self,
# 'showAll', True) and f.getServerSide())]
if not (INamedFile.providedBy(fields[f])) and not (getattr(self, 'showAll', True) and IFieldExtender(schema[f]).serverSide)
]
# which fields should we show?
if getattr(self, 'showAll', True):
live_fields = all_fields
else:
live_fields = [
f for f in all_fields if f in getattr(self, 'showFields', ())]
if not getattr(self, 'includeEmpties', True):
all_fields = live_fields
live_fields = [f for f in all_fields if fields[f]]
for f in all_fields:
value = fields[f]
if value:
live_fields.append(f)
#bare_fields = [schema[f] for f in live_fields]
bare_fields = dict([(f, fields[f]) for f in live_fields])
bodyfield = self.body_pt
# pass both the bare_fields (fgFields only) and full fields.
# bare_fields for compatability with older templates,
# full fields to enable access to htmlValue
replacer = DollarVarReplacer(fields).sub
extra = {
'data': bare_fields,
'fields': dict([(i, j.title) for i, j in getFieldsInOrder(schema)]),
'mailer': self,
'body_pre': self.body_pre and replacer(self.body_pre),
'body_post': self.body_post and replacer(self.body_post),
'body_footer': self.body_footer and replacer(self.body_footer),
}
template = ZopePageTemplate(self.__name__)
template.write(bodyfield)
template = template.__of__(context)
body = template.pt_render(extra_context=extra)
# if isinstance(body, unicode):
#body = body.encode("utf-8")
#keyid = getattr(self, 'gpg_keyid', None)
#encryption = gpg and keyid
# if encryption:
#bodygpg = gpg.encrypt(body, keyid)
# if bodygpg.strip():
#body = bodygpg
return body
示例2: get_mail_body
# 需要导入模块: from Products.PageTemplates.ZopePageTemplate import ZopePageTemplate [as 别名]
# 或者: from Products.PageTemplates.ZopePageTemplate.ZopePageTemplate import write [as 别名]
def get_mail_body(self, unsorted_data, request, context):
"""Returns the mail-body with footer.
"""
schema = get_schema(context)
data = OrderedDict(
[x for x in getFieldsInOrder(schema) if x[0] in unsorted_data]
)
data.update(unsorted_data)
all_data = [
f for f in data
# TODO
# if not (f.isLabel() or f.isFileField()) and not (getattr(self,
# 'showAll', True) and f.getServerSide())]
if not (self._is_file_data(data[f])) and not (
getattr(self, 'showAll', True) and
IFieldExtender(schema[f]).serverSide
)
]
# which data should we show?
if getattr(self, 'showAll', True):
live_data = all_data
else:
showFields = getattr(self, 'showFields', [])
if showFields is None:
showFields = []
live_data = [
f for f in all_data if f in showFields]
if not getattr(self, 'includeEmpties', True):
all_data = live_data
live_data = [f for f in all_data if data[f]]
for f in all_data:
value = data[f]
if value:
live_data.append(f)
bare_data = OrderedDict([(f, data[f]) for f in live_data])
bodyfield = self.body_pt
# pass both the bare_fields (fgFields only) and full fields.
# bare_fields for compatability with older templates,
# full fields to enable access to htmlValue
replacer = DollarVarReplacer(data).sub
extra = {
'data': bare_data,
'fields': OrderedDict([
(i, j.title)
for i, j in getFieldsInOrder(schema)
]),
'mailer': self,
'body_pre': self.body_pre and replacer(self.body_pre),
'body_post': self.body_post and replacer(self.body_post),
'body_footer': self.body_footer and replacer(self.body_footer),
}
template = ZopePageTemplate(self.__name__)
template.write(bodyfield)
template = template.__of__(context)
body = template.pt_render(extra_context=extra)
# if isinstance(body, unicode):
# body = body.encode("utf-8")
# keyid = getattr(self, 'gpg_keyid', None)
# encryption = gpg and keyid
# if encryption:
# bodygpg = gpg.encrypt(body, keyid)
# if bodygpg.strip():
# body = bodygpg
return body
示例3: getDefault
# 需要导入模块: from Products.PageTemplates.ZopePageTemplate import ZopePageTemplate [as 别名]
# 或者: from Products.PageTemplates.ZopePageTemplate.ZopePageTemplate import write [as 别名]
def getDefault(self, instance):
value = ObjectField.getDefault(self, instance)
zpt = ZopePageTemplate(self.getName())
zpt.write(value)
return zpt.__of__(instance)
示例4: set
# 需要导入模块: from Products.PageTemplates.ZopePageTemplate import ZopePageTemplate [as 别名]
# 或者: from Products.PageTemplates.ZopePageTemplate.ZopePageTemplate import write [as 别名]
def set(self, instance, value, **kwargs):
if not isinstance(value, ZopePageTemplate):
zpt = ZopePageTemplate(self.getName())
zpt.write(value)
value = zpt
ObjectField.set(self, instance, value, **kwargs)
示例5: renderFeedbacktext
# 需要导入模块: from Products.PageTemplates.ZopePageTemplate import ZopePageTemplate [as 别名]
# 或者: from Products.PageTemplates.ZopePageTemplate.ZopePageTemplate import write [as 别名]
def renderFeedbacktext(self):
pt = ZopePageTemplate(self.id+'_tmp')
pt.write(self.feedbacktext)
return pt.__of__(self)()
示例6: get_mail_body
# 需要导入模块: from Products.PageTemplates.ZopePageTemplate import ZopePageTemplate [as 别名]
# 或者: from Products.PageTemplates.ZopePageTemplate.ZopePageTemplate import write [as 别名]
def get_mail_body(self, unsorted_data, request, context):
"""Returns the mail-body with footer.
"""
schema = get_schema(context)
form = DummyFormView(context, request)
form.schema = schema
form.prefix = 'form'
form._update()
widgets = {name: widget.render() for name, widget in form.w.items()}
data = OrderedDict(
[x for x in getFieldsInOrder(schema) if x[0] in unsorted_data]
)
data.update(unsorted_data)
all_data = [
f for f in data
# TODO
# if not (f.isLabel() or f.isFileField()) and not (getattr(self,
# 'showAll', True) and f.getServerSide())]
if not (self._is_file_data(data[f])) and not (
getattr(self, 'showAll', True) and
IFieldExtender(schema[f]).serverSide
)
]
# which data should we show?
if getattr(self, 'showAll', True):
live_data = all_data
else:
showFields = getattr(self, 'showFields', [])
if showFields is None:
showFields = []
live_data = [
f for f in all_data if f in showFields]
if not getattr(self, 'includeEmpties', True):
all_data = live_data
live_data = [f for f in all_data if data[f]]
for f in all_data:
value = data[f]
if value:
live_data.append(f)
bare_data = OrderedDict([(f, data[f]) for f in live_data])
bodyfield = self.body_pt
# pass both the bare_fields (fgFields only) and full fields.
# bare_fields for compatability with older templates,
# full fields to enable access to htmlValue
if isinstance(self.body_pre, basestring):
body_pre = self.body_pre
else:
body_pre = self.body_pre.output
if isinstance(self.body_post, basestring):
body_post = self.body_post
else:
body_post = self.body_post.output
if isinstance(self.body_footer, basestring):
body_footer = self.body_footer
else:
body_footer = self.body_footer.output
extra = {
'data': bare_data,
'fields': OrderedDict([
(i, j.title)
for i, j in getFieldsInOrder(schema)
]),
'widgets': widgets,
'mailer': self,
'body_pre': body_pre and lnbr(dollar_replacer(body_pre, data)),
'body_post': body_post and lnbr(dollar_replacer(body_post, data)),
'body_footer': body_footer and lnbr(
dollar_replacer(body_footer, data)),
}
template = ZopePageTemplate(self.__name__)
template.write(bodyfield)
template = template.__of__(context)
return template.pt_render(extra_context=extra)
示例7: installTemplateInZodb
# 需要导入模块: from Products.PageTemplates.ZopePageTemplate import ZopePageTemplate [as 别名]
# 或者: from Products.PageTemplates.ZopePageTemplate.ZopePageTemplate import write [as 别名]
def installTemplateInZodb(folder, template):
obj = ZopePageTemplate(template.getId(), template._text, template.content_type)
obj.expand = 0
obj.write(template.read())
id = obj.getId()
folder._setObject(id, obj)