self.path = None form = self.get_smi_form() if form is not None: self.path = form.get_content_path(self._content) class ObjectFieldWidget(ObjectFieldWidget): grok.adapts(ObjectField, Interface, Interface) class DisplayObjectFieldWidget(ObjectFieldWidget): grok.name(unicode(DISPLAY)) grok.global_adapter( newCollectionWidgetFactory(mode='lines'), adapts=(ICollectionField, Interface, Interface), provides=IWidget, name='lines') grok.global_adapter( newCollectionWidgetFactory(mode='multipickup'), adapts=(ICollectionField, Interface, Interface), provides=IWidget, name='multipickup') grok.global_adapter( newCollectionWidgetFactory(mode='lines', interface=IWidgetExtractor), adapts=(ICollectionField, Interface, Interface), provides=IWidgetExtractor, name='lines')
class Resources(grok.DirectoryResource): grok.path('resources') grok.name('zeam.form.plone.resources') class PloneFieldWidget(FieldWidget, Acquisition.Explicit): grok.baseclass() @property def context(self): # Plone Zope 2 template need a context. return self.form.context class PloneWYSIWYGFieldWidget(PloneFieldWidget): grok.adapts(TextSchemaField, Interface, Interface) grok.name('plone.wysiwyg') grok.global_adapter( newCollectionWidgetFactory(mode='plone.multi-select'), adapts=(ICollectionSchemaField, Interface, Interface), provides=IWidget, name='plone.multi-select') class PloneMultiSelectFieldWidget(MultiChoiceFieldWidget, PloneFieldWidget): grok.adapts(CollectionSchemaField, ChoiceSchemaField, Interface, Interface) grok.name('plone.multi-select')
class PloneFieldWidget(FieldWidget, Acquisition.Explicit): grok.baseclass() @property def context(self): # Plone Zope 2 template need a context. return self.form.context class PloneWYSIWYGFieldWidget(PloneFieldWidget): grok.adapts(TextField, Interface, Interface) grok.name('plone.wysiwyg') grok.global_adapter(newCollectionWidgetFactory(mode='plone.multi-select'), adapts=(ICollectionField, Interface, Interface), provides=IWidget, name='plone.multi-select') class PloneMultiSelectFieldWidget(MultiChoiceFieldWidget, PloneFieldWidget): grok.adapts(CollectionField, ChoiceField, Interface, Interface) grok.name('plone.multi-select') # Plone 4 includes the resources by default # Plone 5 doesn't, so we have to inject them in the request. # This doesn't alter Plone 4 behavior. RESOURCES = (
def context(self): # Plone Zope 2 template need a context. return self.form.context class PloneMultiSelectFieldWidget(MultiChoiceFieldWidget, PloneFieldWidget): grok.adapts(CollectionField, ChoiceField, Interface, Interface) grok.name('INOUT') def __init__(self, field, value_field, form, request): super(PloneMultiSelectFieldWidget, self).__init__(field, value_field, form, request) add_resource_on_request(request, 'inout') grok.global_adapter(newCollectionWidgetFactory(mode='INOUT'), adapts=(ICollectionField, Interface, Interface), provides=IWidget, name='INOUT') class PloneSelectizeFieldWidget(MultiChoiceFieldWidget, PloneFieldWidget): grok.adapts(CollectionField, ChoiceField, Interface, Interface) grok.name('selectize') def __init__(self, field, value_field, form, request): super(PloneSelectizeFieldWidget, self).__init__(field, value_field, form, request) add_resource_on_request(request, 'selectize')
MODE = 'display_shorturl' grok.adapts(TextLineField, Interface, Interface) grok.name(MODE) def update(self): super(DisplayShortURLWidget, self).update() need(IDisplayShortURLResources) def inputValue(self): value = super(DisplayShortURLWidget, self).inputValue() if value: return self.base_url.rstrip('/') + '/' + value return value grok.global_adapter( newCollectionWidgetFactory(mode='display_shorturl'), adapts=(SetField, Interface, Interface), provides=IWidget, name='display_shorturl') class SetFieldWidget(MultiGenericDisplayFieldWidget): grok.adapts(SetField, Interface, Interface, Interface) grok.name('display_shorturl') class CustomPathWidget(ShortURLWidget): MODE = 'custom_path' grok.adapts(TextLineField, Interface, Interface) grok.name(MODE)