ZPatterns AttributeProvider question
Good evening everybody! I have some question regarding attribute and agent programming for ZPatterns. I have some provider which is registered for the "handlers" and "attributes" methods and some attributes. My problem is when trying to create a new object and directly editing it, e.g. obj=newItem() obj.propertysheets.data.manage_changeProperties(foobar=13) the propertysheet is defined and my provider is also registered for handling the property "foobar". Unfortunately my SetAttributeFor() method is never called. Also defined in my provider are _objectAdded(), _objectAdding(), _objectChanged() (but not _objectChanging()). Here's what they do: _objectAdded() is storing the data collected via SetAttributeFor() into an sql database as new record _objectAdding() is doing the same as the original method but also committing the transaction as otherwise the new record will not be stored into the database (basically it calls _objectAdded() via the transaction mechanism). I needed to do that as otherwise a getattr on the primary key (==loadAttrib) failed as I try to retrieve the record inside the _AttributeFor() method. _objectChanged() doing the same as objectAdded() but updating the sql database. So what's happening is that _objectAdding() and _objectAdded() get called from the newItem() call but _SetAttributeFor() is not called. When doing the manage_changeProperties() inside a new method which is called manually (and does a getItem()) everything is fine. I've also tried to do obj=newItem() newid=obj.id obj2=getItem(newid) obj2.propertysheets.data.manage_changeProperties(foobar=13) but this also did not call _SetAttributeFor(). So does any ZPatterns wizard has any idea on what I might do wrong? (I can also send someone the source code if this message seems too confusing ;-) regards, Christian Scholz PS: What I am trying to create is an sql attribute provider for ZPatterns which is some replacement for manually creating the zsql method and SkinScript methods. Unfortunately it seems more difficult than I thought at first ;-) -- COM.lounge http://comlounge.net/ communication & design info@comlounge.net
Christian Scholz wrote:
Good evening everybody!
I have some question regarding attribute and agent programming for ZPatterns.
I have some provider which is registered for the "handlers" and "attributes" methods and some attributes.
My problem is when trying to create a new object and directly editing it, e.g.
obj=newItem() obj.propertysheets.data.manage_changeProperties(foobar=13)
the propertysheet is defined and my provider is also registered for handling the property "foobar". Unfortunately my SetAttributeFor() method is never called.
Have you defined a namesForRegistration method in your provider? See Components.py for an example: lib/python/Products/ZPatterns/SkinScript/Components.py -- Steve Alexander Software Engineer Cat-Box limited
Hi!
Good evening everybody!
I have some question regarding attribute and agent programming for ZPatterns.
I have some provider which is registered for the "handlers" and "attributes" methods and some attributes.
My problem is when trying to create a new object and directly editing it, e.g.
obj=newItem() obj.propertysheets.data.manage_changeProperties(foobar=13)
the propertysheet is defined and my provider is also registered for handling the property "foobar". Unfortunately my SetAttributeFor() method is never called.
Have you defined a namesForRegistration method in your provider?
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). cheers, Christian -- COM.lounge http://comlounge.net/ communication & design info@comlounge.net
At 08:18 PM 4/21/01 +0200, Christian Scholz wrote:
Hi!
Good evening everybody!
I have some question regarding attribute and agent programming for ZPatterns.
I have some provider which is registered for the "handlers" and "attributes" methods and some attributes.
My problem is when trying to create a new object and directly editing it, e.g.
obj=newItem() obj.propertysheets.data.manage_changeProperties(foobar=13)
the propertysheet is defined and my provider is also registered for handling the property "foobar". Unfortunately my SetAttributeFor() method is never called.
Have you defined a namesForRegistration method in your provider?
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. 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.
participants (3)
-
cs@comlounge.net -
Phillip J. Eby -
Steve Alexander