本文整理汇总了Python中Products.ATContentTypes.content.base.ATCTContent类的典型用法代码示例。如果您正苦于以下问题:Python ATCTContent类的具体用法?Python ATCTContent怎么用?Python ATCTContent使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了ATCTContent类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: initializeArchetype
def initializeArchetype(self, **kwargs):
""" Translate the adapter in the current langage
"""
ATCTContent.initializeArchetype(self, **kwargs)
self.setNoSubmitMessage(zope.i18n.translate(_(u'pfg_thankspage_nosubmitmessage', u'<p>No input was received. Please <a title="Test Folder" href=".">visit the form</a>.</p>'), context=self.REQUEST))
示例2: at_post_create_script
def at_post_create_script(self):
""" activate action adapter in parent folder """
# XXX TODO - change to use events when we give up on Plone 2.1.x
ATCTContent.at_post_create_script(self)
self.aq_parent.addActionAdapter(self.id)
示例3: manage_afterAdd
def manage_afterAdd(self, item, container):
# TODO: when we're done with 2.1.x, implement this via event subscription
ATCTContent.manage_afterAdd(self, item, container)
id = self.getId()
if self.fgField.__name__ != id:
self.fgField.__name__ = id
示例4: setFormat
def setFormat(self, value):
"""
Method for CMF compatibility, set for body format
"""
if not value:
value = "text/html"
else:
value = translateMimetypeAlias(value)
ATCTContent.setFormat(self, value)
示例5: update
def update(self, event=None, **kwargs):
# Clashes with BaseObject.update, so
# we handle gracefully
info = {}
if event is not None:
for field in event.Schema().fields():
info[field.getName()] = event[field.getName()]
elif kwargs:
info = kwargs
ATCTContent.update(self, **info)
示例6: processForm
def processForm(self, data=1, metadata=0, REQUEST=None, values=None):
# override base so that we can selectively redirect back to the form
# rather than to the thanks page view.
# base processing
ATCTContent.processForm(self, data, metadata, REQUEST, values)
# if the referer is the item itself, let nature take its course;
# if not, redirect to form after a commit.
referer = self.REQUEST.form.get('last_referer', None)
if referer is not None and referer.split('/')[-1] != self.getId():
transaction.commit()
raise zExceptions.Redirect, "%s#qedit" % self.formFolderObject().absolute_url()
示例7: manage_beforeDelete
def manage_beforeDelete(self, item, container):
#
# Hook method, called before object deletion
#
# Get list for ids of referenced comments,trackbacks
ids = [obj.id for obj in self.getComment()]
ids += [obj.id for obj in self.getTrackback()]
# Now delete them all!
self.aq_parent.getCommentFolder().manage_delObjects(ids)
# Call superclass method
ATCTContent.manage_beforeDelete(self, item, container)
示例8: setFormat
def setFormat(self, value):
# CMF compatibility method.
#
# The default mutator is overwritten to:
#
# o add a conversion from stupid CMF content type
# (e.g. structured-text) to real mime types used by MTR.
#
# o Set format to default format if value is empty
if not value:
value = zconf.ATDocument.default_content_type
else:
value = translateMimetypeAlias(value)
ATCTContent.setFormat(self, value)
示例9: _notifyOfCopyTo
def _notifyOfCopyTo(self, container, op=0):
"""Override this to store a flag when we are copied, to be able
to discriminate the right thing to do in manage_afterAdd here
below.
"""
self._v_renamed = 1
return ATCTContent._notifyOfCopyTo(self, container, op=op)
示例10: __bobo_traverse__
def __bobo_traverse__(self, REQUEST, name):
"""
Transparent access to image scales of image fields
on content.
"""
if name.startswith('image_'):
name = name[len('image_'):]
split = name.rsplit('_', 1)
if len(split) == 2:
# has scale with it
fieldname, scale = split
else:
fieldname = name
scale = None
field = self.getField(fieldname)
image = None
if field and \
field.getType() == 'uwosh.pfg.d2c.extender.XImageField':
if scale is None:
image = field.getScale(self)
else:
if scale in field.getAvailableSizes(self):
image = field.getScale(self, scale=scale)
if image is not None and not isinstance(image, basestring):
# image might be None or '' for empty images
return image
return ATCTContent.__bobo_traverse__(self, REQUEST, name)
示例11: manage_afterPUT
def manage_afterPUT(self, data, marshall_data, file, context, mimetype, filename, REQUEST, RESPONSE):
# After webdav/ftp PUT method.
# Set title according to the id on webdav/ftp PUTs.
if "" == data:
file.seek(0)
content = file.read(65536)
else:
content = data
if -1 != content.lower().find("<html"):
parser = etree.HTMLParser()
tree = etree.fromstring(content, parser=parser)
titletag = tree.xpath("//title")
if titletag:
self.setTitle(titletag[0].text)
return
ATCTContent.manage_afterPUT(self, data, marshall_data, file, context, mimetype, filename, REQUEST, RESPONSE)
示例12: manage_afterAdd
def manage_afterAdd(self, item, container):
# Fix text when created through webdav.
# Guess the right mimetype from the id/data.
ATCTContent.manage_afterAdd(self, item, container)
field = self.getField("text")
# hook for mxTidy / isTidyHtmlWithCleanup validator
tidyOutput = self.getTidyOutput(field)
if tidyOutput:
if hasattr(self, "_v_renamed"):
mimetype = field.getContentType(self)
del self._v_renamed
else:
mimetype = self.guessMimetypeOfText()
if mimetype:
field.set(self, tidyOutput, mimetype=mimetype) # set is ok
elif tidyOutput:
field.set(self, tidyOutput) # set is ok
示例13: manage_afterPUT
def manage_afterPUT(self, data, marshall_data, file, context, mimetype,
filename, REQUEST, RESPONSE):
# After webdav/ftp PUT method.
# Set title according to the id on webdav/ftp PUTs.
if '' == data:
file.seek(0)
content = file.read(65536)
else:
content = data
if -1 != content.lower().find("<html"):
parser = SimpleHTMLParser()
parser.feed(content)
if parser.title:
self.setTitle(parser.title)
return
ATCTContent.manage_afterPUT(self, data, marshall_data, file,
context, mimetype, filename, REQUEST,
RESPONSE)
示例14: __bobo_traverse__
def __bobo_traverse__(self, REQUEST, name):
try:
return self[name]
except KeyError:
pass
if hasattr(aq_base(self), name):
return getattr(self, name)
# webdav
"""
method = REQUEST.get('REQUEST_METHOD', 'GET').upper()
if (method not in ('GET', 'POST') and not
isinstance(REQUEST.RESPONSE, xmlrpc.Response) and
REQUEST.maybe_webdav_client and not REQUEST.path):
return ReflectoNullResource(self, name, REQUEST).__of__(self)
"""
return ATCTContent.__bobo_traverse__(self, REQUEST, name)
示例15: __bobo_traverse__
def __bobo_traverse__(self, REQUEST, name):
"""Transparent access to image scales
"""
if name.startswith('backgroundImage'):
field = self.getField('backgroundImage')
image = None
if name == 'backgroundImage':
image = field.getScale(self)
else:
scalename = name[len('backgroundImage_'):]
if scalename in field.getAvailableSizes(self):
image = field.getScale(self, scale=scalename)
if image is not None and not isinstance(image, basestring):
# image might be None or '' for empty images
return image
return ATCTContent.__bobo_traverse__(self, REQUEST, name)