zpatterns-0.4: creating an item in "virtual mode"
Hello, I use virtual attribute access to provide access to my SQL database. However, I want to use the Rack.newItem facility to create new records in the database. But it fails because in virtual mode, an item always exists. This patch solves the problem, at least for me --- Rack.py.orig Mon Jun 26 11:35:25 2000 +++ Rack.py Wed Jul 5 11:13:04 2000 @@ -125,7 +125,8 @@ # Create a new object, identified by key - item = self.getItem(key) + a = self.loadAttrib + item = not a and self.getItem(key) or None # XXX What if all items potentially exist? @@ -134,7 +135,6 @@ item = self._RawItem(key) - a = self.loadAttrib if not a: slot = self._writeableSlot(key) slot[SelfKey] = item.aq_base # strip acquisition wrapping comments? regards, jephte.clain@univ-reunion.fr
At 11:14 AM 7/5/00 +0400, Jephte CLAIN wrote:
Hello,
I use virtual attribute access to provide access to my SQL database. However, I want to use the Rack.newItem facility to create new records in the database. But it fails because in virtual mode, an item always exists. This patch solves the problem, at least for me
# XXX What if all items potentially exist?
comments?
The XXX comment shown above says it all. :) Actually, all it says is that I knew the problem you're having would happen. However, if I put your patch in, I now have to have one that said: # XXX What if object already exists in virtual mode? That having been said, I will think about adding your patch, or alternatively a storage setting that tells the Rack whether to check for existence before adding new items. This setting would default to being true, so you could change it for your circumstance, which is a fairly special case, I think.
participants (2)
-
Jephte CLAIN -
Phillip J. Eby