Back to index

plone3  3.1.7
metadirectives.py
Go to the documentation of this file.
00001 from zope.interface import Interface
00002 
00003 from zope import schema
00004 from zope.configuration import fields as configuration_fields
00005 
00006 from zope.publisher.interfaces.browser import IDefaultBrowserLayer, IBrowserView
00007 from plone.portlets.interfaces import IPortletManager
00008 
00009 from Products.CMFPlone import PloneMessageFactory as _
00010 
00011 class IPortletDirective(Interface):
00012     """Directive which registers a new portlet type.
00013     
00014     The portlet should also be installed into a site using a GenericSetup
00015     portlets.xml file, for example.
00016     """
00017     
00018     name = schema.TextLine(
00019         title=_(u"Name"),
00020         description=_(u"A unique name for the portlet. Also used for its add view."),
00021         required=True)                    
00022                            
00023     interface = configuration_fields.GlobalInterface(
00024         title=_(u"Assignment type interface"),
00025         description=_(u"Should correspond to the public interface of the assignment"),
00026         required=True)
00027     
00028     assignment = configuration_fields.GlobalObject(
00029         title=_(u"Assignment class"),
00030         description=_(u"A persistent class storing the portlet assignment"),
00031         required=True)
00032 
00033     view_permission = schema.TextLine(
00034         title=_(u"View permission"),
00035         description=_(u"Permission used for viewing the portlet."),
00036         required=False,
00037         default=u"zope2.View"
00038         )
00039     
00040     edit_permission = schema.TextLine(
00041         title=_(u"Edit permission"),
00042         description=_(u"Permission used for editing the portlet assignment."),
00043         required=False,
00044         default=u"cmf.ManagePortal"
00045         )
00046         
00047     renderer = configuration_fields.GlobalObject(
00048         title=_(u"Renderer"),
00049         description=_(u"A class which renders the portlet data provider"),
00050         required=True
00051         )
00052     
00053     addview = configuration_fields.GlobalObject(
00054         title=_(u"Add view"),
00055         description=_(u"View used to add the assignment object"),
00056         required=True
00057         )
00058     
00059     editview = configuration_fields.GlobalObject(
00060         title=_(u"Edit view"),
00061         description=_(u"View used to edit the assignment object (if appropriate)"),
00062         required=False
00063         )
00064         
00065 class IPortletRendererDirective(Interface):
00066     """Register a portlet renderer, i.e. a different view of a portlet
00067     """
00068     
00069     # The portlet data provider type must be given
00070     
00071     portlet = configuration_fields.GlobalObject(
00072         title=_("Portlet data provider type for which this renderer is used"),
00073         description=_("An interface or class"),
00074         required=True)
00075         
00076     # Use either class or template to specify the custom renderer
00077 
00078     class_ = configuration_fields.GlobalObject(
00079         title=_("Class"),
00080         description=_("A class acting as the renderer."),
00081         required=False,
00082         )
00083         
00084     template = configuration_fields.Path(
00085         title=_(u"The name of a template that implements the renderer."),
00086         description=_(u"If given, the default renderer for this portlet will be used, but with this template"),
00087         required=False
00088         )
00089     
00090     # Use these to discriminate the renderer.
00091     
00092     for_ = configuration_fields.GlobalObject(
00093         title=_("Context object type for which this renderer is used"),
00094         description=_("""An interface or class"""),
00095         required=False,
00096         default=Interface,
00097         )
00098         
00099     layer = configuration_fields.GlobalObject(
00100         title=_("Browser layer for which this renderer is used"),
00101         description=_("""An interface or class"""),
00102         required=False,
00103         default=IDefaultBrowserLayer,
00104         )
00105         
00106     view = configuration_fields.GlobalObject(
00107         title=_("Browser view type for this this renderer is used"),
00108         description=_("An interface or class"),
00109         required=False,
00110         default=IBrowserView)
00111         
00112     manager = configuration_fields.GlobalObject(
00113         title=_("Portlet manager type for which this renderer is used"),
00114         description=_("An interface or class"),
00115         required=False,
00116         default=IPortletManager)