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 <[EMAIL PROTECTED]> 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)



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

Reply via email to