Пример #1
0
def oc_menuitem_directive(_context, name, sort_order,
                          text=None,
                          permission='zope2.View',
                          url=contained_item_url,
                          item_url=u'',
                          filter=nofilter,
                          container=IPloneSiteRoot,
                          css_class=default_css,
                          selected=if_request_starts_with_url,
                          application_header=None,
                          layer=IDefaultBrowserLayer,
                          template=None,
                          **kw):
    """create a class specific for viewlet, and register it"""
    new_keyword_args = kw.copy()
    if text is None:
        text = name
    if template is None:
        template = ZopeTwoPageTemplateFile('menuitem.pt')
    viewlet_factory = create_topnav_viewlet(
        name,
        sort_order,
        text,
        url,
        item_url,
        filter,
        container,
        css_class,
        selected,
        application_header,
        template,
        )
    new_keyword_args['class_'] = viewlet_factory
    new_keyword_args['manager'] = TopnavManager
    viewletDirective(_context, name, permission, layer=layer, **new_keyword_args)
Пример #2
0
def registerComponent(_context, name, component, viewlet, manager, 
                      selection=None, image=None, permission="zope.Public"):
    """ Register a component to be used by articles
    """
    adapter(_context, [component], interfaces.IComponent, name=name, for_=[interfaces.IArticle])
    if selection:
        adapter(_context, [component], interfaces.IComponentSelection, name=name, for_=[selection])
        
    viewletDirective(_context, component.viewlet, permission, for_=component.interface, manager=manager, class_=viewlet, view=interfaces.IArticleView)

    if not image:
        path = os.path.abspath(str(_context.path(component.image.replace('++resource++', ''))))
        if os.path.isfile(path):
            image = path
    if image:
        resource(_context, component.image.replace('++resource++', ''), image=image)