[Zope-dev] ZPatterns - help!
Phillip J. Eby
pje@telecommunity.com
Thu, 23 Nov 2000 17:24:00 -0500
At 01:58 PM 11/23/00 -0500, bentzion@bellatlantic.net wrote:
>I am trying to create 'virtual' DataSkins that totally live in a
>SQL database. How do I create a new item in a rack without
>providing an initial ID for the object?
You can't. To do what you're trying to do, you would need to implement a
"newKey" function in the Specialist that creates the row, but with contents
that would still cause your attribute providers to pretend the object
doesn't yet exist.
Basically, ZPatterns as it is now does not provide support for creating an
object without first knowing its ID. This means that it's hard to support
autogenerated database ID's, but I suggest rethinking your design a bit.
Using keys that are identity columns is often a bad idea, since reloading
data tends to mess them up or reassign them, that sort of thing. I have
found it to usually be better to have a seperate counter that issues ID's
that then are guaranteed to never be re-issued to the wrong object. Also,
by seperating ID generation from insertion you can often gain concurrency
in multi-user applications (because you can generate ID's on a seperate
connection, in a seperate transaction).
Even if you prefer to use a directly autogenerated integer key for
referential integrity purposes, in most application domains there is a
domain-specific primary key that can/should be used as your 'id' attribute.