Metadata-Version: 1.0
Name: z3c.preference
Version: 0.1.1
Summary: UI for zope.preference using z3c.pagelet and z3c.form.
Home-page: http://pypi.python.org/pypi/z3c.preference
Author: Michael Howitz
Author-email: zope-dev@zope.org
License: ZPL 2.1
Description: This packages provides a user interface for `zope.preference` using
        `z3c.pagelet` and `z3c.form`.
        
        
        .. contents::
        
        ==============
        z3c.preference
        ==============
        
        ``z3c.preference`` renders forms in the browser for the preference
        sets which were defined using zope.preference_.
        
        .. _zope.preference: http://pypi.python.org/pypi/zope.preference
        
        Using z3c.preference
        ====================
        
        There are some preconditions to use `z3c.preference`:
        
        * The views for the ``++preferences++`` namespace are registered for
        the layer ``z3c.preference.interfaces.IPreferenceLayer``. So you
        have to add this interface to the browser layer of your application.
        
        * Only users having the permission ``z3c.preference.EditPreference``
        are allowed to access the the preference views. So you have to add this
        permission to the users resp. roles which should be able to access
        the preferences views.
        
        
        Set up for tests
        ================
        
        At first we have to define a preference interface:
        
        >>> import zope.interface
        >>> import zope.schema
        >>> class IBackEndSettings(zope.interface.Interface):
        ...     """Backend User Preferences"""
        ...
        ...     email = zope.schema.TextLine(
        ...         title=u"E-mail Address",
        ...         description=u"E-mail address used to send notifications")
        ...
        ...     skin = zope.schema.Choice(
        ...         title=u"Skin",
        ...         description=u"The skin that should be used for the back end.",
        ...         values=['Hipp', 'Lame', 'Basic'],
        ...         default='Basic')
        ...
        ...     showLogo = zope.schema.Bool(
        ...         title=u"Show Logo",
        ...         description=u"Specifies whether the logo should be displayed.",
        ...         default=True)
        
        The interface must be registered for preferenes:
        
        >>> from zope.configuration import xmlconfig
        >>> import zope.preference
        >>> context = xmlconfig.file('meta.zcml', zope.preference)
        
        >>> context = xmlconfig.string('''
        ...     <configure
        ...         xmlns="http://namespaces.zope.org/zope"
        ...         i18n_domain="test">
        ...
        ...       <preferenceGroup
        ...           id="BackEndSettings"
        ...           title="Back End Settings"
        ...           schema="z3c.preference.README.IBackEndSettings"
        ...           category="true"
        ...           />
        ...
        ...     </configure>''', context)
        
        
        To access the forms a browser is needed, the user must be autorized as
        the preferences are stored in the principal annotations:
        
        >>> from zope.app.wsgi.testlayer import Browser
        >>> browser = Browser()
        >>> browser.addHeader('Authorization', 'Basic mgr:mgrpw')
        
        
        Editing preferences
        ===================
        
        There is a name space to access the preferences. On the page a form is
        displayed which show the default values:
        
        >>> browser.open('http://localhost/++preferences++/BackEndSettings')
        >>> browser.getControl('E-mail Address').value
        ''
        >>> browser.getControl('Skin').displayValue
        ['Basic']
        >>> browser.getControl('yes').selected
        True
        >>> browser.getControl('no').selected
        False
        
        The values can be changed and submitting the form makes them persistent:
        
        >>> browser.getControl('E-mail Address').value = 'me@example.com'
        >>> browser.getControl('Skin').displayValue = ['Hipp']
        >>> browser.getControl('no').click()
        >>> browser.getControl('Apply').click()
        
        After submitting the form gets displayed again and shown the changed values:
        
        >>> 'Data successfully updated.' in browser.contents
        True
        >>> browser.getControl('E-mail Address').value
        'me@example.com'
        >>> browser.getControl('Skin').displayValue
        ['Hipp']
        >>> browser.getControl('no').selected
        True
        
        
        =======
        To do
        =======
        
        - Add a tree to access preferences deeper in the preference tree.
        
        - Render preference description.
        
        - Document how to use it in own projects. (ZCML and skin)
        
        =======
        Changes
        =======
        
        
        0.1.1 (2010-07-17)
        ==================
        
        - Documented preconditions to use this package, see `Using
        z3c.preference`_.
        
        0.1.0 (2010-07-10)
        ==================
        
        - Initial Release.
        
Keywords: zope3 bluebream z3c preference ui
Platform: UNKNOWN
Classifier: Development Status :: 3 - Alpha
Classifier: Environment :: Web Environment
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved
Classifier: License :: OSI Approved :: Zope Public License
Classifier: Programming Language :: Python
Classifier: Natural Language :: English
Classifier: Operating System :: OS Independent
Classifier: Topic :: Internet :: WWW/HTTP
Classifier: Framework :: Zope3
