Re: [Zope] referencing a folder
At 14:15 15/04/2003 +0000, you wrote:
At 15:45 2003-04-15 +0200, Marie Robichon said:
Hi,
I want to add an object via a python script, but cannot find the syntax to reference the destination folder which is in the 'Intranet' virtual root of my site The following doesn't work and I've tried various other ways, and haven't found a faq or solution anywhere. Probably something dumb again.....
newsfolder=News.FrontNews
newsfolder.manage_addProduct['EasyEditor'].addEasyNewsItem( note_id, note_title...............
Hi Marie, I think you might be missing 'context'?
newsfolder=context.News.FrontNews
no using newsfolder=context.News.FrontNews gives me an AttributeError. The script is in fact in Intranet/Test/Marie/Notes and I want to add an EasyNewsItem to Intranet/News/FrontNews (Intranet being our virtual root) so I don't think I should be using context? Marie Marie Robichon Web Task Force European Synchrotron Radiation Facility BP 220 38043 Grenoble Cedex France http://www.esrf.fr Tel: (33) 04 76 88 21 86 Fax: (33) 04 76 88 24 27
At 16:42 2003-04-15 +0200, Marie Robichon said:
At 14:15 15/04/2003 +0000, you wrote:
At 15:45 2003-04-15 +0200, Marie Robichon said:
Hi,
I want to add an object via a python script, but cannot find the syntax to reference the destination folder which is in the 'Intranet' virtual root of my site The following doesn't work and I've tried various other ways, and haven't found a faq or solution anywhere. Probably something dumb again.....
newsfolder=News.FrontNews
newsfolder.manage_addProduct['EasyEditor'].addEasyNewsItem( note_id, note_title...............
Hi Marie, I think you might be missing 'context'?
newsfolder=context.News.FrontNews
no using newsfolder=context.News.FrontNews gives me an AttributeError. The script is in fact in Intranet/Test/Marie/Notes and I want to add an EasyNewsItem to Intranet/News/FrontNews (Intranet being our virtual root) so I don't think I should be using context?
I don't know why you get an AttributeError, it's hard for me to tell. You could use container as a starting point if you like, it would work equal in your scenario. Actually what happens in your code is that the context is changed to point to News/FrontNews in dependent if you use container or context. News is actually acquired from what ever starting point you use. (Acquisition is a marvelous and confusing beast :-) You could also use (if you like to point to the FrontNews object with an URL) news=context.restrictedTraverse('/Intranet/News/FrontNews') # If the physical URL is /Intranet/News/FrontNews news.manage_addProduct['EasyEditor'].addEasyNewsItem(<id and stuff>) Best Regards, Johan Carlsson Easy Publisher Developers Team Johan Carlsson johanc@easypublisher.com Mail: Birkagatan 9 SE-113 36 Stockholm Sweden Phone +46-(0)8-31 24 94 Fax +46-(0)8-673 04 44 Mobil +46-(0)70-558 25 24 http://www.easypublisher.com
On Tue, 2003-04-15 at 07:42, Marie Robichon wrote:
At 14:15 15/04/2003 +0000, you wrote:
Hi Marie, I think you might be missing 'context'?
newsfolder=context.News.FrontNews
no using newsfolder=context.News.FrontNews gives me an AttributeError. The script is in fact in Intranet/Test/Marie/Notes and I want to add an EasyNewsItem to Intranet/News/FrontNews (Intranet being our virtual root) so I don't think I should be using context?
Might there be something else in Marie or Test called News? Try: newsfolder=context.Intranet.News.FrontNews Though it's not often necessary, it's not a bad habit to work from the common parent shared by the method and the target. It tends (IMO) to be less susceptable to acquisition surprises. HTH, Dylan
Marie Robichon wrote at 2003-4-15 16:42 +0200:
....
I think you might be missing 'context'?
newsfolder=context.News.FrontNews
no using newsfolder=context.News.FrontNews gives me an AttributeError. The script is in fact in Intranet/Test/Marie/Notes and I want to add an EasyNewsItem to Intranet/News/FrontNews (Intranet being our virtual root) so I don't think I should be using context?
When you want "News" to reference with respect to the script, your should use "container" (and not "context"). Maybe, you should read again about the difference between "container" and "context"... Dieter
participants (4)
-
Dieter Maurer -
Dylan Reinhardt -
Johan Carlsson [EasyPublisher] -
Marie Robichon