[Zope3-checkins] CVS: Zope3/src/zope/app/apidoc/viewmodule -
__init__.py:1.2
Stephan Richter
srichter at cosmos.phy.tufts.edu
Sun Mar 28 18:41:40 EST 2004
Update of /cvs-repository/Zope3/src/zope/app/apidoc/viewmodule
In directory cvs.zope.org:/tmp/cvs-serv23176/src/zope/app/apidoc/viewmodule
Modified Files:
__init__.py
Log Message:
Added tests.
Remove usage support. Usage has evaporated into a black hole.
=== Zope3/src/zope/app/apidoc/viewmodule/__init__.py 1.1 => 1.2 ===
--- Zope3/src/zope/app/apidoc/viewmodule/__init__.py:1.1 Thu Feb 19 15:46:43 2004
+++ Zope3/src/zope/app/apidoc/viewmodule/__init__.py Sun Mar 28 18:41:39 2004
@@ -19,9 +19,7 @@
from zope.interface import implements
from zope.app.apidoc.interfaces import IDocumentationModule
-__metaclass__ = type
-
-class ViewModule:
+class ViewModule(object):
"""Represent the Documentation of all Views."""
implements(IDocumentationModule)
@@ -55,26 +53,70 @@
"""
def getSkins(self):
- """Get the names of all available skins."""
- service = zapi.getService(self, 'Presentation')
+ """Get the names of all available skins.
+
+ Examples::
+
+ >>> module = ViewModule()
+ >>> skins = module.getSkins()
+ >>> skins.sort()
+ >>> skins
+ ['default', 'skinA', 'skinB', 'skinC']
+
+ >>> pres = zapi.getService(None, 'Presentation')
+ >>> pres.defineSkin('skinD', ['layer3'])
+ >>> skins = module.getSkins()
+ >>> skins.sort()
+ >>> skins
+ ['default', 'skinA', 'skinB', 'skinC', 'skinD']
+ """
+ # Only the global presentation service defines skins
+ service = zapi.getService(None, 'Presentation')
return service.skins.keys()
def getLayersForSkin(self, skin):
"""Get the names of all available layers of a particular skin.
Returns a 'KeyError', if the skin does not exist.
+
+ Examples::
+
+ >>> module = ViewModule()
+ >>> module.getLayersForSkin('default')
+ ('default',)
+ >>> module.getLayersForSkin('skinA')
+ ('default',)
+ >>> module.getLayersForSkin('skinB')
+ ('layer5', 'layer4', 'default')
+ >>> module.getLayersForSkin('skinC')
+ ('layer4', 'layer2', 'layer1', 'default')
+ >>> module.getLayersForSkin('skinD')
+ Traceback (most recent call last):
+ ...
+ KeyError: 'skinD'
"""
- service = zapi.getService(self, 'Presentation')
+ # Only the global presentation service defines skins
+ service = zapi.getService(None, 'Presentation')
return service.skins[skin]
def getSkinLayerMapping(self):
"""Return a dictionary with keys being skin names and the value are
- tuples of layer names."""
- service = zapi.getService(self, 'Presentation')
- return service.skins
+ tuples of layer names.
+
+ Example::
- def getUsages(self):
- """Return a list of all available usages."""
- service = zapi.getService(self, 'Presentation')
- return service._usages.keys()
+ >>> import pprint
+ >>> pprint = pprint.PrettyPrinter(width=69).pprint
+ >>> module = ViewModule()
+ >>> map = module.getSkinLayerMapping().items()
+ >>> map.sort()
+ >>> pprint(map)
+ [('default', ('default',)),
+ ('skinA', ('default',)),
+ ('skinB', ('layer5', 'layer4', 'default')),
+ ('skinC', ('layer4', 'layer2', 'layer1', 'default'))]
+ """
+ # Only the global presentation service defines skins
+ service = zapi.getService(None, 'Presentation')
+ return service.skins
More information about the Zope3-Checkins
mailing list