Back to index

plone3  3.1.7
components.py
Go to the documentation of this file.
00001 ##############################################################################
00002 #
00003 # Copyright (c) 2007 Zope Corporation and Contributors. All Rights Reserved.
00004 #
00005 # This software is subject to the provisions of the Zope Public License,
00006 # Version 2.1 (ZPL).  A copy of the ZPL should accompany this distribution.
00007 # THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
00008 # WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
00009 # WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
00010 # FOR A PARTICULAR PURPOSE.
00011 #
00012 ##############################################################################
00013 """Components setup view.
00014 
00015 $Id: components.py 78546 2007-08-02 18:07:51Z yuppie $
00016 """
00017 
00018 from Products.Five.browser.pagetemplatefile import ViewPageTemplateFile
00019 from Products.Five.component.interfaces import IObjectManagerSite
00020 from Products.Five.formlib.formbase import PageEditForm
00021 from zope.component import adapts
00022 from zope.component import getMultiAdapter
00023 from zope.formlib import form
00024 from zope.interface import implements
00025 from zope.interface import Interface
00026 from zope.schema import Text
00027 
00028 from Products.GenericSetup.context import SetupEnviron
00029 from Products.GenericSetup.interfaces import IBody
00030 
00031 
00032 class IComponentsSetupSchema(Interface):
00033 
00034     """Schema for components setup views.
00035     """
00036 
00037     body = Text(
00038         title=u'Settings')
00039 
00040 
00041 class ComponentsSetupSchemaAdapter(object):
00042 
00043     adapts(IObjectManagerSite)
00044     implements(IComponentsSetupSchema)
00045 
00046     def __init__(self, context):
00047         self.context = context
00048 
00049     def _getBody(self):
00050         sm = self.context.aq_inner.getSiteManager()
00051         return getMultiAdapter((sm, SetupEnviron()), IBody).body
00052 
00053     def _setBody(self, value):
00054         sm = self.context.aq_inner.getSiteManager()
00055         getMultiAdapter((sm, SetupEnviron()), IBody).body = value
00056 
00057     body = property(_getBody, _setBody)
00058 
00059 
00060 class ComponentsSetupView(PageEditForm):
00061 
00062     """Components setup view for IObjectManagerSite.
00063     """
00064 
00065     label = u'Component Registry: XML Configuration'
00066 
00067     form_fields = form.FormFields(IComponentsSetupSchema)
00068 
00069     def setUpWidgets(self, ignore_request=False):
00070         super(ComponentsSetupView,
00071               self).setUpWidgets(ignore_request=ignore_request)
00072         self.widgets['body'].height = 24
00073 
00074 
00075 class ComponentsSetupTab(ComponentsSetupView):
00076 
00077     """Components setup ZMI tab for IObjectManagerSite.
00078     """
00079 
00080     base_template = PageEditForm.template
00081 
00082     template = ViewPageTemplateFile('components.pt')
00083 
00084     label = None