本文整理汇总了Python中Products.Archetypes.BaseObject.BaseObject类的典型用法代码示例。如果您正苦于以下问题:Python BaseObject类的具体用法?Python BaseObject怎么用?Python BaseObject使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了BaseObject类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __bobo_traverse__
def __bobo_traverse__(self, REQUEST, name):
"""Transparent access to multilanguage image scales for
content types holding an multilanguage ImageField named
'image'
NO BLOBS
"""
if name.startswith('image_') or name == 'image':
field = self.getField('image')
if not IMultilanguageField.providedBy(field):
return BaseObject.__bobo_traverse__(self, REQUEST, name)
last = REQUEST.get('ACTUAL_URL', '').endswith(name)
fieldname, scale = name, None
if '___' in name:
fieldname, lang, scalename = name.split('___')
if scalename:
scale = scalename[1:]
else:
if '_' in name:
fieldname, scale = name.split('_', 1)
if last and REQUEST.get('HTTP_USER_AGENT', False):
_scale = scale
if _scale is not None:
_scale = '_'+str(_scale)
else:
_scale = ''
REQUEST.RESPONSE.redirect(self.absolute_url()+'/'+fieldname+'___'+field._getCurrentLanguage(self)+'___'+_scale)
lang = field._getCurrentLanguage(self)
lang_before = field._v_lang
try:
field.setLanguage(lang)
image = None
if scale:
if scale in field.getAvailableSizes(self):
image = field.getScale(self, scale=scale)
else:
image = field.getScale(self)
if not image: # language fallback
defaultLang = field.getDefaultLang(self)
if defaultLang and not defaultLang == lang:
field.setLanguage(defaultLang)
if scale:
if scale in field.getAvailableSizes(self):
image = field.getScale(self, scale=scale)
else:
image = field.getScale(self)
if image is not None:
if last and REQUEST.get('HTTP_USER_AGENT', False):
_scale = scale
if _scale is not None:
_scale = '_'+str(_scale)
else:
_scale = ''
REQUEST.RESPONSE.redirect(self.absolute_url()+'/'+fieldname+'___'+defaultLang+'___'+_scale)
finally:
field.setLanguage(lang_before)
if image is not None and not isinstance(image, basestring):
# image might be None or '' for empty images
return image
return BaseObject.__bobo_traverse__(self, REQUEST, name)
示例2: _notifyOfCopyTo
def _notifyOfCopyTo(self, container, op=0):
"""In the case of a move (op=1) we need to make sure
references are mainained for all referencable objects within
the one being moved.
manage_renameObject calls _notifyOfCopyTo so that the
object being renamed doesn't lose its references. But
manage_renameObject calls _delObject which calls
manage_beforeDelete on all the children of the object
being renamed which deletes all references for children
of the object being renamed. Here is a patch that does
recursive calls for _notifyOfCopyTo to address that
problem.
"""
# XXX this doesn't appear to be necessary anymore, if it is
# it needs to be used in BaseBTreeFolder as well, it currently
# is not.
BaseObject._notifyOfCopyTo(self, container, op=op)
# keep reference info internally when op == 1 (move)
# because in those cases we need to keep refs
if op==1:
self._v_cp_refs = 1
for child in self.contentValues():
if IReferenceable.providedBy(child):
child._notifyOfCopyTo(self, op)
示例3: _notifyOfCopyTo
def _notifyOfCopyTo(self, container, op=0):
# OFS.CopySupport notify
BaseObject._notifyOfCopyTo(self, container, op=op)
# keep reference info internally when op == 1 (move)
# because in those cases we need to keep refs
if op == 1:
self._v_cp_refs = 1
示例4: __bobo_traverse__
def __bobo_traverse__(self, REQUEST, name):
""" helper to access multilanguage image scales the old way during
`unrestrictedTraverse` calls
the method to be patched is '__bobo_traverse__'
"""
if name.startswith('image_') or name == 'image':
field = self.getField(name.split('_')[0])
if not IMultilanguageField.providedBy(field) or not hasattr(REQUEST, 'get'):
return BaseObject.__bobo_traverse__(self, REQUEST, name)
last = REQUEST.get('ACTUAL_URL', '').endswith(name)
fieldname, scale = name, None
if '___' in name:
fieldname, lang, scalename = name.split('___')
if scalename:
scale = scalename[1:]
else:
if '_' in name:
fieldname, scale = name.split('_', 1)
if last and REQUEST.get('HTTP_USER_AGENT', False):
# begin own code
if scale in field.getAvailableSizes(self):
# end own code
_scale = scale
if _scale is not None:
_scale = '_'+str(_scale)
else:
_scale = ''
REQUEST.RESPONSE.redirect(self.absolute_url()+'/'+fieldname+'___'+field._getCurrentLanguage(self)+'___'+_scale)
lang = field._getCurrentLanguage(self)
lang_before = field._v_lang
try:
field.setLanguage(lang)
handler = IImageScaleHandler(field, None)
image = None
if handler is not None:
try:
image = handler.getScale(self, scale)
except AttributeError: # no image available, do not raise as there might be one available as a fallback
pass
if not image: # language fallback
defaultLang = field.getDefaultLang(self)
if defaultLang and not defaultLang == lang:
field.setLanguage(defaultLang)
if handler is not None:
image = handler.getScale(self, scale)
if image is not None:
if last and REQUEST.get('HTTP_USER_AGENT', False):
_scale = scale
if _scale is not None:
_scale = '_'+str(_scale)
else:
_scale = ''
REQUEST.RESPONSE.redirect(self.absolute_url()+'/'+fieldname+'___'+defaultLang+'___'+_scale)
finally:
field.setLanguage(lang_before)
if image is not None:
return image
return BaseObject.__bobo_traverse__(self, REQUEST, name)
示例5: __getitem__
def __getitem__(self, key):
"""Overwrite __getitem__.
At first it's using the BaseObject version. If the element can't be
retrieved from the schema it's using PortalFolder as fallback which
should be the ObjectManager's version.
"""
try:
return BaseObject.__getitem__(self, key)
except KeyError:
return PortalFolder.__getitem__(self, key)
示例6: manage_beforeDelete
def manage_beforeDelete(self, item, container):
BaseObject.manage_beforeDelete(self, item, container)
#and reset the rename flag (set in Referenceable._notifyCopyOfCopyTo)
self._v_cp_refs = None
示例7: manage_afterClone
def manage_afterClone(self, item):
BaseObject.manage_afterClone(self, item)
示例8: manage_afterAdd
def manage_afterAdd(self, item, container):
BaseObject.manage_afterAdd(self, item, container)
示例9: __init__
def __init__(self, oid, **kwargs):
# Call skinned first cause baseobject will set new defaults on
# those attributes anyway
PortalFolder.__init__(self, oid, self.Title())
BaseObject.__init__(self, oid, **kwargs)
示例10: __bobo_traverse__
def __bobo_traverse__(self, request, name):
# TODO: replace with IPublishTraverse or/and ITraverse
if hasattr(self, 'documents'):
if self.documents.has_key(name):
return aq_inner(getattr(self.documents, name)).__of__(self)
return BaseObject.__bobo_traverse__(self, request, name)