PlonePAS and MutablePropertySheet

Miles miles at jamkit.com
Tue Jun 12 09:59:02 UTC 2007


Hi,

I'm working on incorporating some additions to the SQLPASPlugin that 
we're using here, which allow it to work with plain PAS, and also 
provide generic setup support etc...

There's one item that is preventing this from working "as planned": the 
way the PropertyProvider plugin returns a property sheet rather than 
just a dict of data (plain PAS explicitly requires the plugin to return 
a dict).

I think this can be avoided if the sheet type is determined in the 
userfactory plugin (PlonePAS/plugins/ufactory.py) rather than directly 
in the plugin.  The following (untested) is the simplest change I can 
see that would preserve BBB whilst allowing the original PAS interface 
to be obeyed:

     def addPropertysheet(self, id, data):
         """ -> add a prop sheet, given data which is either
         a property sheet or a raw mapping.
         """
X       plugin = getattr( self.acl_users, id )

         if IPropertySheet.providedBy(data):
             sheet = data
X       elif IMutablePropertiesManager.providedBy(plugin):
X           isGroup = getattr(user, 'isGroup', lambda: None)()
X           schema = None
X           if hasattr(plugin, '_getSchema'):
X              schema = plugin._getSchema(isGroup)
X           if not schema:
X              schema = None
X           sheet = MutablePropertySheet(id, schema, **data)
         else:
             sheet = UserPropertySheet(id, **data)

         if self._propertysheets.get(id) is not None:
             raise KeyError, 'Duplicate property sheet: %s' % id

         self._propertysheets[id] = sheet

Does this seem like a reasonable change?  I'd like to get some comments 
from anyone who knows more about PAS plugins than me, before I devote 
additional time to it.

Thanks,

Miles






More information about the Product-Developers mailing list