[Zope] Lets try this again - auto-creation

Alex Rice alrice@swcp.com
Sat, 17 Jul 1999 22:45:41 -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.

Maybe you can use an external method that does something similar to what
ZClass._new_class_id() does. This generates something like HM4tXUeVmZJNmNfBf2s4ew==

from lib/python/ZClasses/ZClass.py:

   def _new_class_id(self):
	  import md5, base64, time

	  id=md5.new()
	  id.update(self.absolute_url())
	  id.update(str(time.time()))
	  id=id.digest()
	  id=string.strip(base64.encodestring(id))

	  return '*'+id

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