John Miller wrote: > Okay, this explanation helps a lot! My preference actually *is* to have > 'qxdemo' be the root namespace. I really wouldn't do that if I were you. ;-) See below. > Now I understand that if I put a > _q_index method in the toplevel __init__.py file, I can put in the links > to qxdemo/ui/links, qxdemo/ui/book, and qxdemo/ui/keywords - which will > help unify the package for me. > >> > Okay, I've reached the limits of my understanding again. It took me > awhile to realize that by publishing the root of the package (app = > Publisher('qxdemo') in the .cgi file) I needed to export the 'ui' > directory. But doing so resulted in a link that wouldn't work: quixote > reports '''Page not found: /qxdemo/ui/links''' in the browser. Here are > the relevant portions from the current setup: > > qxdemo/__init__.py ---> '''_q_exports = ['links', 'book', 'keywords', 'ui'] > from quixote.util import StaticDirectory > from qxdemo.ui.links import _q_index, links, > book, keywords > Links demo # this is > how the link looks > ui = > StaticDirectory("/Library/Python/2.3/qxdemo/ui")''' > > qxdemo/ui/__init__.py ---> '''_q_exports = ['links']''' > > Does anyone see where the problem is? First, don't publish qxdemo/ui as a StaticDirectory, unless your intent is that you want users to view/download your PTL files, rather than execute them. I'm pretty sure that in the demo, "ui" and its contents represent the user interface. The main "qxdemo" directory contains "qxedmo/ui" but it also contains the other stuff, such as the CGI script, etc. What I'm saying is, I wouldn't advise trying to publish "qxdemo" but rather "qxdemo.ui". Keep all of your PTL modules in the qxdemo/ui tree, and publish that; use the root directory only for configuration files, CGI scripts, etc. That way, you'll have a nicely organized codebase. So, I'd use Publisher('qxdemo.ui') in your CGI script, and in qxdemo/ui/__init__.py, I'd include import books, keywords _q_exports = ['links', 'books', 'keywords'] then in the qxdemo/ui/ folder I'd have books.ptl (or books.py if you don't want PTL) keywords.ptl (or keywords.py) and so on. So: all of the UI stuff (PTL files and so on) go in the "ui" tree. In the root folder, you have CGI scripts, configuration files, and what have you. Your application might also grow a "qxdemo/app" tree where you could have modules that pertain to your application, but are related to logic and not to presentation (e.g., database connection stuff, class definitions for "back-end" objects, utility functions, etc.). It's not strictly necessary; but for maintainability, testing and readability, it's nice to keep as much of your logic out of the PTL modules as possible. > > (Also, I was wondering if it might be possible to use __init__.ptl files > instead of __init__.py ones?) Not out of the box. But there's a patch for Quixote 0.6 that might still work: http://mail.mems-exchange.org/pipermail/quixote-users/2003-May/001519.html I seem to recall another patch that someone wrote, but I can't remember where I saw it. -- Graham