[Zope] restrictedTraverse without acquisition
R Karthick
catchkarthick at yahoo.com
Tue Jul 13 13:50:59 EDT 2004
hi!!
thank you for you reply.
Yeah it seems to be a good solution. but can't i just
switch off acquisition in restrictedTraverse, when i
need to?
regards,
R K
--- Jonathan Hobbs <toolkit at magma.ca> wrote:
> From: "R Karthick" <catchkarthick at yahoo.com>
> > i have this directory structure
> >
> > /
> > |- clients/projects/abc/batches/001
> > |- wg/projects/cba/batches/100
> >
> > now i am running a script python from 001 folder.
> now
> > i want to check whether there is any folder called
> abc
> > in wg/projects folder. i do this by a try
> statedment
> >
> > try:
> > foo =
> context.restrictedTraverse("wg/projects/abc")
> > catch:
> > ... # create the directory
> >
> > It goes into the workgroup folder. But when it
> sees
> > the project folder, through acquisition it finds
> the
> > projects folder inside clients hierarchy first and
> > finds that the folder abc is actually present.
> >
> > I want context.restrictedTraverse to behave in a
> way
> > that it acquire wg but after that projects should
> not
> > be acquired but should follow the wg.
>
> How about something like: (warning - untested)
>
> foo = context.restrictedTraverse("wg/projects")
> found = 0
> for i in foo.objectItems():
> if str(i[0]) == 'abc':
> found = 1
>
> if not found:
> ... # create the directory
>
>
> HTH
>
> Jonathan
>
>
>
=====
with "freedom" comes great responsibilities
__________________________________
Do you Yahoo!?
New and Improved Yahoo! Mail - Send 10MB messages!
http://promotions.yahoo.com/new_mail
More information about the Zope
mailing list