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''): class_ = makeClassForTemplate(template, globals(), 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) if layer is None: layer = IDefaultBrowserLayer s = zapi.getGlobalSiteManager() s.provideAdapter((for_, layer), Interface, name, class_) # Reminder: the permission we got has already been processed by # BaseFormDirective, that means that zope.Public has been # translated to the CheckerPublic object protectClass(class_, permission) initializeClass(class_)
def EditViewFactory(name, schema, label, permission, layer, template, default_template, bases, for_, fields, fulledit_path=None, fulledit_label=None, menu=u''): class_ = makeClassForTemplate(template, globals(), 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) if layer is None: layer = IDefaultBrowserLayer s = zapi.getGlobalSiteManager() s.provideAdapter((for_, layer), Interface, name, class_) # Reminder: the permission we got has already been processed by # BaseFormDirective, that means that zope.Public has been # translated to the CheckerPublic object protectClass(class_, permission) initializeClass(class_)
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''): class_ = makeClassForTemplate(template, globals(), 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) if layer is None: layer = IDefaultBrowserLayer s = zope.component.getGlobalSiteManager() s.registerAdapter(class_, (for_, layer), Interface, name) # Reminder: the permission we got has already been processed by # BaseFormDirective, that means that zope.Public has been # translated to the CheckerPublic object protectClass(class_, permission) initializeClass(class_)
def EditViewFactory(name, schema, label, permission, layer, template, default_template, bases, for_, fields, fulledit_path=None, fulledit_label=None, menu=u''): class_ = makeClassForTemplate(template, globals(), 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) if layer is None: layer = IDefaultBrowserLayer s = zope.component.getGlobalSiteManager() s.registerAdapter(class_, (for_, layer), Interface, name) # Reminder: the permission we got has already been processed by # BaseFormDirective, that means that zope.Public has been # translated to the CheckerPublic object protectClass(class_, permission) initializeClass(class_)
def execute(self, class_, config, schema, name, require, **kw): formfields = form.FormFields(*schema) for formfield in formfields: fname = formfield.__name__ if not hasattr(class_, fname): setattr(class_, fname, FieldProperty(formfield.field)) for iface in schema: if not iface.providedBy(class_): classImplements(class_, iface) class_.meta_type = class_.portal_type = name initializeClass(class_) registerClass(config, class_, name, require) return True
""" import os.path import Acquisition import zope.app.form.browser.objectwidget from AccessControl import ClassSecurityInfo from Globals import InitializeClass as initializeClass from Products.Five.browser.pagetemplatefile import ZopeTwoPageTemplateFile class ObjectWidgetView(Acquisition.Explicit, zope.app.form.browser.objectwidget.ObjectWidgetView): security = ClassSecurityInfo() security.declareObjectPublic() template = ZopeTwoPageTemplateFile('objectwidget.pt') initializeClass(ObjectWidgetView) class ObjectWidgetClass(Acquisition.Explicit, zope.app.form.browser.objectwidget.ObjectWidget): def __init__(self, context, request, factory, **kw): super(ObjectWidgetClass, self).__init__(context, request, factory, **kw) self.view = ObjectWidgetView(self, request) def setRenderedValue(self, value): """Slightly more robust re-implementation this method.""" # re-call setupwidgets with the content self._setUpEditWidgets() for name in self.names: val = getattr(value, name, None) if val is None: