Re: [Zope-dev] initializing objects in ZPatterns

2001-02-22 Thread Steve Alexander

Christian Scholz wrote:

 Hi!
 
 I just encountered another problem with ZPatterns (well not exactly with ZPatterns
 but the way I use it.. ;-)
 
 I have some Specialist with a normal rack which stores data persistently in the ZODB.
 Everytime I am creating a new object I want to create an object of another specialist
 on the fly and store it's id inside my first object.
 
 Thus I have setup a SkinScript with the following content:
 
 
   INITIALIZE OBJECT WITH company_address=addresses.createAddress()
 
   WITH addresses.getItem(self.company_address) COMPUTE company_addr=RESULT
 
   STORE company_address IN SELF
 
 The createAddress is called actually and it returns the ID of the new object
 (thus the object is created). Unfortunately the id is not stored inside
 company_address. After reading the new object again this value is still empty
 (and thus also no address object is return by the address specialist). Same happens
 when just using some dummy property and filling it with a fixed string. This
 also disappears..

To get company_address stored, you can probably do something like:

  your_object.manage_changeProperties(company_address=your_object.company_address)

or possibly your_object.propertysheets.NameOfSheet.manage_changeProperties...
depending on what kind of object you're using.

You could have this as a trigger:

WHEN OBJECT ADDED CALL
  self.manage_changeProperties(company_address=self.company_address)


As for whether it is a bug, the implementation of the INITALIZE clause just puts
its attributes directly into the DataSkin's attribute-cache. It appears to be
designed for the behaviour that you see.

You could get the behaviour that you want by making the implementation actually
set the attributes instead. I'm not sure what the other implications of doing
that are, though.

If you're interested, the code is in

  lib/python/Products/ZPatterns/SkinScript/Components.py
about line 71.

--
Steve Alexander
Software Engineer
Cat-Box limited
http://www.cat-box.net




___
Zope-Dev maillist  -  [EMAIL PROTECTED]
http://lists.zope.org/mailman/listinfo/zope-dev
**  No cross posts or HTML encoding!  **
(Related lists - 
 http://lists.zope.org/mailman/listinfo/zope-announce
 http://lists.zope.org/mailman/listinfo/zope )



Re: [Zope-dev] initializing objects in ZPatterns

2001-02-22 Thread Christian Scholz

Hi!

  I just encountered another problem with ZPatterns (well not exactly with ZPatterns
  but the way I use it.. ;-)
  
  I have some Specialist with a normal rack which stores data persistently in the 
ZODB.
  Everytime I am creating a new object I want to create an object of another 
specialist
  on the fly and store it's id inside my first object.
  
  Thus I have setup a SkinScript with the following content:
  
  
INITIALIZE OBJECT WITH company_address=addresses.createAddress()
  
WITH addresses.getItem(self.company_address) COMPUTE company_addr=RESULT
  
STORE company_address IN SELF
  
  The createAddress is called actually and it returns the ID of the new object
  (thus the object is created). Unfortunately the id is not stored inside
  company_address. After reading the new object again this value is still empty
  (and thus also no address object is return by the address specialist). Same happens
  when just using some dummy property and filling it with a fixed string. This
  also disappears..
 
 To get company_address stored, you can probably do something like:
 
   your_object.manage_changeProperties(company_address=your_object.company_address)
 
 or possibly your_object.propertysheets.NameOfSheet.manage_changeProperties...
 depending on what kind of object you're using.
 
 You could have this as a trigger:
 
 WHEN OBJECT ADDED CALL
   self.manage_changeProperties(company_address=self.company_address)

Well, the first one seems to work, but the SkinScript trigger does not unfortunately.
So I will try to incorporate this into my other code (which is a bit more tricky
as I automated all the property handling stuff). But thanks anyway!

 As for whether it is a bug, the implementation of the INITALIZE clause just puts
 its attributes directly into the DataSkin's attribute-cache. It appears to be
 designed for the behaviour that you see.
 
 You could get the behaviour that you want by making the implementation actually
 set the attributes instead. I'm not sure what the other implications of doing
 that are, though.
 
 If you're interested, the code is in
 
   lib/python/Products/ZPatterns/SkinScript/Components.py
 about line 71.

ok, thanks, will have a look at that.

cheers,
  Christian


___
Zope-Dev maillist  -  [EMAIL PROTECTED]
http://lists.zope.org/mailman/listinfo/zope-dev
**  No cross posts or HTML encoding!  **
(Related lists - 
 http://lists.zope.org/mailman/listinfo/zope-announce
 http://lists.zope.org/mailman/listinfo/zope )



Re: [Zope-dev] initializing objects in ZPatterns

2001-02-22 Thread Christian Scholz

Hi!

 To get company_address stored, you can probably do something like:
 
   your_object.manage_changeProperties(company_address=your_object.company_address)
 
 or possibly your_object.propertysheets.NameOfSheet.manage_changeProperties...
 depending on what kind of object you're using.

I've now tried

WHEN OBJECT ADDED CALL
  
self.propertysheets.data.manage_changeProperties(company_address=self.company_address)

which gives me some Unauthorized error on the method call.

(when doing it manually in some dtml method after newItem() it works ok, though.
And I am logged in as Manager..)

Sometimes I wish Zope would print more about the details of such an response,
e.g. which permissions might be missing..

Anyway, I will keep experimenting with it (also tried to subclass directly from
DataSkin, to override some method which create the company address) but then
I noticed that it always needs to be a ZClass (except I would also implement my
own Rack, I guess..)
Wonder when the basic app will be running.. ;-)

ok, nice evening everybody! :)

-- christian


___
Zope-Dev maillist  -  [EMAIL PROTECTED]
http://lists.zope.org/mailman/listinfo/zope-dev
**  No cross posts or HTML encoding!  **
(Related lists - 
 http://lists.zope.org/mailman/listinfo/zope-announce
 http://lists.zope.org/mailman/listinfo/zope )



Re: [Zope-dev] initializing objects in ZPatterns

2001-02-22 Thread Steve Alexander

Christian Scholz wrote:


 I've now tried
 
 WHEN OBJECT ADDED CALL
   
self.propertysheets.data.manage_changeProperties(company_address=self.company_address)
 
 which gives me some Unauthorized error on the method call.

Give your skinscript an appropriate proxy role.

--
Steve Alexander
Software Engineer
Cat-Box limited
http://www.cat-box.net


___
Zope-Dev maillist  -  [EMAIL PROTECTED]
http://lists.zope.org/mailman/listinfo/zope-dev
**  No cross posts or HTML encoding!  **
(Related lists - 
 http://lists.zope.org/mailman/listinfo/zope-announce
 http://lists.zope.org/mailman/listinfo/zope )



[Zope-dev] initializing objects in ZPatterns

2001-02-21 Thread Christian Scholz

Hi!

I just encountered another problem with ZPatterns (well not exactly with ZPatterns
but the way I use it.. ;-)

I have some Specialist with a normal rack which stores data persistently in the ZODB.
Everytime I am creating a new object I want to create an object of another specialist
on the fly and store it's id inside my first object.

Thus I have setup a SkinScript with the following content:


  INITIALIZE OBJECT WITH company_address=addresses.createAddress()

  WITH addresses.getItem(self.company_address) COMPUTE company_addr=RESULT

  STORE company_address IN SELF

The createAddress is called actually and it returns the ID of the new object
(thus the object is created). Unfortunately the id is not stored inside
company_address. After reading the new object again this value is still empty
(and thus also no address object is return by the address specialist). Same happens
when just using some dummy property and filling it with a fixed string. This
also disappears..

So what do I have to do to get it stored?
(the other data which is handled via the default plugins is stored and all the
attributes are defined inside the ZClass..)

Hope, anyone knows how this might be fixed..

regards,
  Christian

-- 
COM.lounge  http://comlounge.net/
communication  design [EMAIL PROTECTED]

___
Zope-Dev maillist  -  [EMAIL PROTECTED]
http://lists.zope.org/mailman/listinfo/zope-dev
**  No cross posts or HTML encoding!  **
(Related lists - 
 http://lists.zope.org/mailman/listinfo/zope-announce
 http://lists.zope.org/mailman/listinfo/zope )