Jordan Baker wrote:
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?

yep pretty much. look at zope3 utilities on http://www.openplans.org/projects/plonecheatsheet/





_______________________________________________
Product-Developers mailing list
[email protected]
http://lists.plone.org/mailman/listinfo/product-developers

Reply via email to