problem with superValues
Hi, Im trying to send an E-Mail within an external python script each time an object is edited. Therefor I use superValues to locate the MailHost object. mailhost=getattr(self, self.superValues('Mail Host')[0].id) If the object that sends the mail already exists anything goes fine. But if the object is edited for the first time (via the __init__ procedure that calls the edit procedure) superValues can't find the MailHost object (IndexError: list index out of range). Any ideas what's going wrong? MfG Steffen -- That you're not paranoid doesn't mean they aren't right behind you.
during __init__ your object has no acquisition content. you cannot use acquisition at that point in time. jens On Friday, Mar 7, 2003, at 14:12 US/Eastern, Steffen Hausmann wrote:
Hi,
Im trying to send an E-Mail within an external python script each time an object is edited. Therefor I use superValues to locate the MailHost object.
mailhost=getattr(self, self.superValues('Mail Host')[0].id)
If the object that sends the mail already exists anything goes fine.
But if the object is edited for the first time (via the __init__ procedure that calls the edit procedure) superValues can't find the MailHost object (IndexError: list index out of range).
Any ideas what's going wrong?
MfG Steffen
Wrap your code into manage_afterAdd() -aj --On Freitag, 7. März 2003 14:20 -0500 Jens Vagelpohl <jens@zope.com> wrote:
during __init__ your object has no acquisition content. you cannot use acquisition at that point in time.
jens
On Friday, Mar 7, 2003, at 14:12 US/Eastern, Steffen Hausmann wrote:
Hi,
Im trying to send an E-Mail within an external python script each time an object is edited. Therefor I use superValues to locate the MailHost object.
mailhost=getattr(self, self.superValues('Mail Host')[0].id)
If the object that sends the mail already exists anything goes fine.
But if the object is edited for the first time (via the __init__ procedure that calls the edit procedure) superValues can't find the MailHost object (IndexError: list index out of range).
Any ideas what's going wrong?
MfG Steffen
_______________________________________________ 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 )
-- --------------------------------------------------------------------- - Andreas Jung http://www.andreas-jung.com - - EMail: andreas at andreas-jung.com - - "Life is too short to (re)write parsers" - ---------------------------------------------------------------------
On Fri, Mar 07, 2003 at 08:28:25PM +0100, Andreas Jung wrote:
Wrap your code into manage_afterAdd()
Now it works. Thanks a lot.
--On Freitag, 7. März 2003 14:20 -0500 Jens Vagelpohl <jens@zope.com> wrote:
during __init__ your object has no acquisition content. you cannot use acquisition at that point in time.
MfG Steffen -- That you're not paranoid doesn't mean they aren't right behind you.
On Fri, Mar 07, 2003 at 02:20:37PM -0500, Jens Vagelpohl wrote:
during __init__ your object has no acquisition content. you cannot use acquisition at that point in time.
How can I check (without raising an error) whether an object has an acquisition context or not. MfG Steffen -- That you're not paranoid doesn't mean they aren't right behind you.
--On Samstag, 8. März 2003 17:00 +0100 Steffen Hausmann <steffen@hausmann-family.de> wrote:
On Fri, Mar 07, 2003 at 02:20:37PM -0500, Jens Vagelpohl wrote:
during __init__ your object has no acquisition content. you cannot use acquisition at that point in time.
How can I check (without raising an error) whether an object has an acquisition context or not.
There is no reason to check for the acquisition context. As Jens wrote, the context is not available during __init__(). That's a fact. To perform post-__init__() actions *inside* the acquisition context, you should define your own manage_afterAdd() method. -aj
On Sat, Mar 08, 2003 at 06:32:18PM +0100, Andreas Jung wrote:
<steffen@hausmann-family.de> wrote:
How can I check (without raising an error) whether an object has an acquisition context or not.
There is no reason to check for the acquisition context. As Jens wrote, the context is not available during __init__(). That's a fact. To perform post-__init__() actions *inside* the acquisition context, you should define your own manage_afterAdd() method.
The problem I had when I started this post is already solved, but it occured another problem that makes it necessary to know whether an object has an acquisition context or not (I should have mentioned that in my last post). MfG Steffen -- That you're not paranoid doesn't mean they aren't right behind you.
Greetings. I am learning zope and have made my first working product to track people, however I want to use PageTemplates instead of DTML. Here is an example in my code: class Person: ... ... index_html = DTMLFile('www/index_html', globals()) ... ... right there, I want to use a page template for index_html instead of a DTML file, how can I do that? Thanks, Jeremy
from Products.PageTemplates.PageTemplateFile import PageTemplateFile then Index_html = PageTemplateFile('www/index_html', globals()) will do the job assuming you have got a file called index_html.zpt in www. I think index_html.pt also works. A On 8/3/03 9:00 pm, "Jeremy Cowgar" <jc@cowgar.com> wrote:
I am learning zope and have made my first working product to track people, however I want to use PageTemplates instead of DTML. Here is an example in my code:
class Person: ... ... index_html = DTMLFile('www/index_html', globals()) ... ...
right there, I want to use a page template for index_html instead of a DTML file, how can I do that?
I am learning zope and have made my first working product to track people, however I want to use PageTemplates instead of DTML.
I remember posting this not too long ago: Create Management Screens with ZPT http://www.zope.org/Members/Zen/howto/ZPT_management --jcc
superValues will only work after you have _setObject'ed your new object. There is normally no acquisition context available during __init__. Your factory method should look something like this: ob = MyClass('foo') self._setObject('foo', ob) self._getOb('foo').edit() HTH, Stefan --On Freitag, 07. März 2003 20:12 +0100 Steffen Hausmann <steffen@hausmann-family.de> wrote:
Im trying to send an E-Mail within an external python script each time an object is edited. Therefor I use superValues to locate the MailHost object.
mailhost=getattr(self, self.superValues('Mail Host')[0].id)
If the object that sends the mail already exists anything goes fine.
But if the object is edited for the first time (via the __init__ procedure that calls the edit procedure) superValues can't find the MailHost object (IndexError: list index out of range).
-- Those who write software only for pay should go hurt some other field. /Erik Naggum/
participants (7)
-
Andreas Jung -
Andrew Veitch -
J Cameron Cooper -
Jens Vagelpohl -
Jeremy Cowgar -
Stefan H. Holek -
Steffen Hausmann