Re: [Zope] adding product-based objects programmatically

2006-08-05 Thread Kees de Brabander

- Original Message - 
From: Dieter Maurer [EMAIL PROTECTED]
To: Kees de Brabander [EMAIL PROTECTED]
Cc: Jens Vagelpohl [EMAIL PROTECTED]; [Zope] Mailing List
zope@zope.org
Sent: Friday, August 04, 2006 8:11 PM
Subject: Re: [Zope] adding product-based objects programmatically


 Kees de Brabander wrote at 2006-8-3 20:39 +0200:
  ... adding additional objects ...
 Thanks anyway, problem solved, even when done in the __init__ of
Queryset.
 Would manage_afterAdd a more sensible place for it?

 You cannot do it in __init__ when the object needs a correct
 acquisition chain (which is not the case in __init__).
 This is the case, for example, when the object needs to be indexed.

 When you add further objects in manage_afterAdd, you have to be
 aware, that manage_afterAdd is not only called when the object
 is initially created but also for rename/move/copy. In all those cases,
 your objects are likely to be already there. This means that you have
 explicitely to check for this case.

Googling and puzzling I became aware of that fact. Thanks for your concern.
cb

___
Zope maillist  -  Zope@zope.org
http://mail.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists - 
 http://mail.zope.org/mailman/listinfo/zope-announce
 http://mail.zope.org/mailman/listinfo/zope-dev )


Re: [Zope] adding product-based objects programmatically

2006-08-04 Thread Dieter Maurer
Gabriel Genellina wrote at 2006-8-3 20:58 -0300:
At Thursday 3/8/2006 15:51, Kees de Brabander wrote:

  dispatcher.Destination()._setObject(id, nQ)

I remembered and checked: it was taken from the Zope Developer's Guide 2.4
edition on zope.org!!

I would delete that from zope.org site.
It's far too old and outdated, and confuses people.

The Zope Developer's Guide is still useful.

We should keep it until we got something better...



-- 
Dieter
___
Zope maillist  -  Zope@zope.org
http://mail.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists - 
 http://mail.zope.org/mailman/listinfo/zope-announce
 http://mail.zope.org/mailman/listinfo/zope-dev )


Re: [Zope] adding product-based objects programmatically

2006-08-04 Thread Dieter Maurer
Kees de Brabander wrote at 2006-8-3 20:39 +0200:
 ... adding additional objects ...
Thanks anyway, problem solved, even when done in the __init__ of Queryset.
Would manage_afterAdd a more sensible place for it?

You cannot do it in __init__ when the object needs a correct
acquisition chain (which is not the case in __init__).
This is the case, for example, when the object needs to be indexed.

When you add further objects in manage_afterAdd, you have to be
aware, that manage_afterAdd is not only called when the object
is initially created but also for rename/move/copy. In all those cases,
your objects are likely to be already there. This means that you have
explicitely to check for this case.



-- 
Dieter
___
Zope maillist  -  Zope@zope.org
http://mail.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists - 
 http://mail.zope.org/mailman/listinfo/zope-announce
 http://mail.zope.org/mailman/listinfo/zope-dev )


Re: [Zope] adding product-based objects programmatically

2006-08-03 Thread Kees de Brabander
hi,
- Original Message - 
From: Jens Vagelpohl [EMAIL PROTECTED]
To: [Zope] Mailing List zope@zope.org
Sent: Wednesday, August 02, 2006 12:52 PM
Subject: Re: [Zope] adding product-based objects programmatically


 -BEGIN PGP SIGNED MESSAGE-
 Hash: SHA1


 On 2 Aug 2006, at 06:37, Kees de Brabander wrote:

  Hi,
  Apparently my knowledge of Zope/Python is still to limited.
  I have a product that derives from Folder. When I add this product
  to a
  folder via zmi I want to have it populated with other products to it
  programmatically. I tried to do so in the __init__ function. That
  works with
  objects like acl_user folders, but not with products in the products
  directory. Can anyone send me in the right direction or at least
  give a hint
  where to look for a solution?

 Do not do this in __init__ as you have no acquisition at that point.
 Use manage_afterAdd for that.

 jens

Your remark appeared (and presumably is) valid, although I do not understand
why adding acl_user folders has no problems with that. So, I additionally
defined manage_afterAdd. However I got the same error. Any more pointers? By
the way, where are 'manage_afterAdd' and friends documented?
tia, cb

Module QuerySet.py:
from Query import manage_addQuery
class QuerySet(Folder):
def __init__(self, id, title):
self.id = id
self.title = title
self.manage_addUserFolder()

def manage_afterAdd(self, item, container):
manage_addQuery(self, id, title)

manage_addQuery in Query.py looks like:
def manage_addQuery(dispatcher, id, title, REQUEST=None):

nQ=Query(id,title)
dispatcher.Destination()._setObject(id, nQ)
if REQUEST is not None:
dispatcher.manage_main(dispatcher, REQUEST)


Traceback (innermost last):

  a.. Module ZPublisher.Publish, line 101, in publish
  b.. Module ZPublisher.mapply, line 88, in mapply
  c.. Module ZPublisher.Publish, line 39, in call_object
  d.. Module Products.QuerySet.QuerySet, line 81, in manage_addQuerySet
  e.. Module OFS.ObjectManager, line 276, in _setObject
  f.. Module Products.QuerySet.QuerySet, line 114, in manage_afterAdd
  g.. Module Products.Query.Query, line 80, in manage_addQuery
AttributeError: Destination



zope 2.7.8, win32



___
Zope maillist  -  Zope@zope.org
http://mail.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists - 
 http://mail.zope.org/mailman/listinfo/zope-announce
 http://mail.zope.org/mailman/listinfo/zope-dev )


Re: [Zope] adding product-based objects programmatically

2006-08-03 Thread Jens Vagelpohl

-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

Your remark appeared (and presumably is) valid, although I do not  
understand
why adding acl_user folders has no problems with that. So, I  
additionally
defined manage_afterAdd. However I got the same error. Any more  
pointers? By

the way, where are 'manage_afterAdd' and friends documented?


Google? The source code? Dunno.


  a.. Module ZPublisher.Publish, line 101, in publish
  b.. Module ZPublisher.mapply, line 88, in mapply
  c.. Module ZPublisher.Publish, line 39, in call_object
  d.. Module Products.QuerySet.QuerySet, line 81, in  
manage_addQuerySet

  e.. Module OFS.ObjectManager, line 276, in _setObject
  f.. Module Products.QuerySet.QuerySet, line 114, in manage_afterAdd
  g.. Module Products.Query.Query, line 80, in manage_addQuery
AttributeError: Destination


This error is obviously coming from your own source code, and since I  
don't see that code I can't help.


jens


-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.1 (Darwin)

iD8DBQFE0fSzRAx5nvEhZLIRAoYGAJ9Ic5o/B0SQoe0k459Lre37f0qwVQCdGXhV
R9oDTi32WNJNhrIYUidfBSI=
=diJA
-END PGP SIGNATURE-
___
Zope maillist  -  Zope@zope.org
http://mail.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists - 
http://mail.zope.org/mailman/listinfo/zope-announce

http://mail.zope.org/mailman/listinfo/zope-dev )


Re: [Zope] adding product-based objects programmatically

2006-08-03 Thread Kees de Brabander
Huh? I included the relevant portions of my source code in my message:

Module QuerySet.py:
from Query import manage_addQuery
class QuerySet(Folder):
def __init__(self, id, title):
self.id = id
self.title = title
self.manage_addUserFolder()

def manage_afterAdd(self, item, container):
manage_addQuery(self, id, title)

manage_addQuery in Query.py looks like:
def manage_addQuery(dispatcher, id, title, REQUEST=None):

nQ=Query(id,title)
dispatcher.Destination()._setObject(id, nQ)
if REQUEST is not None:
dispatcher.manage_main(dispatcher, REQUEST)

cb
- Original Message - 
From: Jens Vagelpohl [EMAIL PROTECTED]
To: [Zope] Mailing List zope@zope.org
Sent: Thursday, August 03, 2006 3:05 PM
Subject: Re: [Zope] adding product-based objects programmatically


 -BEGIN PGP SIGNED MESSAGE-
 Hash: SHA1
 
  Your remark appeared (and presumably is) valid, although I do not  
  understand
  why adding acl_user folders has no problems with that. So, I  
  additionally
  defined manage_afterAdd. However I got the same error. Any more  
  pointers? By
  the way, where are 'manage_afterAdd' and friends documented?
 
 Google? The source code? Dunno.
 
a.. Module ZPublisher.Publish, line 101, in publish
b.. Module ZPublisher.mapply, line 88, in mapply
c.. Module ZPublisher.Publish, line 39, in call_object
d.. Module Products.QuerySet.QuerySet, line 81, in  
  manage_addQuerySet
e.. Module OFS.ObjectManager, line 276, in _setObject
f.. Module Products.QuerySet.QuerySet, line 114, in manage_afterAdd
g.. Module Products.Query.Query, line 80, in manage_addQuery
  AttributeError: Destination
 
 This error is obviously coming from your own source code, and since I  
 don't see that code I can't help.
 
 jens
 
 
 -BEGIN PGP SIGNATURE-
 Version: GnuPG v1.4.1 (Darwin)
 
 iD8DBQFE0fSzRAx5nvEhZLIRAoYGAJ9Ic5o/B0SQoe0k459Lre37f0qwVQCdGXhV
 R9oDTi32WNJNhrIYUidfBSI=
 =diJA
 -END PGP SIGNATURE-
 ___
 Zope maillist  -  Zope@zope.org
 http://mail.zope.org/mailman/listinfo/zope
 **   No cross posts or HTML encoding!  **
 (Related lists - 
  http://mail.zope.org/mailman/listinfo/zope-announce
  http://mail.zope.org/mailman/listinfo/zope-dev )
 
___
Zope maillist  -  Zope@zope.org
http://mail.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists - 
 http://mail.zope.org/mailman/listinfo/zope-announce
 http://mail.zope.org/mailman/listinfo/zope-dev )


Re: [Zope] adding product-based objects programmatically

2006-08-03 Thread Dieter Maurer
Kees de Brabander wrote at 2006-8-3 16:25 +0200:
Huh? I included the relevant portions of my source code in my message:

Module QuerySet.py:
from Query import manage_addQuery
class QuerySet(Folder):
def __init__(self, id, title):
self.id = id
self.title = title
self.manage_addUserFolder()

def manage_afterAdd(self, item, container):
manage_addQuery(self, id, title)

manage_addQuery in Query.py looks like:
def manage_addQuery(dispatcher, id, title, REQUEST=None):

nQ=Query(id,title)
dispatcher.Destination()._setObject(id, nQ)

Apparently, dispatcher lacks a Destination method.

Why are you using it?
Usually dispatcher._setObject is enough.



-- 
Dieter
___
Zope maillist  -  Zope@zope.org
http://mail.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists - 
 http://mail.zope.org/mailman/listinfo/zope-announce
 http://mail.zope.org/mailman/listinfo/zope-dev )


Re: [Zope] adding product-based objects programmatically

2006-08-03 Thread Kees de Brabander

- Original Message - 
From: Dieter Maurer [EMAIL PROTECTED]
To: Kees de Brabander [EMAIL PROTECTED]
Cc: Jens Vagelpohl [EMAIL PROTECTED]; [Zope] Mailing List
zope@zope.org
Sent: Thursday, August 03, 2006 7:04 PM
Subject: Re: [Zope] adding product-based objects programmatically


 Kees de Brabander wrote at 2006-8-3 16:25 +0200:
 Huh? I included the relevant portions of my source code in my message:
 
 Module QuerySet.py:
 from Query import manage_addQuery
 class QuerySet(Folder):
 def __init__(self, id, title):
 self.id = id
 self.title = title
 self.manage_addUserFolder()
 
 def manage_afterAdd(self, item, container):
 manage_addQuery(self, id, title)
 
 manage_addQuery in Query.py looks like:
 def manage_addQuery(dispatcher, id, title, REQUEST=None):
 
 nQ=Query(id,title)
 dispatcher.Destination()._setObject(id, nQ)

 Apparently, dispatcher lacks a Destination method.

 Why are you using it?
 Usually dispatcher._setObject is enough.

I must confess that I copied it from an example (don't know which anymore).
Thanks anyway, problem solved, even when done in the __init__ of Queryset.
Would manage_afterAdd a more sensible place for it?

cb

___
Zope maillist  -  Zope@zope.org
http://mail.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists - 
 http://mail.zope.org/mailman/listinfo/zope-announce
 http://mail.zope.org/mailman/listinfo/zope-dev )


Re: [Zope] adding product-based objects programmatically

2006-08-03 Thread Kees de Brabander
 manage_addQuery in Query.py looks like:
 def manage_addQuery(dispatcher, id, title, REQUEST=None):
 
 nQ=Query(id,title)
 dispatcher.Destination()._setObject(id, nQ)

 Apparently, dispatcher lacks a Destination method.

 Why are you using it?
 Usually dispatcher._setObject is enough.

I remembered and checked: it was taken from the Zope Developer's Guide 2.4
edition on zope.org!!

___
Zope maillist  -  Zope@zope.org
http://mail.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists - 
 http://mail.zope.org/mailman/listinfo/zope-announce
 http://mail.zope.org/mailman/listinfo/zope-dev )


Re: [Zope] adding product-based objects programmatically

2006-08-03 Thread Gabriel Genellina

At Thursday 3/8/2006 15:51, Kees de Brabander wrote:


 dispatcher.Destination()._setObject(id, nQ)

I remembered and checked: it was taken from the Zope Developer's Guide 2.4
edition on zope.org!!


I would delete that from zope.org site.
It's far too old and outdated, and confuses people.



Gabriel Genellina
Softlab SRL 






__
Preguntá. Respondé. Descubrí.
Todo lo que querías saber, y lo que ni imaginabas,
está en Yahoo! Respuestas (Beta).
¡Probalo ya! 
http://www.yahoo.com.ar/respuestas


___
Zope maillist  -  Zope@zope.org
http://mail.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists - 
http://mail.zope.org/mailman/listinfo/zope-announce

http://mail.zope.org/mailman/listinfo/zope-dev )


Re: [Zope] adding product-based objects programmatically

2006-08-02 Thread Jens Vagelpohl

-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1


On 2 Aug 2006, at 06:37, Kees de Brabander wrote:


Hi,
Apparently my knowledge of Zope/Python is still to limited.
I have a product that derives from Folder. When I add this product  
to a

folder via zmi I want to have it populated with other products to it
programmatically. I tried to do so in the __init__ function. That  
works with

objects like acl_user folders, but not with products in the products
directory. Can anyone send me in the right direction or at least  
give a hint

where to look for a solution?


Do not do this in __init__ as you have no acquisition at that point.  
Use manage_afterAdd for that.


jens


-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.1 (Darwin)

iD8DBQFE0IPZRAx5nvEhZLIRAhR3AJ9dWgX2g9oCnmYGZZ78ifk8JapawACcD7IH
rP10ndkIi7DeBIX26taDPhs=
=m63H
-END PGP SIGNATURE-
___
Zope maillist  -  Zope@zope.org
http://mail.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists - 
http://mail.zope.org/mailman/listinfo/zope-announce

http://mail.zope.org/mailman/listinfo/zope-dev )