Esempio n. 1
0
def AddViewFactory(name,
                   schema,
                   label,
                   permission,
                   layer,
                   template,
                   default_template,
                   bases,
                   for_,
                   fields,
                   content_factory,
                   arguments,
                   keyword_arguments,
                   set_before_add,
                   set_after_add,
                   menu=u''):

    s = getGlobalService(Presentation)
    class_ = makeClassForTemplate(template, used_for=schema, bases=bases)

    class_.schema = schema
    class_.label = label
    class_.fieldNames = fields
    class_._factory = content_factory
    class_._arguments = arguments
    class_._keyword_arguments = keyword_arguments
    class_._set_before_add = set_before_add
    class_._set_after_add = set_after_add

    class_.generated_form = ZopeTwoPageTemplateFile(default_template)

    s.provideView(for_, name, IBrowserRequest, class_, layer)
    protectClass(class_, permission)
    initializeClass(class_)
Esempio n. 2
0
    def __call__(self):
        (_context, name, for_, permission, layer, class_,
         allowed_interface, allowed_attributes) = self.args

        required = {}

        cdict = {}
        pages = {}

        for pname, attribute, template in self.pages:
            try:
                s = getGlobalService(Presentation)
            except ComponentLookupError, err:
                pass

            if template:
                cdict[pname] = ZopeTwoPageTemplateFile(template)
                if attribute and attribute != name:
                    cdict[attribute] = cdict[pname]
            else:
                if not hasattr(class_, attribute):
                    raise ConfigurationError("Undefined attribute",
                                             attribute)

            attribute = attribute or pname
            required[pname] = permission

            pages[pname] = attribute
Esempio n. 3
0
def EditViewFactory(name,
                    schema,
                    label,
                    permission,
                    layer,
                    template,
                    default_template,
                    bases,
                    for_,
                    fields,
                    fulledit_path=None,
                    fulledit_label=None,
                    menu=u''):
    s = getGlobalService(Presentation)
    class_ = makeClassForTemplate(template, used_for=schema, bases=bases)
    class_.schema = schema
    class_.label = label
    class_.fieldNames = fields

    class_.fulledit_path = fulledit_path
    if fulledit_path and (fulledit_label is None):
        fulledit_label = "Full edit"

    class_.fulledit_label = fulledit_label

    class_.generated_form = ZopeTwoPageTemplateFile(default_template)

    s.provideView(for_, name, IBrowserRequest, class_, layer)
    protectClass(class_, permission)
    initializeClass(class_)
Esempio n. 4
0
def makeClassForTemplate(src, template=None, used_for=None,
                         bases=(), cdict=None):
    # XXX needs to deal with security from the bases?
    if cdict is None:
        cdict = {}
    cdict.update({'index': ZopeTwoPageTemplateFile(src, template)})
    bases += (ViewMixinForTemplates,)
    class_ = makeClass("SimpleViewClass from %s" % src, bases, cdict)

    if used_for is not None:
        class_.__used_for__ = used_for

    return class_