[Zope] Invalide syntax on (of all things) def initialize(context):

Dieter Maurer dieter@handshake.de
Thu, 23 Aug 2001 22:29:02 +0200 (CEST)


complaw@hal-pc.org writes:
 > As impossible as it seems, my Zope 2-3-1 had the temerity to say this 
 > __init__.py....
 > 
 > import Doctrine
 > 
 > def initialize(context):
 >         """Initialize the Legal Doctrine Product."""
 > 	
 >         context.registerClass(
 >                 Doctrine.Doctrine,
 >                 constructors = (
 >                         Doctrine.manage_addDoctrineForm,
 >                         Doctrine.manage_addDoctrine
 >                 ),
 > 		icon = 'images/Doctrine.jpg'
 >         )
 > 
 > 
 > ... gave me this...
 > 
 > Import Traceback
 > 
 > Traceback (innermost last):
 >   File "/usr/local/zope/2-3-1/lib/python/OFS/Application.py", line 536, in 
 > import_products
 >     product=__import__(pname, global_dict, global_dict, silly)
 >   File "/usr/local/zope/2-3-1/lib/python/Products/LegalDoctrine/__init__.py", 
 > line 3
 >      def initialize(context):
 >      ^
 >  SyntaxError: invalid syntax
 > 
 > 
 > I've seen def initialize(context): done for several different Zope products.  
 > Does my instance of Zope just not like me?  Someone please tell me that I'm not 
 > crazy.
You are (probably) not crazy!

Sometimes, Zope betrays you...

  It shows you an old traceback in the Product folder.

  I have been hit by this, too, and chased the apparent problem
  for several hours...

  The solution:
  
    activate Zope logging mechanism by providing a parameter
    "STUPID_LOG_FILE=yourlog" to "z2.py".

    Restart Zope and look into "yourlog".
    It should tell you the real problem.

    Once this real problem is solved, the old traceback will
    disappear...


Dieter