def __init__(self, context, request): super(SubFormGroupBase, self).__init__(context, request) # retrieve subforms by adaptation subforms = map(lambda f: f[1], component.getAdapters( (self.context, self, self.request), interfaces.ISubForm)) # sort them self.allSubforms = sort_components(subforms) self.subforms = []
def __init__(self, context, request): super().__init__(context, request) self.setContentData(self) steps = (f[1] for f in getAdapters((self.context, self, self.request), IStep)) self.allSteps = sort_components(steps) self.__extracted_step = False
def update(self): self.allSubforms = sort_components( query_subforms(self.context, self.request, self)) self.subforms = filter(lambda f: f.available(), self.allSubforms) # set the prefix if self.prefix is None: self.prefix = set_prefix(self.parent, self.base_prefix)
def __get__(self, form, type=None): if form is None: return Fields() cache = form.__dict__.get(self.key, None) if cache is None and IBrowserView.providedBy(form): providers = component.subscribers( (form.context, form), self.interface) providers = sort_components(providers) cache = Fields(*(p.fields for p in providers)) form.__dict__[self.key] = cache return cache
def update(self): self.__updated = True self.title = title.bind(default=self.__component_name__).get(self) # We get the real context menu_context = self.getMenuContext() # Get the MenuContext and calculate its url self.context_url = get_absolute_url(menu_context, self.request) # Get the viewlets, sort them and update them self.viewlets = sort_components(list(query_entries( menu_context, self.request, self.view, self)))
def get_interfaces(): """This collect all the listing interfaces available. """ def get_interface((name, listing)): identifier = grok.name.bind().get(listing) if not ISpecification.providedBy(listing.interface): return map( lambda (name, interface): (name, interface, identifier), listing.interface) return [(str(name), listing.interface, identifier)] return reduce( operator.add, map( get_interface, sort_components( getAllComponents(provided=IContainerJSListing), key=operator.itemgetter(1))), [])
def queryOrderedMultiSubscriptions(components, interface): return util.sort_components(component.subscribers(components, interface))
def update(self, *args, **kwargs): self.viewlets = sort_components(list(query_components( self.context, self.request, self.view, self, interface=IViewlet)))
def GET(self): listing_cfg = map( lambda (name, listing): listing.configuration(self), sort_components( getAllComponents(provided=IContainerJSListing), key=itemgetter(1))) cfg = { 'ifaces': { 'content': ['object'], 'asset': ['content', 'object'], 'container': ['content', 'object'], 'versioned': ['content', 'object'] }, 'listing': listing_cfg, 'actions': [{ 'available': {'input_mode': True}, 'actions': [{ 'title': self.translate(_(u'Cancel')), 'description': self.translate( _(u'Do not proceed with this action.')), 'icon': 'close', 'order': 5, 'action': {'input_mode': False}, 'accesskey': ['ctrl+z', 'esc'], 'iface': ['content'] }, { 'title': self.translate(_(u'Save')), 'icon': 'check', 'order': 10, 'action': {'input_mode': True}, 'accesskey': ['ctrl+s',], 'iface': ['content'] }] }, { 'available': {'input_mode': False}, 'actions': [{ 'title': self.translate(_(u'Cut')), 'description': self.translate( _(u'Cut the selected items onto the clipboard.')), 'icon': 'scissors', 'accesskey': ['ctrl+x'], 'order': 5, 'action': {'cut': True}, 'available': { 'content_match': [ 'not', ['equal', 'access', None]], 'min_items': 1}, 'ifaces': ['content'] }, { 'title': self.translate(_(u'Copy')), 'description': self.translate( _(u'Copy the selected items onto the clipboard.')), 'icon': 'copy', 'accesskey': ['ctrl+c'], 'order': 6, 'action': {'copy': True}, 'available': {'min_items': 1}, 'ifaces': ['content'] }, { 'title': None, 'order': 7, 'available': { 'content_match': [ 'not', ['equal', 'access', None]], 'clipboard_min_items': 1}, 'actions': [{ 'title': self.translate(_(u'Paste')), 'description': self.translate( _(u'Paste the items held on the clipboard.')), 'icon': 'clipboard', 'accesskey': ['ctrl+v'], 'order': 10, 'action': { 'rest': { 'action': 'paste', 'send': 'clipboard_ids'}}, 'ifaces': ['object'] }, { 'title': self.translate(_(u'Paste as Ghost')), 'description': self.translate( _(u'Paste the items held on the clipboard as Ghosts.')), 'icon': 'link', 'accesskey': ['ctrl+g'], 'order': 20, 'action': { 'rest': { 'action': 'pasteasghost', 'send': 'clipboard_ids'}}, 'ifaces': ['object'] }], 'ifaces': ['object'] }, { 'title': self.translate(_(u'Delete')), 'description': self.translate( _(u'Remove the selected items permanently.')), 'icon': 'trash', 'accesskey': ['ctrl+d'], 'order': 9, 'action': { 'rest': { 'action': 'delete', 'send': 'selected_ids',}}, 'confirmation': { 'title': self.translate(_(u"Confirm deletion")), 'message': self.translate(_(u'Do you reeally want to delete the selected content?'))}, 'available': { 'content_match': [ 'not', ['equal', 'access', None]], 'min_items': 1}, 'ifaces': ['content'] }, { 'title': self.translate(_(u'Rename')), 'description': self.translate( _(u'Change the name and/or titles of the selected items.')), 'icon': 'pencil', 'accesskey': ['ctrl+r'], 'order': 10, 'action': { 'input': { 'action': 'rename', 'values': ['identifier', 'title']}}, 'available': { 'content_match': [ 'not', ['equal', 'access', None]], 'min_items': 1}, 'ifaces': ['content'] }] }, { 'available': {'input_mode': False}, 'actions': [{ 'title': None, 'available': {'min_items': 1}, 'actions': [{ 'title': self.translate(_(u'Publish')), 'description': self.translate( _(u'Make the selected items available to the public.')), 'icon': 'check', 'accesskey': ['ctrl+p'], 'order': 10, 'action': { 'rest': { 'action': 'publish', 'send': 'selected_ids'}}, 'available': { 'content_match': [ 'equal', 'access', 'manage', 'publish'], 'items_match': [ 'or', ['provides', 'container'], ['equal', 'status_next', 'draft', 'pending'] ]}, 'ifaces': ['container', 'versioned'] }, { 'title': self.translate(_(u'New version')), 'description': self.translate( _(u'Create an editable version of the selected items.')), 'icon': 'document', 'accesskey': ['ctrl+n'], 'order': 15, 'action': { 'rest': { 'action': 'newversion', 'send': 'selected_ids'}}, 'active': {}, 'available': { 'content_match': [ 'not', ['equal', 'access', None]], 'items_match': [ 'and', ['equal', 'status_next', None], ['equal', 'status_public', 'published', 'closed'] ]}, 'ifaces': ['versioned'] }, { 'title': self.translate(_(u'Request approval')), 'description': self.translate( _(u'Change the status of the selected items to ready to review.')), 'icon': 'check', 'order': 20, 'action': { 'rest': { 'action': 'requestapproval', 'send': 'selected_ids'}}, 'available': { 'content_match': [ 'equal', 'access', 'write'], 'items_match': [ 'equal', 'status_next', 'draft']}, 'ifaces': ['versioned'] }, { 'title': self.translate(_(u'Approve for future')), 'description': self.translate( _(u'Approve the selected items with a publication date in the future.')), 'icon': 'document', 'order': 25, 'action': { 'form': { 'name': 'silva.core.smi.approveforfuture', 'identifier': 'form.prefix.contents'}}, 'available': { 'content_match': [ 'equal', 'access', 'manage', 'publish'], 'items_match': [ 'equal', 'status_next', 'draft', 'pending']}, 'ifaces': ['versioned'] }, { 'title': self.translate(_(u'Reject request')), 'description': self.translate( _(u'Change the status of the selected items back to draft.')), 'icon': 'close', 'order': 30, 'action': { 'rest': { 'action': 'rejectrequest', 'send': 'selected_ids'}}, 'available': { 'content_match': [ 'equal', 'access', 'manage', 'publish'], 'items_match': [ 'equal', 'status_next', 'pending']}, 'ifaces': ['versioned'] }, { 'title': self.translate(_(u'Withdraw request')), 'description': self.translate( _(u'Change the status of the selected items back to draft.')), 'icon': 'close', 'order': 30, 'action': { 'rest': { 'action': 'withdrawrequest', 'send': 'selected_ids'}}, 'available': { 'content_match': [ 'equal', 'access', 'write'], 'items_match': [ 'equal', 'status_next', 'pending']}, 'ifaces': ['versioned'] }, { 'title': self.translate(_(u'Revoke approval')), 'description': self.translate( _(u'Change the status of the selected items back to draft.')), 'icon': 'cancel', 'order': 40, 'action': { 'rest': { 'action': 'revokeapproval', 'send': 'selected_ids'}}, 'available': { 'content_match': [ 'equal', 'access', 'manage', 'publish'], 'items_match': [ 'equal', 'status_next', 'approved']}, 'ifaces': ['versioned'] }, { 'title': self.translate(_(u'Close')), 'description': self.translate( _(u'Unpublish the selected items.')), 'icon': 'close', 'accesskey': ['ctrl+l'], 'order': 50, 'action': { 'rest': { 'action': 'close', 'send': 'selected_ids'}}, 'available': { 'content_match': [ 'equal', 'access', 'manage', 'publish'], 'items_match': [ 'or', ['provides', 'container'], ['equal', 'status_public', 'published'] ]}, 'ifaces': ['container', 'versioned'] }], 'ifaces': ['object'] }]} ]} return self.json_response(cfg)
def _lookup(self, validator): candidates = [] for iface, factories in self._designs.iteritems(): candidates.extend(filter(validator, factories)) return sort_components(candidates)