[Zope] Zope obj naming vs python obj naming.

Brian Lloyd Brian@digicool.com
Mon, 28 Jun 1999 10:10:21 -0400


> I came up against a situation just now whereby I had several 
> folders in zope
> named with prefixes 7_1Load  
> I believe it is illigal in python to have an object name start with an
> integer. So when I tried to access my folder by name in an 
> external method I
> got an error. Is there another way of accessing the object in 
> python? If not
> shouldn't python naming restrictions be applied to zope 
> objects otherwise
> there is no guarentee that an external method will work with 
> all objects.
> 
> ps. The line I was using in the external method was 
> "eval('self.'+id)" or
> something similar. I also tried getattr


Object naming in Zope plays by slightly different rules than
Python naming, by necessity. We have had customers, for example,
that _hate_ the _html naming convention and wanted badly to use
.htm, .html etc. names. There are also concessions made in the
name of supporting things like FTP and WebDAV - in these cases,
Zope really needs to be willing to accept names that occur in
real world file names (~files, etc.).

So, the short answer is that when working with Zope objects
from an external method, you should always use getattr() or
Zope-provided API methods like objectValues. 'eval' constructs
should be avoided. You say above that you tried getattr() - 
can you tell me how this failed (the traceback)? That should
work for any name, no matter how illegal the name is in Python...



Brian Lloyd        brian@digicool.com
Software Engineer  540.371.6909              
Digital Creations  http://www.digicool.com