Ejemplo n.º 1
0
    def publishTraverse(self, request, name):
        if self.slot is None:
            slot_id = urllib.unquote(name)
            design = self.context.get_design()
            if slot_id not in design.slots:
                raise NotFound('Unknown slot %s' % slot_id)
            self.slot = design.slots[slot_id]
            self.slot_id = slot_id
            self.__name__ = '/'.join((self.__name__, name))
            return self

        if self.slot is not None:
            service = getUtility(IBlockGroupLookup)
            configuration = service.lookup_block_by_name(self, name)
            if configuration is not None:
                restrictions = self.slot.get_new_restrictions(configuration)
                adder = queryRESTComponent(
                    (implementedBy(configuration.block), self.context),
                    (self.context, request, configuration, restrictions),
                    name='add',
                    parent=self,
                    id=name)
                if adder is not None:
                    return adder
        return super(AddBlock, self).publishTraverse(request, name)
Ejemplo n.º 2
0
 def publishBlock(self, name, request):
     restrictions = self.slot.get_existing_restrictions(self.block)
     return queryRESTComponent(
         (self.block, self.context),
         (self.block, self.context, request, self.block_controller, restrictions),
         name='edit',
         parent=self,
         id=name)