Defining classes in scripts in Zope 2.7, examples are broken
What is the new convention for creating classes in scripts? Is it disallowed now? The examples (File Library, Guest Book) define exception classes in their add/upload scripts, which results in an error on Zope2.7b3 Win32. Thanks. Error Type: NameError Error Value: global name '__name__' is not defined """Create a guest book entry. """ class LimitExceeded(Exception): """raised when too many entries are submitted""" entries_folder=container.Entries # create up-to 5 unique entry ids, a real app might not impose such a # small limit, but we do because this is just an example after all n=len(entries_folder.objectIds()) if n > 4: raise LimitExceeded, "limit on number of entries (5) exceeded" id='entry_%d' % n
Jeff Kowalczyk wrote:
What is the new convention for creating classes in scripts? Is it disallowed now?
Nope, but there's a bug in 2.7b3 that's fixed in CVS. It involves giving the Script globals a '__name__' entry. Cheers, Evan @ 4-am
Please file a collector issue. <http://zope.org/Collectors/Zope> Stefan --On Freitag, 19. Dezember 2003 12:44 -0500 Jeff Kowalczyk <jtk@yahoo.com> wrote:
What is the new convention for creating classes in scripts? Is it disallowed now?
The examples (File Library, Guest Book) define exception classes in their add/upload scripts, which results in an error on Zope2.7b3 Win32.
Thanks.
Error Type: NameError Error Value: global name '__name__' is not defined
"""Create a guest book entry. """ class LimitExceeded(Exception): """raised when too many entries are submitted"""
entries_folder=container.Entries
# create up-to 5 unique entry ids, a real app might not impose such a # small limit, but we do because this is just an example after all n=len(entries_folder.objectIds()) if n > 4: raise LimitExceeded, "limit on number of entries (5) exceeded" id='entry_%d' % n
_______________________________________________ Zope maillist - Zope@zope.org http://mail.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://mail.zope.org/mailman/listinfo/zope-announce http://mail.zope.org/mailman/listinfo/zope-dev )
-- The time has come to start talking about whether the emperor is as well dressed as we are supposed to think he is. /Pete McBreen/
Stefan H. Holek wrote:
Please file a collector issue. <http://zope.org/Collectors/Zope>
or better yet, search the collector first... http://zope.org/Collectors/Zope/1074 -- Jamie Heilman http://audible.transient.net/~jamie/ "Paranoia is a disease unto itself, and may I add, the person standing next to you may not be who they appear to be, so take precaution." -Sathington Willoughby
participants (4)
-
Evan Simpson -
Jamie Heilman -
Jeff Kowalczyk -
Stefan H. Holek