[Product-Developers] Re: storing site-wide global persistent data

Jordan Baker jbb at scryent.com
Tue Jun 3 15:03:58 UTC 2008


To answer my own question, I looked at Martin's book and noticed that 
the approach there is to register a local utility implementing the 
interface which is inherently persistent by the virtue of being local.

This seems cleaner than attaching data to the Portal Root which then 
needs to be manually cleaned up if you uninstall your product for 
example.

On 2008-06-03 10:54:05 -0400, Jordan Baker 
<jbb at scryent.com> said:

> In the older days you just added a property to the site portal, or 
> added an object under portal_properties.
> 
> I've noticed that plone.app.controlpanel uses views to adapt the portal 
> root for control panel purposes and adapts the portal root to these 
> property settings.
> 
> If I want to setup global settings for my own application would this 
> pattern also make sense? Or should I do something else.
> 
> Using annotation on the Plone portal object is currently what I'm doing.
> 
> """UNTESTED code"""
> class IAppSettings(object):
>     app_path = Attribute("path to the application")
> 
> class PortalAppSettings(object):
>     adapts(IPloneSiteRoot)
>     implements(IAppSettings)
> 
>     def __init__(self, context):
>         self.context = context
>         self.settings = 
> IAnnotations(self.context).setdefault(ANNOTATION_KEY, {})
> 
>     def get_base_path(self):
>         return self.settings.get('base_path', '/tmp/releases')
> 
>     def set_base_path(self, base_path):
>         self.settings['base_path'] = base_path
>     base_path = property(get_base_path, set_base_path)
> 
> This sort of thing could be generalized even further.  But is this a 
> good approach for storing settings like this?
> 
> -----
> Jordan Baker (hexsprite)


-- 
-----
Jordan Baker (hexsprite)






More information about the Product-Developers mailing list