[Dev] persisting a preference

John Anderson john at osafoundation.org
Fri Nov 11 10:13:25 PST 2005


+1 This is along the lines of what I thinking too.

Alec Flett wrote:

> John Anderson wrote:
>
>> Chandler's repository already provides a great way to persist user 
>> data, state between sessions and a host of other stuff in the system 
>> (e.g. the order of items in tables), which we already use everywhere 
>> and it works great. I think calling all of this persistent data 
>> "preferences" would be confusing. I like Philippe's suggestion (see 
>> below) that we call user settings (e.g. style information) preferences.
>
> Yeah, I think there is really no technical difference between 
> preferences and any other data in the repository.. however there is a 
> /semantic/ difference, and that's what I think is worth trying to 
> capture. There are plenty of persisted values in the repository that, 
> if tweaked by the user, would probably just wreak havoc on chandler.
>
> Preferences, on the other hand, are safe to muck with a bit, and 
> provide some 'back door' hacks to allow us to try out experimental 
> behavior or features in the application by letting users turn them on 
> manually. For instance, here's a page of FireFox "hidden preferences" 
> - prefs which have no UI:
> http://www.geocities.com/pratiksolanki/
>
> So Philippe, you asked for a few things to be clarified. Here's what 
> I'd suggest:
>
> somewhere, say osaf.app, we have:
>
> class Preferences(Item):
>     pass
>
> Then, in an individual parcel's .py file, lets say this is for john's 
> MP3-organizer, somewhere:
>
> class MP3Prefs(Preferences):
>     favoriteGenre = schema.One(schema.String)
>
> and in their __init__.py's installParcel():
>
>     MP3Prefs.update(parcel, 'preferences', favoriteGenre='Rock')
>
> Then, to access that particular preference:
>     mp3prefs = schema.ns('mp3player', view).preferences
>     genre = mp3prefs.favoriteGenre
>
> If a tool wanted to iterate all preferences in the system, and print 
> them to the screen:
>
> for parcelPrefs in osaf.app.Preferences.iterItems():
>     print "Preferences for: %s:" % parcelPrefs.__class__.__name__
>     for prefname, prefvalue, preftype in 
> parcelPrefs.iterAttributes(inherited=False):
>         print "    %s = %s" % (prefname, prefvalue)
>
> This would (hopefully) print:
>
> Preferences for: MP3Prefs:
>     favoriteGenre = Rock
>
> you could even imagine a UI like about:config that uses 
> AttributeEditors to edit the prefs and make sure they have the right 
> sort of UI for each type of attribute.
>
> Alec
>
>------------------------------------------------------------------------
>
>_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
>
>Open Source Applications Foundation "Dev" mailing list
>http://lists.osafoundation.org/mailman/listinfo/dev
>  
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osafoundation.org/pipermail/dev/attachments/20051111/694fb042/attachment.html


More information about the Dev mailing list