示例#1
0
文件: menu.py 项目: silvacms/silva.ui
 def describe(self, page, path, actives):
     data = {}
     if self.name is not None:
         data["name"] = page.translate(self.name)
     elif self.logo is not None:
         data["logo"] = self.logo
     if self.screen is not None:
         is_screen = False
         if IRESTComponent.implementedBy(self.screen):
             for active in actives:
                 if isinstance(active, self.screen):
                     data["active"] = True
                     break
             is_screen = IUIScreen.implementedBy(self.screen)
         elif self.interface is not None:
             for active in actives:
                 if self.interface.providedBy(active):
                     data["active"] = True
                     break
             is_screen = self.interface.extends(IUIScreen)
         if is_screen:
             screen = self.identifier()
             data["screen"] = "/".join((path, screen)) if path else screen
     if self.action is not None:
         data["action"] = self.action
     if self.description is not None:
         data["description"] = page.translate(self.description)
     if self.accesskey is not None:
         data["accesskey"] = self.accesskey
     if self.icon is not None:
         data["icon"] = self.icon
     return data
示例#2
0
文件: menu.py 项目: silvacms/silva.ui
    def describe(self, page):
        actives = [page]
        active = page.__parent__
        while IRESTComponent.providedBy(active):
            actives.append(active)
            active = active.__parent__

        return map(lambda e: e.describe(page, None, actives), self)
示例#3
0
def queryRESTComponent(specs, args, name=u'', parent=None, id=_marker):
    """Query the ZCA for a REST component.
    """
    factory = getComponent(specs, IRESTComponent, name, default=None)
    if factory is not None:
        result = factory(*args)
        if result is not None and IRESTComponent.providedBy(result):
            # Set parenting information / for security
            if id is _marker:
                id = name
            result.__name__ = id
            result.__parent__ = parent
            return result
    return None
示例#4
0
文件: base.py 项目: silvacms/silva.ui
 def __init__(self, screen):
     # Follow Zope 2 information to appear in the undo log.
     note = []
     if ISilvaObject.providedBy(screen.context) or IVersion.providedBy(screen.context):
         note.append("/".join(screen.context.getPhysicalPath()))
     else:
         note.append("/")
     names = []
     while IRESTComponent.providedBy(screen):
         names.append(screen.__name__)
         screen = screen.__parent__
     if names:
         note.extend(["SMI action:", "/".join(reversed(names))])
     self.note = " ".join(note)
     self.user = getSecurityManager().getUser()
     self.user_path = ""
     auth_folder = aq_parent(self.user)
     if auth_folder is not None:
         self.user_path = "/".join(auth_folder.getPhysicalPath()[1:-1])
示例#5
0
def get_tab_path(tab):
    path = []
    while IRESTComponent.providedBy(tab):
        path.extend(reversed_clean_path(tab.__name__))
        tab = tab.__parent__
    return path
示例#6
0
 def __str__(self):
     pattern = '%s/++rest++%s'
     if IRESTComponent.providedBy(self.context.__parent__):
         pattern = '%s/%s'
     return pattern % (self._parent_url(), self.context.__name__)
示例#7
0
文件: menu.py 项目: silvacms/silva.ui
 def identifier(self):
     if IRESTComponent.implementedBy(self.screen):
         return grok.name.bind().get(self.screen)
     if isinstance(self.screen, basestring):
         return self.screen
     return None