[Dev] persisting a preference

Phillip J. Eby pje at telecommunity.com
Thu Nov 3 08:04:36 PST 2005


At 08:57 PM 11/2/2005 -0800, Jeffrey Harris wrote:
>Hi Folks,
>
>What's our current thinking on how a developer should go about
>establishing and using what I'll call a preference, essentially a single
>persistent value with a well-known name (in this case, I'm wanting to
>persist the last directories chosen for import and export)?
>
>We've got lots of well-known collections living in
>parcels/osaf/app/__init__.py, perhaps that's the appropriate place for
>preferences?  It doesn't feel quite right to me...
>
>I'm sending this question to the list instead of asking one person or
>another because
>A) I think there might be different opinions, and
>B) I'm hoping someone will write up a detailed example so that knowledge
>can live on in the list, not just my brain :)

The simplest thing that would work:

     class PrefsForMyParcel(schema.Item):
          some_pref = schema.One(sometype, defaultValue=something)
          # ... other preferences

     def installParcel(parcel, oldVersion=None):
         PrefsForMyParcel.update(parcel, "prefs")

Accessing preferences can then be done via:

     schema.ns("my.parcel", view).prefs.some_pref



More information about the Dev mailing list