[Chandler-dev] dump/reload issues

D John Anderson john at osafoundation.org
Wed Apr 4 13:36:24 PDT 2007


+1
On Apr 4, 2007, at 11:26 AM, Morgen Sagen wrote:

> We need to settle on how we're going to dump and reload data that  
> lives under //parcels, including preferences information.  Let me  
> explain how I am doing things, and we can see if this works for  
> everyone else.  (This assumes that the dump code is only going to  
> iterate items outside of //parcels, and the logic for doing so is  
> moving out of Main.py and into dumpreload.py)
>
>
> So osaf.sharing has an out-of-the-box (OOTB) Reference item named  
> "currentSharingAccount" which has a bi-directional-reference to  
> whatever the "current" sharing account item is.  Originally, the  
> OOTB sharing account item lived under //parcels.  I recently  
> changed sharing/__init__.py to create the OOTB account outside of // 
> parcels (//userdata now).  So now that account will get dumped just  
> like any other account.
>
> As for sharing preferences, I defined a model.SharePrefsRecord  
> which contains the UUID of the "current" sharing account:
>
>    class SharePrefsRecord(eim.Record):
>        URI = "http://osafoundation.org/eim/sharing/prefs/0"
>        currentAccount = eim.field(schema.UUID) # empty string means  
> no account
>
>
> ...and added the following methods to DumpTranslator:
>
>     @model.SharePrefsRecord.importer
>     def import_share_prefs(self, record):
>
>         if record.currentAccount:
>             @self.withItemForUUID(record.currentAccount,
>                 accounts.SharingAccount)
>             def set_current(account):
>                 ref = schema.ns("osaf.sharing",  
> self.rv).currentSharingAccount
>                 ref.item = account
>
>     # Called from finishExport()
>     def export_share_prefs(self):
>
>         ref = schema.ns("osaf.sharing", self.rv).currentSharingAccount
>         if ref.item is None:
>             currentAccount = ""
>         else:
>             currentAccount = ref.item.itsUUID.str16()
>         cur = ref.item
>
>         yield model.SharePrefsRecord(currentAccount)
>
>
> Note that export_share_prefs is a regular method called directly  
> from DumpTranslator's finishExport( ) method.  The SharePrefsRecord  
> is imported using the decorated import_share_prefs method.  Note  
> also that since there is ever only one SharePrefsRecord instance,  
> that record type doesn't need to have any key fields.
>
>
> In the future we'll improve the Translator code so that parcels can  
> register themselves and get hooked into what the translator is  
> doing, but for now just add specific "yield" statements to  
> DumpTranslator.finishExport( ).
>
> Sound good?
> _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
>
> Open Source Applications Foundation "chandler-dev" mailing list
> http://lists.osafoundation.org/mailman/listinfo/chandler-dev



More information about the chandler-dev mailing list