[Zope] Bug? Traversable.absolute_url

Thomas Guettler zopestoller@thomas-guettler.de
Tue, 30 Jul 2002 11:39:31 +0200


Hi Chris and all others!

Chris Withers wrote:

> Thomas Guettler wrote:
> 
>> Hi!
>>
>> I changes some stuff in my code and now I get:

 >

> What changes did you make?


I changed some stuff how objects get created. The way objects
are created is a bit odd. There are defaults-Documents for each
class. New objects get created by making a copy if the default objects

I had an other strange error: hasattr(aq_base(self, prop)) behaved odd:
It return true although the property was not there!

Maybe someone finds a mistake in the way I create objects:

BTW, it is not very important. Just have a look if you have time to.

     def createNewDocument(self, REQUEST=None):
         "Create a new document from the template in the folder 'defaults'"
         #Call __init__ of this class
         copy=self.__class__(self.root())

         #Copy state to new instance
         state=self.__getstate__()
         id=copy.id # setstate overwrites id
         copy.__setstate__(state)
         copy.id=id
         copy.isDefaultDocument=0
         copy._updateProperty('stollfolder_users', [self.root().userManagement.
                              getCurrentUser()])
         #Assertion: Test if the reference to the stollCatalog is OK
         if copy.default_catalog!=self.default_catalog:
             raise "Bad Copy"

         #Copy attachments
         for (id, att) in copy.objectItems():
             new_att=att._getCopy(copy)
             copy._delObject(id)
             copy._setObject(id, new_att)


         r=copy.root()
         path=string.join(['/', r.id, '/documents/', copy.id], '')
         r.stollCatalog.catalog_object(copy, path)

         #Protokollierung
         copy.stollfolder_history=[]
         copy.stollfolder_historyAdd("Dokument Nr '" + copy.id +
                                     "' wurde erstellt")

         if REQUEST:
             REQUEST.RESPONSE.redirect('/' + self.root().id +
                                       '/documents/' + copy.id)
         return copy

  thomas