[ZODB-Dev] [ZODB4] - Shouldn't the new object be added to Connection._created ?
Ury Marshak
um@hottech-israel.com
Mon, 29 Jul 2002 11:33:27 +0200
>> My app level code keeps the new object referenced, and then tries to
rerun
>> the transaction after fixing the conflict. As a workaround I could
recreate
>> the
>> object if necessary,
>
>If the object was created in that (failed) transaction, then doesnt
reruning
>the transaction necessarily involve recreating the object?
I don't know ;) That's one possible answer to my question - that this sort
of behavior is explicitly forbidden.
The whole idea came up on this list when I asked how I can generate
sequential IDs for objects. What troubles me is that it seems
that the machinery supprting this (re-storing new objects) seems to be
there (and actually functioning when using say FileStorage directly) but it
fails when run using ZEO's ClientStorage. And the object is left in an
inconsistent state - it is marked as a ghost. So I cannot even copy the
object, or write some sort of .clone() method - any access attempt tries
to unghostify the object and dies with KeyError.
What I was actually trying to do was to write a class, say
'SequentiallyNumberedObject' that would have a method
'store_and_get_next_sequential_ID()', that would try to
commit itself, and on a ConflictError it would bump up the ID
number and try again. It seemed like a very convenient and
nice design (at that point :)
Still, I'm so new to ZODB (and OODBs) that I'm surely missing
a lot of basic tricks that you guys take for granted. It feels so
confusing - on one hand there's a lot of pure magic, like no need
to SELECT from tens of joined tables just to load a rather simple
object, on the other hand - no indices, no autonumbering, etc.
it has to be written by hand... just feels weird ;)
At first sight python+ZODB looks like an (almost) ideal platform
for a small 'business' applications. There are many benefits (one
of them for me for example is the ability to transparently switch to
a local storage in case of a single-user installation). What is
missing is some sort of a framework for common tasks like
automatic indexing, enforcing constrains on some of the
object's properties, automatic sequential numbering (I find that
a necessity - people would bug you all the time if you skip
a number in their CD collection database program, and in some
places, like when printing invoices, it may be required by law).
Such a framework might have hooks for easily plugging in a
generic GUI, that would need some metadata for the objects'
structure.
So, if other people have gone through this before, and done
something related, I'd be grateful for some pointers...
Ury