[Zope] using getProperty and catching Unauthorized

Florent Guillaume fg@nuxeo.com
25 Oct 2002 21:28:46 +0200


Aaaaaaaaah so that's why!

Thanks for the explanation, I didn't know of this subtlety. Do you know
if Guido will always keep it that way BTW?

Florent

On Fri, 2002-10-25 at 21:25, Casey Duncan wrote:
> So long as the string doesn't contain a space, then it is always interned by Python:
> 
> >>> a = 'Not Found'
> >>> b = 'Not Found'
> >>> a is b
> 0
> >>> a = 'Unauthorized'
> >>> b = 'Unauthorized'
> >>> a is b
> 1
> 
> So it works if the string exception doesn't contain a space, otherwise you're hosed ;^)
> 
> -Casey
> 
> On Fri, 25 Oct 2002 20:46:32 +0200
> Florent Guillaume <fg@nuxeo.com> wrote:
> 
> > This kind of thing only works if the 'Unauthorized' string is always
> > interned, which I'm not sure is guaranteed...
> > 
> > I know I've had things like that *not* work in python scripts.
> > 
> > Florent
> > 
> > In article <20021025100215.65bc8b3e.casey@zope.com> you write:
> > > I think the following should do what you want:
> > > 
> > > for foo in bar.objectvalues()
> > >     try:
> > >         mo = foo.getProperty('menu_order', None)
> > >     except 'Unauthorized':
> > >         continue
> > >     ..do stuff..
> > 
> 
-- 
Florent Guillaume, Nuxeo (Paris, France)
+33 1 40 33 79 87  http://nuxeo.com  mailto:fg@nuxeo.com