[Zope] a couple of basic questions

Paul Winkler pw_lists at slinkp.com
Wed Jun 20 10:33:32 EDT 2007


On Wed, Jun 20, 2007 at 10:02:01AM -0400, JPenny at ykksnap-america.com wrote:
> > i tryed to call it using sql_do_something = 
> > context['db/sql_do_something'] hoping that maybe using aquisition 
> > ... i can get the script ... but i get the message that he can't 
> > find the object. 
> 
> Maybe context['db']['sql_do_something'].  I don't remember. 

Close but no cigar.  Dictionary-style item access does NOT use
acquisition:

   foo['bar']['baz'] works iff bar is in foo and baz is in bar.

Object-style attribute access DOES use acquisition:

   foo.bar.baz works if bar is in (or can be acquired by) foo, and baz
   is in (or can be acquired by) bar.

Finally, restrictedTraverse() is your friend:

   foo.restrictedTraverse('bar/baz') works like foo.bar.baz


-PW

-- 

Paul Winkler
http://www.slinkp.com


More information about the Zope mailing list