[Zope] Lets try this again - auto-creation

Alex Rice alrice@swcp.com
Sat, 17 Jul 1999 23:20:31 -0600 (MDT)


On Sat, 17 Jul 1999 16:22:25 -0400,
"Bruce C. Dillahunty" <bdillahu@mindspring.com> said:

Bruce> Does anybody know of a way to create a ZClass object without
Bruce> entering an "ID"... I want the user to create an object, and the
Bruce> ID be "autocreated" (a random number, the date/time,
Bruce> whatever). I'll be accessing them through a ZCatalog searching on
Bruce> properties, creation date, etc. and don't care about the unique
Bruce> ID.

Or maybe it's not the creation of a unique ID that's the problem, rather
how to get the ZClass itself created with that ID?

How about this?

o Create ZClass "X" and choose yes to "Create Factory and add methods".
o In your X_factory object, change Method from X_addForm to X_add.
o In X_add (the constructor), make a change like this:

<!--#with "X.createInObjectManager(_.str(_.whrandom.random()), REQUEST)"-->

instead of

<!--#with "X.createInObjectManager(REQUEST['id'], REQUEST)"-->

_.str(_.whrandom.random()) could be an external method or whatever
generates the unique ID (lava-rand!)

Now when you create a ZClass X in Zope, a random number is selected as
the ID, the object is created, but the user does not see the usual id
entry form. 

-- 
Alex Rice    |    alrice@swcp.com    |    http://www.swcp.com/~alrice
    Current Location: N. Rio Grande Bioregion, Southwestern USA