当前位置: 首页>>代码示例>>Python>>正文


Python interfaces.IFolderish类代码示例

本文整理汇总了Python中Products.CMFCore.interfaces.IFolderish的典型用法代码示例。如果您正苦于以下问题:Python IFolderish类的具体用法?Python IFolderish怎么用?Python IFolderish使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了IFolderish类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: getContext

def getContext(context=None):
    if context is NO_VALUE or context is None or not IFolderish.providedBy(context):
        #return SimpleVocabulary(terms)
        req = getRequest()
        for parent in req.PARENTS:
            if IFolderish.providedBy(parent):
                context = parent
                break
    return context
开发者ID:collective,项目名称:collective.importexport,代码行数:9,代码来源:import_view.py

示例2: fields

 def fields(self):
     if 'collective.behavior.sql.behavior.behaviors.ISQLContent' not in self.context.fti.behaviors:
         return super(SQLTypeOverviewForm, self).fields
     # if this type's class is not a container,
     # remove the field for filtering contained content types
     klass = resolveDottedName(self.context.fti.klass)
     fields = field.Fields(ISQLTypeSettings)
     fti_adapted = ISQLTypeSettings(self.context.fti)
     to_omit = []
     if not fti_adapted.sql_connection:
         to_omit = ['sql_table', 'sql_id_column', 'sql_WHERE', 'sql_modification_timestamp_column', 'sql_modification_last_timestamp', 'sql_folder_id']
         fields = fields.omit('sql_table', 'sql_id_column', 'sql_WHERE', 'sql_modification_timestamp_column', 'sql_modification_last_timestamp', 'sql_folder_id')
     elif not fti_adapted.sql_table:
         to_omit = ['sql_id_column', 'sql_WHERE', 'sql_modification_timestamp_column', 'sql_modification_last_timestamp', 'sql_folder_id']
         fields = fields.omit('sql_id_column', 'sql_WHERE', 'sql_modification_timestamp_column', 'sql_modification_last_timestamp', 'sql_folder_id')
     else:
         engine = create_engine(fti_adapted.sql_connection)
         insp = reflection.Inspector.from_engine(engine)
         tables = insp.get_table_names()
         views = insp.get_view_names()
         if fti_adapted.sql_table in views and fti_adapted.sql_table not in tables:
             fields['sql_id_column'].field.vocabulary = None
             fields['sql_id_column'].field.vocabularyName = "collective.behavior.sql.AvailableSQLAlchemyColumns"
     names = [a for a in ISQLTypeSettings.names() if a not in to_omit]
     filtered = fields.select('title', 'description',
                              'allowed_content_types',
                              'filter_content_types',
                              *names)
     if not IFolderish.implementedBy(klass):
         del filtered['filter_content_types']
     urls = ISQLAlchemyConnectionStrings(component.getUtility(ISiteRoot)).values()
     if len(urls) == 1:
         filtered['sql_connection'].field.default = urls[0]
     return filtered
开发者ID:Martronic-SA,项目名称:collective.behavior.sql,代码行数:34,代码来源:overview.py

示例3: recurse

def recurse(tree, report_file):
    """ Walk through all the content on a Plone site """
    print 'Checking %s' % tree.getId()
    for id, child in tree.contentItems():
	report_objects_with_broken_blobs(child, report_file)
        if IFolderish.providedBy(child):
            recurse(child, report_file)
开发者ID:Siyavula,项目名称:emas.buildout,代码行数:7,代码来源:find_broken_blobs.py

示例4: get_media_container

 def get_media_container(self):
     container = None
     config_media_path = api.portal.get_registry_record(
         'collective.behavior.relatedmedia.media_container_path')
     nav_root = api.portal.get_navigation_root(self.context)
     media_path = "{}{}".format(
         '/'.join(nav_root.getPhysicalPath()), config_media_path)
     try:
         container = self.context.restrictedTraverse(safe_utf8(media_path))
     except:
         # try to create media folder
         container = nav_root
         for f_id in config_media_path.split('/'):
             if not f_id:
                 continue
             if not hasattr(container, f_id):
                 container = createContentInContainer(
                     container, 'Folder', id=f_id, title=f_id,
                     exclude_from_nav=True, checkConstraints=False)
             else:
                 container = container[f_id]
     if container is None:
         container = aq_inner(self.context)
         while not IFolderish.providedBy(container):
             container = aq_parent(container)
     return container
开发者ID:kombinat,项目名称:collective.behavior.relatedmedia,代码行数:26,代码来源:browser.py

示例5: upgrade

def upgrade(context):
    old_stuff = [
        'challenges',
        'workspaces',
        'universities',
        'welcome-to-the-cnrd-virtual-center',
        'people',
        'library',
    ]

    attributes_to_copy = ['title', 'description', 'text', ]

    site = getSite()

    # rename old stuff
    for oid in old_stuff:
        if oid in site.keys():
            site.manage_renameObjects([oid], ['old_stuff_' + oid])
            print 'renamed %s to %s' % (oid, 'old_stuff_' + oid)
        else:
            old_stuff.remove(oid)
            print 'skipping %s' % (oid)

    # cleanup products
    quickinstaller = site.portal_quickinstaller
    installed = quickinstaller.listInstalledProducts()
    quickinstaller.uninstallProducts([p['id'] for p in installed])
    quickinstaller.installProduct('cnrd.vcpolicy')

    # move content to new folders
    for oid in old_stuff:
        old_obj = site['old_stuff_' + oid]
        new_obj = site.get(oid, None)

        if new_obj is None:
            continue

        # set attributes
        for attr in attributes_to_copy:
            value = getattr(old_obj, attr, None)
            if value is not None:
                setattr(new_obj, attr, value)

        if not IFolderish.providedBy(old_obj):
            continue

        clip = old_obj.manage_cutObjects(old_obj.keys())
        new_obj.manage_pasteObjects(clip)
        print 'content moved from %s to %s' % ('old_stuff_' + oid, oid)

    # remove old stuff
    for oid in old_stuff:
        site.manage_delObjects('old_stuff_' + oid)
        print 'removed %s' % ('old_stuff_' + oid)

    # rebuild the catalog
    catalog = getToolByName(context, 'portal_catalog')
    catalog.clearFindAndRebuild()
    for challenge in site['challenges'].values():
        challenge.reindexObject()
开发者ID:ixds,项目名称:plone-virtualcenter,代码行数:60,代码来源:to3.py

示例6: 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)
开发者ID:fourdigits,项目名称:ftw.subsite,代码行数:25,代码来源:negotiator.py

示例7: can_configure

 def can_configure(self):
     """Check if folderview can be configured on context"""
     context = self.context
     if not IFolderish.providedBy(context):
         return False
     already_activated = self.isFolderViewActivated()
     return (not already_activated)
开发者ID:IMIO,项目名称:cpskin.core,代码行数:7,代码来源:folderview.py

示例8: update

    def update(self):
        super(LogoViewlet, self).update()
        context = aq_inner(self.context)
        p_properties = getToolByName(context, 'portal_properties')
        if hasattr(p_properties, 'folder_logo_properties'):
            portal = self.portal_state.portal()
            bprops = portal.restrictedTraverse('base_properties', None)
            title = None
            folder_logo_properties = getattr(p_properties, 'folder_logo_properties')
            logo_id = IFolderLogoProperties(folder_logo_properties).logo_id
            context = aq_inner(self.context)
            catalog = getToolByName(context, 'portal_catalog')
            folders = [folder for folder in aq_chain(context) if IFolderish.providedBy(folder)]
            logos = []
            for folder in folders:
                path = '/'.join(folder.getPhysicalPath())
                brains = catalog(
                    path=dict(query=path, depth=1),
                    id = logo_id,
                    object_provides = IATImage.__identifier__,
                )
                if len(brains) != 0:
                    logos.append(brains[0])
            if len(logos) != 0:
                logoName = logo_id
                title = logos[0].Title
                portal = aq_parent(logos[0].getObject())
            elif bprops is not None:
                logoName = bprops.logoName
            else:
                logoName = 'logo.jpg'
            self.logo_tag = portal.restrictedTraverse(logoName).tag()

            self.portal_title = title or self.portal_state.portal_title()
开发者ID:taito,项目名称:collective.folderlogo,代码行数:34,代码来源:viewlets.py

示例9: background

    def background(self):
        context = aq_inner(self.context)
        p_properties = getToolByName(context, 'portal_properties')
        if hasattr(p_properties, 'folder_logo_properties'):
            catalog = getToolByName(context, 'portal_catalog')
            folder_logo_properties = getattr(p_properties, 'folder_logo_properties')
            flp = IFolderLogoProperties(folder_logo_properties)
            color = flp.background_color
            image_id = flp.background_image_id

            folders = [folder for folder in aq_chain(context) if IFolderish.providedBy(folder)]
            images = []
            for folder in folders:
                path = '/'.join(folder.getPhysicalPath())
                brains = catalog(
                    path=dict(query=path, depth=1),
                    id = image_id,
                    object_provides = IATImage.__identifier__,
                )
                if len(brains) != 0:
                    images.append(brains[0])
            if len(images) != 0:
                image_path = images[0].getPath()
                style = "background: %s url(%s) no-repeat;" % (color, image_path)
            else:
                style = "background: %s no-repeat;" % (color)
            return style
开发者ID:taito,项目名称:collective.folderlogo,代码行数:27,代码来源:viewlets.py

示例10: getBreadcrumbs

def getBreadcrumbs(self, path=None):
    """Patch for displaying plone root in tiny mce breadcrumbs for
    browsing language neutral folders located next to language folders.
    """
    result = []

    root = getUtility(ISiteRoot)
    root_url = root.absolute_url()

    if path is not None:
        root_abs_url = root.absolute_url()
        path = path.replace(root_abs_url, '', 1)
        path = path.strip('/')
        root = aq_inner(root.restrictedTraverse(path))

    relative = aq_inner(self.context).getPhysicalPath()[len(
        root.getPhysicalPath()):]
    if path is None:
        # Add siteroot
        result.append({'title': 'Root',
            'url': '/'.join(root.getPhysicalPath())})

    for i in range(len(relative)):
        now = relative[:i + 1]
        obj = aq_inner(root.restrictedTraverse(now))

        if IFolderish.providedBy(obj):
            if not now[-1] == 'talkback':
                result.append({'title': obj.title_or_id(),
                    'url': root_url + '/' + '/'.join(now)})
    return result
开发者ID:collective,项目名称:slc.linguatools,代码行数:31,代码来源:patch_tinymce_breadcrumbs.py

示例11: navStrategy

 def navStrategy(self):
     context = aq_inner(self.context)
     if IFolderish.providedBy(context):
         root = '/'.join(context.getPhysicalPath())
     else:
         parent = context.__parent__
         root = '/'.join(parent.getPhysicalPath())
     query = {
         'path': root,
         'review_state': 'published',
         'portal_type': 'meetshaus.jmscontent.contentpage',
         'sort_order': 'getObjPositionInParent'
     }
     root_obj = context.unrestrictedTraverse(root)
     strategy = DefaultNavtreeStrategy(root_obj)
     strategy.rootPath = '/'.join(root_obj.getPhysicalPath())
     strategy.showAllParents = False
     strategy.bottomLevel = 999
     tree = buildFolderTree(root_obj, root_obj, query, strategy=strategy)
     items = []
     for c in tree['children']:
         item = {}
         item['item'] = c['item']
         item['children'] = c.get('children', '')
         item['itemid'] = c['normalized_id']
         item_id = c['normalized_id']
         if item_id == context.getId():
             item['class'] = 'active'
         else:
             item['class'] = ''
         items.append(item)
     return items
开发者ID:potzenheimer,项目名称:buildout.jms,代码行数:32,代码来源:subnavigation.py

示例12: set_folder_context_path

def set_folder_context_path(path, context):
    """
    Retorna o contexto da pas

    Args:
        path (list): Do caminho onde a pasta será criada
        context (plone context): Contexto de onde irá criar a pasta

    Returns:
        Retorna o contexto da ultima pasta criada 
    """

    if path:
        #Remove espacos em branco da lista
        path = [i for i in path if i]
        if path:
            p = path[0]
            normalizer = component.getUtility(IIDNormalizer)
            id = normalizer.normalize(p)
            if context.get(id, False):
                folder = context[id]
                if IFolderish.providedBy(folder):
                    if len(path) <= 1:
                        return folder
                else:
                    return False
            else:
                return False

            return set_folder_context_path(path[1:], folder)
    else:
        return context
开发者ID:vindula,项目名称:vindula.content,代码行数:32,代码来源:utils.py

示例13: getSections

 def getSections(self):
     portal = self.portal_state.portal()
     items = portal.getFolderContents()
     for brain in items:
         obj = brain.getObject()
         if IFolderish.providedBy(obj):
             yield obj
开发者ID:plone-gomobile,项目名称:gomobiletheme.mobipublic,代码行数:7,代码来源:viewlets.py

示例14: getBanners

    def getBanners(self):
        """
        Returns a list of objects that provide ICarouselBanner.
        """

        banner_brains = []
        if IFolderish.providedBy(self.context):
            catalog = getToolByName(self.context, "portal_catalog")
            banner_brains = catalog.searchResults(
                {
                    "path": "/".join(self.context.getPhysicalPath()),
                    "object_provides": ICarouselBanner.__identifier__,
                    "sort_on": "getObjPositionInParent",
                }
            )
        elif IATTopic.providedBy(self.context):
            banner_brains = self.context.queryCatalog()

        banner_objects = [b.getObject() for b in banner_brains]
        banner_objects = [b for b in banner_objects if ICarouselBanner.providedBy(b)]

        # Shuffle carousel images if needde
        if self.getSettings().random_order:
            shuffle(banner_objects)

        return banner_objects
开发者ID:adam139,项目名称:devplone422,代码行数:26,代码来源:folder.py

示例15: update

    def update(self):
        super(LogoViewlet, self).update()
        context = aq_inner(self.context)
        registry = getUtility(IRegistry)
        portal = self.portal_state.portal()
        bprops = portal.restrictedTraverse('base_properties', None)
        title = None
        logo_id = registry.get('collective.folderlogo.logo_id', u'logo')
        context = aq_inner(self.context)
        catalog = getToolByName(context, 'portal_catalog')
        folders = [folder for folder in aq_chain(context) if IFolderish.providedBy(folder)]
        logos = []
        for folder in folders:
            path = '/'.join(folder.getPhysicalPath())
            brains = catalog(
                path=dict(query=path, depth=1),
                id=logo_id,
                object_provides=IATImage.__identifier__)
            if len(brains) != 0:
                logos.append(brains[0])
        if len(logos) != 0:
            logoName = logo_id
            title = logos[0].Title
            portal = aq_parent(logos[0].getObject())
        elif bprops is not None:
            logoName = bprops.logoName
        else:
            logoName = 'logo.jpg'
        self.logo_tag = portal.restrictedTraverse(str(logoName)).tag()

        self.portal_title = title or self.portal_state.portal_title()
开发者ID:collective,项目名称:collective.folderlogo,代码行数:31,代码来源:viewlets.py


注:本文中的Products.CMFCore.interfaces.IFolderish类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。