[Zope-dev] ZPatterns AttributeProvider question

Christian Scholz cs@comlounge.net
Fri, 20 Apr 2001 22:33:58 +0200


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