[CPS-devel] can call script via url but not from script

Joachim Schmitz js at aixtraware.de
Fri Nov 10 10:35:51 CET 2006


Santi Camps schrieb:
> On 11/9/06, Joachim Schmitz <js at aixtraware.de> wrote:
>> In the port_root I have a ProxyFolder campus of portal_type University.
>> In the University-Class I defined a routine to get a certain value.
>>
>> when I call this via the browser-url like so:
>>
>> http://www.test.de/srp/campus/getHallTitle?hall=xxx
>>
>> the correct title is returned.
>>
>> but when I call it in a script:
>>
>> context.portal_url.getPortalObject().campus.getHallTitle("xxx")
>>
>> I get an attribute error "getHallTitle"
>>
>> this works also in a script:
>>
> 
> This is because your "campus" object is really a CPS Proxy,
> referencing a really campus object existing in the portal_repository
> (named the "Content").   So, the proxy object doesn't have the
> getHallTitle method, but the content object have.
> 
> A __getitem__ method exists in the proxies to do some magic, so your
> call http://www.test.de/srp/campus/getHallTitle?hall=xxx works.   To
> do the same in a script, you can use either:
> 
> context.portal_url.getPortalObject().campus['getHallTitle']("xxx")
> 
> or
> 
> content = context.portal_url.getPortalObject().campus.getContent()
> content.getHallTitle("xxx")
> 
> That's no difference between them, but the second option is a cheaper
> operation if you need to call more methods or attributes.
> 
there a slight but important difference, the first one works, and the 
second one throws an Unauthorized Exeption for getContent.



-- 
Mit freundlichen Grüßen                                Joachim Schmitz
......................................................................
AixtraWare eK ..Joachim Schmitz ..www.aixtraware.de ..t: +49-2464-8851
Hüsgenstr. 33a .....d-52457 Aldenhoven .............f: +49-2464-905163





This list archive provided by Nuxeo, the leaders of open source ECM. Check out the Nuxeo 5 open source, standards-based ECM project.