-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Christian Klinger wrote:

> i try to add Properties to all of my PAS-Users.
> The Properties should be the adresse information
> of my Users, which i get about an WebService.
> 
> Now i have developed a very simple example of a
> IPropertiesPlugin:
> 
> 
>      security.declarePrivate('getPropertiesForUser')
>      def getPropertiesForUser(self, user, request=None):
>          """ Fullfill PropertiesPlugin requirements """
>          ### Cache Implementation
>          view_name = createViewName('retrievePropsData', user)
>          keywords = {'key' : user}
>          properties = self.ZCacheable_get( view_name = view_name,
>                                             keywords = keywords,
>                                             default = None )
>          if properties is None:
>              properties = {}
>              properties['addr'] = "SampleData"
>              tt=self.ZCacheable_set( properties ,
>                                        view_name=view_name,
>                                        keywords=keywords )
>          return properties
> 
> Now i have some questions about it:
> 
> Shoud I use (and why) the UserPropertySheet instead of a simple dict?

An IPropertiesPlugin is supposed to return a mapping (a dict should be
fine).  The PAS then calls the PropertiedUser's 'addPropertysheet'
method, passing the mapping.  The user object then converts the mapping
to a UserPropertySheet, and stores is in its own namespace.

> Is the cache implementation ok?

By eye, it looks fine.  I'm assuming that your real plugin would be
doing something expensive in the case of a cache miss.

> Does anyone have a simple example for this task?

I don't know if it is simple, but the LDAPMultiPlugins product is
certainly one which uses caching in the way you are investigating:

  http://www.dataflake.org/software/ldapmultiplugins


http://svn.dataflake.org/LDAPMultiPlugins/tags/1.5/LDAPMultiPlugin.py?view=markup


Tres.
- --
===================================================================
Tres Seaver          +1 540-429-0999          [EMAIL PROTECTED]
Palladion Software   "Excellence by Design"    http://palladion.com
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.2.2 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFGABgv+gerLs4ltQ4RAmVgAJwM9xgkgFZVdtXe3np1cSxg67xrugCaAmw5
gvTk5NH64meckbjlmIGIU50=
=greX
-----END PGP SIGNATURE-----

_______________________________________________
Zope-PAS mailing list
Zope-PAS@zope.org
http://mail.zope.org/mailman/listinfo/zope-pas

Reply via email to