本文整理汇总了Python中Products.CMFCore.interfaces.IContentish类的典型用法代码示例。如果您正苦于以下问题:Python IContentish类的具体用法?Python IContentish怎么用?Python IContentish使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了IContentish类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: list_content
def list_content(content, callback):
"""Recursively list CMF content out of the given one. ``callback``
is called every thousand items after a commit.
"""
def recurse(content):
for child in content.contentValues():
if IFolderish.providedBy(child):
for grandchild in recurse(child):
yield grandchild
yield child
count = 0
total = 0
if IFolderish.providedBy(content):
for child in recurse(content):
yield child
count += 1
total += 1
if count > 200:
logger.info('{0} items indexed'.format(total))
transaction.commit()
content._p_jar.cacheGC()
callback()
count = 0
yield content
elif IContentish.providedBy(content):
yield content
示例2: publishTraverse
def publishTraverse(self, request, name):
# Try to get an object using default traversal
adapter = DefaultPublishTraverse(self.context, request)
try:
obj = adapter.publishTraverse(request, name)
if (not IContentish.providedBy(obj)
and not IService.providedBy(obj)):
raise KeyError
# If there's no object with the given name, we get a KeyError.
# In a non-folderish context a key lookup results in an AttributeError.
except (KeyError, AttributeError):
# No object, maybe a named rest service
service = queryMultiAdapter((self.context, request),
name=request._rest_service_id + name)
if service is None:
# No service, fallback to regular view
view = queryMultiAdapter((self.context, request), name=name)
if view is not None:
return view
raise
return service
else:
# Wrap object to ensure we handle further traversal
return RESTWrapper(obj, request)
示例3: getLanguage
def getLanguage(self, langs, env):
if not IFtwSubsiteLayer.providedBy(env):
return base_negotiator.getLanguage(langs, env)
# Get current published object
obj = find_context(env)
# Filter out CSS/JS and other non contentish objects
# IFolderish check includes site root
if not (IContentish.providedBy(obj) or IFolderish.providedBy(obj)):
return base_negotiator.getLanguage(langs, env)
nav_root = get_nav_root(obj)
if ISubsite.providedBy(nav_root):
# Get language stored on Subsite
language = nav_root.force_language
if language:
return language
else:
return base_negotiator.getLanguage(langs, env)
else:
# Use normal Negotiator
return base_negotiator.getLanguage(langs, env)
示例4: get_editor_language
def get_editor_language(request):
""" Get editor language override
"""
cached = getattr(request, "_cached_admin_language", None)
if cached:
return cached
alwaysTranslate = getattr(request, "alwaysTranslate", None)
if alwaysTranslate:
return None
context = find_context(request)
# Filter out CSS and other non-sense
# IFolderish check includes site root
if not (IContentish.providedBy(context) or IFolderish.providedBy(context)):
# Early terminate
return None
# Check if we are the editor
portal_state = getMultiAdapter((context, request),
name="plone_portal_state")
if portal_state.anonymous():
# Anon visitor, normal language ->
request.alwaysTranslate = True
return None
language = 'en'
# english for all authenticated users
request._cached_admin_language = language
return language
示例5: test_provided
def test_provided(self):
from Products.CMFCore.interfaces import IContentish
from Products.CMFCore.interfaces import IIndexableObjectWrapper
obj = DummyContent()
w = self._makeOne({}, obj)
self.failUnless(IContentish.providedBy(w))
self.failUnless(IIndexableObjectWrapper.providedBy(w))
示例6: available
def available(self):
if self.anonymous:
return False
if not IContentish.providedBy(self.context):
return False
return checkPermission('big.brother.ViewAuditLog', self.context)
示例7: test_provided
def test_provided(self):
from Products.CMFCore.interfaces import IIndexableObjectWrapper
from Products.CMFCore.interfaces import IIndexableObject
obj = self._makeContent()
w = self._makeOne({}, obj)
self.assertTrue(IContentish.providedBy(w))
self.assertTrue(IIndexableObjectWrapper.providedBy(w))
self.assertTrue(IIndexableObject.providedBy(w))
示例8: delObjects
def delObjects(cont, ids):
""" abbreviation to delete objects """
delids = [id for id in ids if hasattr(aq_base(cont), id)]
for delid in delids:
try:
obj = cont.get(delid)
if not (IContentish.providedBy(obj) or IFolderish.providedBy(obj)):
cont.manage_delObjects(delid)
except (AttributeError, KeyError, BadRequest):
logger.warning("Failed to delete '%s' in '%s'" % (delid, cont.id))
示例9: _publish_structure
def _publish_structure(portal):
wtool = getToolByName(portal, 'portal_workflow')
logger = logging.getLogger('sac.aerofacil _publish_structure')
to_publish = [i for i in portal.keys() if IContentish.providedBy(portal[i])]
for i in to_publish:
try:
wtool.doActionFor(portal[i], "publish")
except WorkflowException:
logger.info("Could not publish: %s. Already published?" % i)
pass
示例10: parent
def parent(self):
context_state = getMultiAdapter((self.context, self.request), name=u'plone_context_state')
context = aq_inner(self.context)
parent = aq_parent(context)
if context_state.is_default_page():
parent = aq_parent(parent)
if INavigationRoot.providedBy(context) or (not IContentish.providedBy(parent) and not IPloneSiteRoot.providedBy(parent)):
return
return {'url': parent.absolute_url(),
'title': _(u'back to ${parent}', mapping=dict(parent=safe_unicode(parent.Title())))}
示例11: test_provided
def test_provided(self):
from Products.CMFCore.interfaces import IContentish
from Products.CMFCore.interfaces import IIndexableObjectWrapper
from Products.CMFCore.tests.base.dummy import DummyContent
obj = DummyContent()
w = ExtensibleIndexableObjectWrapper(obj, self.portal)
w.update(vars={})
self.failUnless(IContentish.providedBy(w))
self.failUnless(IIndexableObjectWrapper.providedBy(w))
示例12: test_provided
def test_provided(self):
from Products.CMFCore.interfaces import IContentish
from plone.indexer.interfaces import IIndexableObjectWrapper
from Products.CMFCore.tests.base.dummy import DummyContent
obj = DummyContent()
w = IndexableObjectWrapper(obj, self.portal.portal_catalog)
self.assertTrue(IIndexableObjectWrapper.providedBy(w))
self.assertTrue(IContentish.providedBy(w))
示例13: copied
def copied(event):
"""When an object is copied, execute rules assigned to its parent
"""
obj = event.object
if not (IContentish.providedBy(obj) or IComment.providedBy(obj)):
return
if is_portal_factory(obj):
return
execute(aq_parent(aq_inner(event.original)), event)
示例14: update
def update(self):
common.ViewletBase.update(self) # Get portal_state and portal_url
super(DropdownMenuViewlet, self).update()
context = aq_inner(self.context)
portal_props = getToolByName(context, 'portal_properties')
self.properties = portal_props.navtree_properties
self.enable_caching = api.portal.get_registry_record('webcouturier.dropdownmenu.browser.interfaces.IDropdownConfiguration.enable_caching')
self.enable_parent_clickable = api.portal.get_registry_record('webcouturier.dropdownmenu.browser.interfaces.IDropdownConfiguration.enable_parent_clickable')
self.navroot_path = getNavigationRoot(context)
uid = api.content.get_uuid(obj=context) if IContentish.providedBy(context) else None
self.data = Assignment(root_uid=uid)
示例15: moved_event
def moved_event(event):
# only execute moved event if it's not a added or removed event since
# those are handled elsewhere and they base off of this event class
if (IObjectAddedEvent.providedBy(event) or
IObjectRemovedEvent.providedBy(event)):
return
obj = event.object
if not (IContentish.providedBy(obj) or IComment.providedBy(obj)):
return
execute_event(event)