Re: [PyPerSyst-Devel] Surrogates and nested entities
Brought to you by:
pobrien
From: <po...@or...> - 2003-09-26 02:56:57
|
Peter Lyons <pe...@pe...> writes: > >>Yes, and recursively creating surrogates for all nested entity > >> instances in the graph. > > >No nesting. Nesting is evil. > > So let's say I have a Person entity with two fields that are Address > Entities, homeAddress and workAddress. Let's say I display this info > in a web form and the user edit's the person's name and part of each > address. How many UpdateSurrogates would I need to create to get this > transaction through the system? I'd like to do (pseudo code): > -------- > surrogate = realPersonRef.getUpdateSurrogate() > surrogate.firstName = newFirstName > surrogate.homeAddress.postalCode = newPostalCode > surrogate.workAddress.state = newState > > engine.execute(surrogate) > -------- A use case is good. The example you give is not what I consider evil. I'm not completely sure yet how to handle attributes of references. I have to give more thought to this. > (actually, I prefer accesing attributes by methods always, but this > is just a for-instance) Why is that? Sounds like needless overhead to me. > Would I need to do 3 calls to getUpdateSurrogate() or some similar > method? I prefer it when there is no distinction between editing a > "leaf" object or a "branch" object. I agree that there shouldn't necessarily be a distinction. There isn't on read access. Making changes, however, is different. I need to work through some examples to figure out the best way to handle this. Sometimes a group of changes like this may actually logically be three separate transactions. So then it is a question of how to simplify the creation of all three. Other times the group of changes might represent a single transaction (changes to an order and order details). Off the top of my head it sounds like if the relationship is a composition (like order and order detail) then the changes would represent a single transaction. If not, the changes represent separate transactions. Good questions. Much to think about. ;-) -- Patrick K. O'Brien Orbtech http://www.orbtech.com/web/pobrien ----------------------------------------------- "Your source for Python programming expertise." ----------------------------------------------- |