Re: Axiom on the client and server, Client-side object caches was Re: Any ideas why Axiom is acting odd?
Robert Gravina <[email protected]> Mon, 3 Jul 2006 17:48:11 +0900
| Newsgroups | gmane.comp.python.quotient.dev |
|---|---|
| Message-ID | <[email protected]> |
> for book in myitem.books: > if type(book) is StoreID: > book = cache.get(book.storeID) > print book.name > Ah sorry for all the noise.. I think I went off on a tangent, what I was really looking for is a way to have Axioms stores on both sides, and a convenient way of keeping them in sync with Twisted PB. I hope you all don't mind this thinking aloud on the list. I guess this is simpler and better: 1) Load MyItem object from server-side store 2) Send to client as simpler RemoteMyItem (doesn't inherit from Item, but has same attributes ... I had lots of troubles trying to send Items with PB, because of the Store references, axiom.sequence.List references etc.). Add "severStoreID" as an attribute. (simple dict cache) 3) Store this in a local cache dict indexed by "serverStoreID". OR (Axiom Store) 3) Add another attribute, "serverClass" to the RemoteMyItem class and store the class type here. Create a MyItem instance in the client side store. Copy across all attributes. If any of these attributes have a "serverStoreID" attribute, create a type of whatever is in "serverClass" and give it all the attributes. Do this recusively. Now you can query your local Axiom store for you client app, and if you want to update the server, it can use all the "serverStoreID" and "serverClass" attributes to do so. Make sure the Axoim Store is an attribute of a pb.RemoteCache and you can call "observe_updatedItem" every time you want to notify clients of an updated object. At least, that should all work *in theory*... right? ;) Provided copying across all attributes (just the ones you defined in RemoteMyItem) can be done with introspection, the code could be pretty generic. Robert