[Zope-dev] ZPatterns AttributeProvider question

Christian Scholz cs@comlounge.net
Sun, 22 Apr 2001 15:52:32 +0200


Hi!

> >Yes, as said above it registers for handlers and attributes. Also
> >_objectChanged and _SetAttributeFor() etc. are called. They're just not
> called 
> >directly after creating the object (when being in the same request that is).
> 
> _objectChanged() is a transaction-commit message.  You'll only get it when
> the (sub)transaction commits.  You'll receive _objectChanging() just
> *before* the object changes.

Yep, that's how I understood it. That's also working.

> As for _SetAttributeFor(), it should be called at the time
> manage_changeProperties executes, not at object creation.  Are you sure
> that you have it properly named and that it isn't still being defined by
> one of your ancestor classes instead?  The "AttributeProvider" and
> "GTMixin" base classes in ZPatterns implement _SetAttributeFor() by simply
> noting the change for later.  If you don't override this behavior, your
> class won't see _SetAttributFor() itself.

Well, it actually is working, just not directly after creating the new object.

So what I do now as workaround is 

dtml method 1:

- creates new object via newItem()
- redirects to dtml method 2

dtml method 2:
- retrieves the newly created object with getItem()
- calls manage_changeProperties on that object

This is working. Putting the manage_changeProperties directly after the
newItem() is not working. I've also tried retrieving the new object
directly after newItem() and calling manage_changeProperties on that
but this also did not work.
(so it is named correctly as otherwise it wouldn't be called either in dtml method 2).

So the main problem is: SetAttributeFor() is not called (and also _objectChanging()
is not called) in the same request cycle after creating a new object.
They're called however in the "next" request after retrieving it with getItem().

Maybe it helps if I publish the source somewhere? It's gonna be some public
product anyway.

regards,
  Christian

-- 
COM.lounge                                          http://comlounge.net/
communication & design                                 info@comlounge.net