[Zope3-checkins]
SVN: Zope3/branches/roger-contentprovider/src/zope/portlet/statehandler.
statehandler work in progress
Helmut Merz
helmutm at cy55.de
Sat Oct 8 17:42:07 EDT 2005
Log message for revision 38979:
statehandler work in progress
Changed:
U Zope3/branches/roger-contentprovider/src/zope/portlet/statehandler.py
U Zope3/branches/roger-contentprovider/src/zope/portlet/statehandler.txt
-=-
Modified: Zope3/branches/roger-contentprovider/src/zope/portlet/statehandler.py
===================================================================
--- Zope3/branches/roger-contentprovider/src/zope/portlet/statehandler.py 2005-10-08 21:41:03 UTC (rev 38978)
+++ Zope3/branches/roger-contentprovider/src/zope/portlet/statehandler.py 2005-10-08 21:42:07 UTC (rev 38979)
@@ -23,16 +23,16 @@
-class PreferenceStateHandler(object):
+class PreferencesStateHandler(object):
"""State handler based on preferences."""
- implements(interfaces.IStateHandler)
+ zope.interface.implements(interfaces.IStateHandler)
def __init__(self, context):
self.context = context
self.preferences = None
- def setState(self, name, value):
+ def setState(self, value, name):
"""xxx"""
# self.preferences.portletmanager.%s.state = %s % (portletname, name)
Modified: Zope3/branches/roger-contentprovider/src/zope/portlet/statehandler.txt
===================================================================
--- Zope3/branches/roger-contentprovider/src/zope/portlet/statehandler.txt 2005-10-08 21:41:03 UTC (rev 38978)
+++ Zope3/branches/roger-contentprovider/src/zope/portlet/statehandler.txt 2005-10-08 21:42:07 UTC (rev 38979)
@@ -14,9 +14,9 @@
>>> from zope.app.testing import ztapi
>>> from zope.app import zapi
- >>> from zope.interface import implements
- >>> from zope.interface import providedBy
-
+ >>> from zope.interface import implements, directlyProvides
+
+ >>> from zope.contentprovider.interfaces import IContentProviderType
>>> from zope.portlet.interfaces import IStateHandler
>>> from zope.portlet.interfaces import IPortlet
@@ -31,12 +31,12 @@
... self.states = {}
...
... def setState(self, state, name):
- ... cpType = list(providedBy(self.context))[0]
+ ... cpType = zapi.queryType(self.context, IContentProviderType)
... cpTypeName = cpType.__module__ + '.' + cpType.__name__
... self.states[cpTypeName + '/' + name] = state
...
... def getState(self, name):
- ... cpType = list(providedBy(self.context))[0]
+ ... cpType = zapi.queryType(self.context, IContentProviderType)
... cpTypeName = cpType.__module__ + '.' + cpType.__name__
... return self.states[cpTypeName + '/' + name]
@@ -51,6 +51,11 @@
>>> class ISpecialPortlet(IPortlet):
... pass
+Our content provider must be of IContentProviderType so it can recognized
+during adapter lookup:
+
+ >>> directlyProvides(ISpecialPortlet, IContentProviderType)
+
>>> class Portlet(object):
... implements(ISpecialPortlet)
@@ -67,4 +72,11 @@
>>> handler.getState(name='dummy.portlet')
'visible'
-
\ No newline at end of file
+
+Use preferences for portlat state storage
+-----------------------------------------
+
+ >>> from zope.portlet.statehandler import PreferencesStateHandler
+ >>> ztapi.provideAdapter(IPortlet, IStateHandler, PreferencesStateHandler)
+
+
More information about the Zope3-Checkins
mailing list