• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: When (not) to use session().defaultEditingContext()
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: When (not) to use session().defaultEditingContext()


  • Subject: Re: When (not) to use session().defaultEditingContext()
  • From: Chuck Hill <email@hidden>
  • Date: Mon, 1 Nov 2004 12:06:21 -0800


On Oct 31, 2004, at 6:29 PM, Jake MacMullin wrote:

If you get data from the default editing context it could be stale (but this
isn't a problem if you've made all your changes through the default editing
context).


Ben has already pointed out that this is not quite accurate. For more on data freshness see www.wodev.com or, of course, Practical WebObjects.


Sometimes it is difficult to 'isolate' part of the object graph to use in a
separate editing context. In particular, some applications will have complex
relationships extending from an object that lives in the Session (such as a
User).


I find this very easy to avoid. One way is to wrap such security manager issues in an object that handles local instancing and returns the appropriate lists and true/false answers. Another way is to not have a authenticatedUser() method on session, but rather, authenticatedUser(EOEditingContext ec) this entirely avoiding any chance of accidentally getting a copy of the EO from the wrong ec.


So, as I see it (and I may be missing something here), the decision to use
the default editing context or not depends on weighing the difficulties of
making sure you don't accidentally save unwanted changes against the
difficulties of making sure related objects aren't registered in different
editing contexts (and having to explicitly lock and unlock).

The way that I look at it is not "default editing context" but "session editing context". If the object and its state is relevant to the whole session, then it goes in the defaultEditingContext(). The authenticated user is a good example of this. If it is relevant to only some actions in the session, then the object is kept with the manipulating pages.


I think there are also some memory issues. Inter-EO references are strong. So, if the session retains the User EO, and you fetch other objects into the default EC that are related, however indirectly, to the User object then neither these, nor the snapshots in the EOAccess layer, can be garbage collected until the session dies.


Chuck


--
Practical WebObjects - a book for intermediate WebObjects developers who want to increase their overall knowledge of WebObjects, or those who are trying to solve specific application development problems.
http://www.global-village.net/products/practical_webobjects




_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


  • Prev by Date: Re: Sorting
  • Next by Date: Re: Copying an EO with all its relateds...
  • Previous by thread: Re: When (not) to use session().defaultEditingContext()
  • Next by thread: [SOLVED but..] Download capability
  • Index(es):
    • Date
    • Thread