Roundup Tracker - Issues

Issue 2550675

classification
Code in lib directory not always available to schema.py
Type: crash Severity: major
Components: Web interface Versions: 1.4
process
Status: closed fixed
:
: : ber, bnordgren, schlatterbeck
Priority: :

Created on 2010-10-21 15:06 by bnordgren, last changed 2010-10-21 19:21 by schlatterbeck.

Messages
msg4170 Author: [hidden] (bnordgren) Date: 2010-10-21 15:06
In any tracker, create lib directory and file "quirky.py" containing text:

class Test:
    pass

then add "import quirky" as the first line of schema.py

roundup-admin should behave as normal, the mail gateway should behave as
normal, but the web interface now throws an error on every access.
msg4171 Author: [hidden] (ber) Date: 2010-10-21 15:24
Which error message?
msg4172 Author: [hidden] (bnordgren) Date: 2010-10-21 15:29
Cut and paste from the traceback in the web page: 

ImportError: No module named quirky	

A problem occurred while running a Python script. Here is the sequence
of function calls leading up to the error, with the most recent
(innermost) call first. The exception attributes are:

/mnt/infomaster/roundupdev/schema.py in ()
    2 import time, random
    3 from roundup import hyperdb
    4 from email.Utils import formataddr
    5 from roundup.i18n import _ 
    6 from roundup.mailer import Mailer, MessageSendError, encode_quopri, \

/usr/lib/python2.6/site-packages/roundup/instance.py in
open(self=<roundup.instance.Tracker instance>, name='admin')
  116         if self.optimize:
  117             # execute preloaded schema object
  118             exec(self.schema, vars)
      self = <roundup.instance.Tracker instance>, global schema =
undefined, vars = {'Boolean': <class 'roundup.hyperdb.Boolean'>,
'Class': <class roundup.backends.back_mysql.Class>, 'Date': <class
'roundup.hyperdb.Date'>, 'FileClass': <class
roundup.backends.back_mysql.FileClass>, 'Interval': <class
'roundup.hyperdb.Interval'>, 'IssueClass': <class
roundup.backends.back_mysql.IssueClass>, 'Link': <class
'roundup.hyperdb.Link'>, 'Multilink': <class
'roundup.hyperdb.Multilink'>, 'Number': <class
'roundup.hyperdb.Number'>, 'Password': <class
'roundup.hyperdb.Password'>, ...}
  119             if callable (self.schema_hook):
  120                 self.schema_hook(**vars)
msg4173 Author: [hidden] (bnordgren) Date: 2010-10-21 15:31
Note that the above error actually blots out line 1 of schema.py, which
is "import quirky". This may imply that the web traceback needs a little
work too.
msg4174 Author: [hidden] (bnordgren) Date: 2010-10-21 15:40
Potential workaround follows, but the real fix will be to make the
availability of code in the lib directory consistent.

Put this at the top of a schema.py which depends on code in the lib
directory: 

import os.path
import sys

libdir = os.path.join(db.config.TRACKER_HOME, 'lib')
if libdir not in sys.path :
    sys.path.insert(0,libdir)

import quirky
msg4175 Author: [hidden] (schlatterbeck) Date: 2010-10-21 19:21
Fixed in r4554, thanks for reporting!
looks like I was using your workaround for years :-)
History
Date User Action Args
2010-10-21 19:21:13schlatterbecksetstatus: new -> closed
resolution: fixed
messages: + msg4175
nosy: + schlatterbeck
2010-10-21 15:40:54bnordgrensetmessages: + msg4174
2010-10-21 15:31:38bnordgrensetmessages: + msg4173
2010-10-21 15:29:40bnordgrensetmessages: + msg4172
2010-10-21 15:24:00bersetnosy: + ber
messages: + msg4171
2010-10-21 15:06:44bnordgrencreate