On Apr 19, 2004, at 9:35 AM, Graham Fawcett wrote: > John Miller wrote: > >> So I think the problem is the arrangement of _q_exports and import >> statments in the __init__.py files. Here's my naive guess at what it >> should be: >> qxdemo/__init__.py ---> '''_q_exports = ['links'] from qxdemo import >> links''' # entire file >> qxdemo/links.py ---> class definitions file (no quixote exports) >> qxdemo/ui/__init__.py ---> '''_q_export = ['links'] from qxdemo.ui >> import links''' # entire file > > You nailed it, John: it looks like there's a bug in qxdemo. That line > ought to read > > _q_exports = ['links'] > > Note the pluralization. Okay, I added the 's'. > >> This arrangement, however, doesn't work. Can someone suggest what the >> proper arrangement of imports and exports is (and the Publisher >> instance: 'qxdemo' or 'qxdemo/ui'?) so that the initial _q_index >> method can be found? > > I've never run the demo app, but the cgi script looks like it wants to > publish 'qxdemo.ui.links' as the root user interface. Yes, this did the trick. Thank-you! > If you fix the "_q_export" bug above, then there's no reason you > couldn't use 'qxdemo.ui' instead of "qxdemo.ui.links". But since > 'qxdemo.ui' only provides a single export ('links') and provides no > functions of its own, then you wouldn't get any functionality without > adding 'links/' to the end of your URL (as in > http://hostname/scriptpath/links/ ). So it's probably better to use the > 'qxdemo.ui.links' export as the root UI, unless you're planning to add > some non-'links' related functions at the root level. > > Mind you, that's not a bad idea; it's sometimes nice to have a > mostly-empty root namespace, so that you can add in things later that > you didn't realize you'd need: for example, maybe a StaticDirectory, > 'resources/', where you could put style sheets or graphics, a 'doc/' > URL > that could publish help files, etc. Having a "clean root" means you > could add this stuff without having to clutter up the original 'links' > code. Okay, this explanation helps a lot! My preference actually *is* to have 'qxdemo' be the root namespace. 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? (Also, I was wondering if it might be possible to use __init__.ptl files instead of __init__.py ones?) Thanks for any assistance offered! John Miller