Commit 00737f9e authored by Jim Fulton's avatar Jim Fulton

Added some doc strings.

Converted some comments to doc strings.
Got rid of some no=longer-used code.
parent 428b3d3a
...@@ -84,7 +84,7 @@ ...@@ -84,7 +84,7 @@
############################################################################## ##############################################################################
"""Property sheets""" """Property sheets"""
__version__='$Revision: 1.54 $'[11:-2] __version__='$Revision: 1.55 $'[11:-2]
import time, string, App.Management, Globals import time, string, App.Management, Globals
from ZPublisher.Converters import type_converters from ZPublisher.Converters import type_converters
...@@ -100,6 +100,9 @@ from Traversable import Traversable ...@@ -100,6 +100,9 @@ from Traversable import Traversable
class View(App.Management.Tabs, Base): class View(App.Management.Tabs, Base):
"""A view of an object, typically used for management purposes """A view of an object, typically used for management purposes
This class provides bits of management framework needed by propertysheets
to be used as a view on an object.
""" """
def manage_workspace(self, URL1, RESPONSE): def manage_workspace(self, URL1, RESPONSE):
...@@ -174,7 +177,10 @@ class PropertySheet(Traversable, Persistent, Implicit): ...@@ -174,7 +177,10 @@ class PropertySheet(Traversable, Persistent, Implicit):
), ),
) )
def property_extensible_schema__(self): return self._extensible def property_extensible_schema__(self):
"""Return a flag indicating whether new properties may be
added or removed."""
return self._extensible
def __init__(self, id, md=None): def __init__(self, id, md=None):
# Create a new property set, using the given id and namespace # Create a new property set, using the given id and namespace
...@@ -195,10 +201,11 @@ class PropertySheet(Traversable, Persistent, Implicit): ...@@ -195,10 +201,11 @@ class PropertySheet(Traversable, Persistent, Implicit):
return self.v_self() return self.v_self()
def valid_property_id(self, id): def valid_property_id(self, id):
# Return a true value if the given id is valid to use as """Is the given id valid to use as a property id
# a property id. Note that this method does not consider
# factors other than the actual value of the id, such as Note that this method does not consider
# whether the given id is already in use. factors other than the actual value of the id, such as
whether the given id is already in use."""
if not id or (id[:1]=='_') or (' ' in id): if not id or (id[:1]=='_') or (' ' in id):
return 0 return 0
return 1 return 1
...@@ -221,7 +228,6 @@ class PropertySheet(Traversable, Persistent, Implicit): ...@@ -221,7 +228,6 @@ class PropertySheet(Traversable, Persistent, Implicit):
"""Get the type of property 'id', returning None if no """Get the type of property 'id', returning None if no
such property exists""" such property exists"""
pself=self.p_self() pself=self.p_self()
self=self.v_self()
for md in pself._properties: for md in pself._properties:
if md['id']==id: if md['id']==id:
return md.get('type', 'string') return md.get('type', 'string')
...@@ -493,6 +499,7 @@ Globals.default__class_init__(PropertySheet) ...@@ -493,6 +499,7 @@ Globals.default__class_init__(PropertySheet)
class Virtual: class Virtual:
"""A virtual propertysheet stores it's properties in it's instance."""
def __init__(self): def __init__(self):
pass pass
...@@ -500,7 +507,6 @@ class Virtual: ...@@ -500,7 +507,6 @@ class Virtual:
def v_self(self): def v_self(self):
return self.aq_parent.aq_parent return self.aq_parent.aq_parent
class DefaultProperties(Virtual, PropertySheet, View): class DefaultProperties(Virtual, PropertySheet, View):
"""The default property set mimics the behavior of old-style Zope """The default property set mimics the behavior of old-style Zope
properties -- it stores its property values in the instance of properties -- it stores its property values in the instance of
...@@ -600,7 +606,6 @@ class PropertySheets(Traversable, Implicit, App.Management.Tabs): ...@@ -600,7 +606,6 @@ class PropertySheets(Traversable, Implicit, App.Management.Tabs):
id='propertysheets' id='propertysheets'
__ac_permissions__=( __ac_permissions__=(
('Manage properties', ('manage_addPropertySheet', ('Manage properties', ('manage_addPropertySheet',
'addPropertySheet', 'addPropertySheet',
...@@ -670,10 +675,6 @@ class PropertySheets(Traversable, Implicit, App.Management.Tabs): ...@@ -670,10 +675,6 @@ class PropertySheets(Traversable, Implicit, App.Management.Tabs):
if propset.id != name and propset.xml_namespace() != name: if propset.id != name and propset.xml_namespace() != name:
result.append(propset) result.append(propset)
self.parent.__propsets__=tuple(result) self.parent.__propsets__=tuple(result)
# Why?
#def __del__(self):
# self.parent=None
def __len__(self): def __len__(self):
return len(self.__propsets__()) return len(self.__propsets__())
...@@ -725,6 +726,15 @@ Globals.default__class_init__(DefaultPropertySheets) ...@@ -725,6 +726,15 @@ Globals.default__class_init__(DefaultPropertySheets)
class FixedSchema(PropertySheet): class FixedSchema(PropertySheet):
"""A Fixed-schema property sheet has no control over it's schema
It gets its schema from another proprtysheet but has control over
its value storage.
This mix-in is used for ZClass instance proprtysheets, which store
their data in instances, but get their schema from the
proprtysheet managed in the ZClass.
"""
def __init__(self, id, base, md=None): def __init__(self, id, base, md=None):
FixedSchema.inheritedAttribute('__init__')(self, id, md) FixedSchema.inheritedAttribute('__init__')(self, id, md)
...@@ -751,9 +761,12 @@ class FixedSchema(PropertySheet): ...@@ -751,9 +761,12 @@ class FixedSchema(PropertySheet):
class vps(Base): class vps(Base):
# The vps object implements a "computed attribute" - it ensures """Virtual Propertysheets
# that a PropertySheets instance is returned when the propertysheets
# attribute of a PropertyManager is accessed. The vps object implements a "computed attribute" - it ensures
that a PropertySheets instance is returned when the propertysheets
attribute of a PropertyManager is accessed.
"""
def __init__(self, c=PropertySheets): def __init__(self, c=PropertySheets):
self.c=c self.c=c
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment