コード例 #1
0
ファイル: view.py プロジェクト: Zojax/zojax.ui.cssregistry
    def update(self):
        request = self.request

        if 'form.copy' in request:
            reg = request.get('registry', None)

            registry = self.listRegistries()[int(reg)]['registry']

            for prop, value in registry.items():
                self.context[prop] = CSSProperty(
                    value.name, value.value,
                    value.title, value.description, value.type)

            event.notify(ObjectModifiedEvent(self.context))

            IStatusMessage(request).add(
                _(u"CSS Registry has been copied."))

        if 'form.add' in request:
            name = request.get('form.add.name', '').strip()
            if not name:
                IStatusMessage(request).add(
                    _(u"Can't add property with emtpy name."), 'error')
            else:
                self.context[name] = CSSProperty(
                    name, request.get('form.add.value', ''))

                event.notify(ObjectModifiedEvent(self.context))

        if 'form.remove' in request:
            for prop in request.get('property', ()):
                del self.context[prop]
            event.notify(ObjectModifiedEvent(self.context))
            IStatusMessage(request).add(_(u"Properties have been removed."))

        if 'form.save' in request:
            for key, value in request.form.items():
                if key.startswith('prop-'):
                    key = key[5:]
                    old = self.context[key]
                    property = CSSProperty(
                        old.name, value,
                        old.title, old.description, old.type)

                    self.context[key] = property

            if request.get('form.enabled') == 'yes':
                self.context.enabled = True
            else:
                self.context.enabled = False

            event.notify(ObjectModifiedEvent(self.context))
            IStatusMessage(request).add(_(u"Properties have been changed."))
コード例 #2
0
ファイル: view.py プロジェクト: Zojax/zojax.ui.cssregistry
    def listRegistries(self):
        regs = []
        for key, registry in registries.items():
            name, layer = key

            regs.append({'name': name or _('Without name'),
                         'layer': '%s.%s'%(layer.__module__, layer.__name__),
                         'registry': registry})

        return regs