def addingInfo(self): """Return menu data. This is sorted by title. """ container = self.context result = [] for menu_id in (self.menu_id, 'zope.app.container.add'): if not menu_id: continue for item in getMenu(menu_id, self, self.request): extra = item.get('extra') if extra: factory = extra.get('factory') if factory: factory = getUtility(IFactory, factory) if not checkFactory(container, None, factory): continue elif item['extra']['factory'] != item['action']: item['has_custom_add_view']=True # translate here to have a localized sorting item['title'] = zope.i18n.translate(item['title'], context=self.request) result.append(item) # sort the adding info with a collator instead of a basic unicode sort collator = queryAdapter(self.request.locale, ICollator) if collator is None: collator = FallbackCollator(self.request.locale) result.sort(key = lambda x: collator.key(x['title'])) return result
def update(self): self.__updated = True self.siteInfo = createObject('groupserver.SiteInfo', self.context) self.groupsInfo = createObject('groupserver.GroupsInfo', self.context) self.pages = getMenu('page_change_menu', self.context, self.request) self.requestBase = self.request.URL.split('/')[-1]
def update(self): # should only ever be called for contexts with these interfaces assert (IWorkspaceContainer.providedBy(self.context) or IWorkspaceSectionContext.providedBy(self.context)) self.sections = getMenu("workspace_context_navigation", self.context, self.request) # get a translated copy of original workspace object workspace = translate_obj( misc.get_parent_with_interface(self, IWorkspaceContainer)) self.workspace_title = workspace.full_name
def update(self): self.__updated = True self.groupsInfo = createObject('groupserver.GroupsInfo', self.context) self.pages = getMenu('user_profile_menu', self.user, self.request) self.requestBase = self.request.URL.split('/')[-1] self.userId = self.context.getId()
def update(self): # should only ever be called for contexts with these interfaces assert IWorkspaceContainer.providedBy(self.context) or IWorkspaceSectionContext.providedBy(self.context) self.sections = getMenu("workspace_context_navigation", self.context, self.request) # Append a trailing slash to each workspace viewlet navigation entry so # that the right context is always maintained when using this navigation. for section in self.sections: section["url"] = url.set_url_context(section["url"]) # get a translated copy of original workspace object workspace = translate_obj(misc.get_parent_with_interface(self, IWorkspaceContainer)) self.workspace_title = workspace.full_name
def update(self): # should only ever be called for contexts with these interfaces assert (IWorkspaceContainer.providedBy(self.context) or IWorkspaceSectionContext.providedBy(self.context)) self.sections = getMenu("workspace_context_navigation", self.context, self.request) # Append a trailing slash to each workspace viewlet navigation entry so # that the right context is always maintained when using this navigation. for section in self.sections: section["url"] = url.set_url_context(section["url"]) # get a translated copy of original workspace object workspace = translate_obj( misc.get_parent_with_interface(self, IWorkspaceContainer)) self.workspace_title = workspace.full_name
def listActions(self, info=None, object=None): """ List all the actions defined by a provider. """ if object is None: if info is None: # There is no support for global actions return () else: object = info.content actions = [] for menu_id in _listMenuIds(): for entry in getMenu(menu_id, object, self.REQUEST): # The action needs a unique name, so I'll build one # from the object_id and the action url. That is sure # to be unique. action = str(entry['action']) if object is None: act_id = 'action_%s' % action else: act_id = 'action_%s_%s' % (object.getId(), action) if entry.get('filter') is None: filter = None else: filter = Expression(text=str(entry['filter'])) title = entry['title'] # Having bits of unicode here can make rendering very confused, # so we convert it to plain strings, but NOT if it is a # messageID. In Zope 3.2 there are two types of messages, # Message and MessageID, where MessageID is depracated. We can # type-check for both but that provokes a deprecation warning, # so we check for the "domain" attribute instead. if not hasattr(title, 'domain'): title = str(title) act = ActionInformation(id=act_id, title=title, action=Expression(text='string:%s' % action), condition=filter, category=str(menu_id), visible=1) actions.append(act) return tuple(actions)
def addingInfo(self): """Return menu data. This is sorted by title. """ container = self.context result = [] for menu_id in (self.menu_id, 'zope.app.container.add'): if not menu_id: continue for item in getMenu(menu_id, self, self.request): extra = item.get('extra') if extra: factory = extra.get('factory') if factory: factory = zapi.getUtility(IFactory, factory) if not checkFactory(container, None, factory): continue elif item['extra']['factory'] != item['action']: item['has_custom_add_view'] = True result.append(item) result.sort(lambda a, b: cmp(a['title'], b['title'])) return result
def addingInfo(self): """Return menu data. This is sorted by title. """ container = self.context result = [] for menu_id in (self.menu_id, 'zope.app.container.add'): if not menu_id: continue for item in getMenu(menu_id, self, self.request): extra = item.get('extra') if extra: factory = extra.get('factory') if factory: factory = zapi.getUtility(IFactory, factory) if not checkFactory(container, None, factory): continue elif item['extra']['factory'] != item['action']: item['has_custom_add_view']=True result.append(item) result.sort(lambda a, b: cmp(a['title'], b['title'])) return result
def __getitem__(self, menu_id): return getMenu(menu_id, self.context, self.request)
def menu(self): for mitem in getMenu('timereport', self.context, self.request): if not mitem['selected']: # workaround for Zope bug #2288, don't include @@ in action mitem['action'] = mitem['action'].replace('@@', '') yield mitem