Message4023

Author amak
Recipients JohnSJohnM, amak, cgroves
Date 2009-01-10.19:42:15
SpamBayes Score 0.03768465
Marked as misclassified No
Message-id <1231616537.1.0.311093522661.issue1222@psf.upfronthosting.co.za>
In-reply-to
Content
This is a mis-understanding; modjy does not recognise sub-folders of
lib-python. Modjy requires that you add dub-directories or
jars/eggs/zips to .pth files; this is documented in the modjy documentation.

I wrote up the details on that blog post you mentioned, as a comment. I
repeat those comments here.

http://jblebrun.blogspot.com/2008/10/django-on-glassfish-
via-jython.html

#6: Subdirectories of lib-python.

Initially, when Leo was developing Django-on-Jython, he adopted the
convention of adding every subdirectory of lib-python to sys.path.
However, this was not a clean solution, because it required that actual
libraries be stored two subdirectories down, e.g. "django" would be
stored in "lib-python/django/django", which was counter-intuitive.

So I adopted a different solution for modjy, which was to add only the
lib-python directory to sys.path. This means that django, for example,
would be stored directly under lib-python/django; no deeper
subdirectories required.

The reason why Leo adopted his original convention was that ".egg",
".jar" file, etc, would be also be added to sys.path, being entries in
the lib-python directory.

This was a good solution to the problem, but I thought it better to use
the standard python convention of .pth files. Listing .eggs, .jars and
.zips in .pth files was more explicit (remember "explicit is better than
implicit"), and also standard.

The .pth solution is what is explicitly stated in the modjy
documentation, so the statement "According to modjy, it added to the
python path every subdirectory of WEB-INFO/lib-python in the .war. But
it turns out, after peeking in the code, that this is not actually the
case." The actual case is what is documented, and not otherwise.

Lastly, you should not need a single .pth file for every library or
directory; you can use a single .pth file, perhaps "all.pth", which
lists every path you want added to sys.path. So all.pth could look like this

#--------------
django
Lib
doj
myproject
#--------------
History
Date User Action Args
2009-01-10 19:42:17amaksetmessageid: <1231616537.1.0.311093522661.issue1222@psf.upfronthosting.co.za>
2009-01-10 19:42:17amaksetrecipients: + amak, cgroves, JohnSJohnM
2009-01-10 19:42:17amaklinkissue1222 messages
2009-01-10 19:42:16amakcreate