durusmail: quixote-users: Re: import and export - help!
import and export - help!
2004-04-18
Re: import and export - help!
2004-04-19
2004-04-20
2004-04-20
2004-04-20
2004-04-20
2004-04-21
2004-04-21
Jason E. Sibre (2 parts)
2004-04-21
Re: import and export - help! (resolved)
2004-04-21
2004-04-20
2004-04-20
Re: import and export - help!
Jason E. Sibre
2004-04-21
> If only it were so simple! Well, I tried exactly this, and it didn't
> work, and I cannot figure out why. From the top, this is what I have:
>
> 1. qxdemo.cgi ---> app = Publisher('qxdemo.ui') # only relevant lines
> shown
>
> 2. qxdemo/ui/__init__.py ---> _q_exports = ['foo']
>                                from qxdemo.ui import foo
>
> 3. qxdemo/ui/foo/__init__.py ---> _q_exports = ['bar']
>
> 4. qxdemo/ui/foo/bar.ptl ---> _q_exports = ['run']
>                                def run [html] (request):
>                                    "This is the run method."
>
> When I go to http://server/qxdemo/foo/bar/run I get the following error
> message in the browser window: '''Page not found: /qxdemo/foo/bar/run:
> None has no _q_exports list.'''
>
> I had earlier tried it without importing 'foo' in qxdemo/ui/__init__.py
> but that led to a different error message: '''ImportError: No module
> named foo''' which is why I added it to the import line. An alternative
> way of getting 'foo' into the namespace I tried was to add it as a
> StaticDirectory, but Graham showed how that was poor practice for
> interface files (and besides, it didn't work!) Any ideas what is
> missing?

Hmm... It took me a while to duplicate your setup, but I did, and it's
working for me...  Um...  Have you checked the permissions of the files and
dirs that you added?  That '''ImportError: No module named foo''' sounds
quite a bit like the errors I get when I forget to do a 'chmod' on a newly
added module.

I duplicated your setup (but omitted the 'from qxdemo.ui import foo') on
step 2, and I get the page as expected.  The url I used to get there was
"http://sibre.org/cgi-bin/qxdemorun.py/foo/bar/run"

Another thought: Looking at your message again, I see '''Page not found:
/qxdemo/foo/bar/run: None has no _q_exports list.'''
There are two questions that pop into my head:

1. "/qxdemo/foo/bar/run"...  Is qxdemo the cgi driver script?  (qxdemorun.py
in my url?)  If not, maybe you just have a bad url in the browser (similar
to my first effort of /links/foo/bar/run, before I noticed the glitch!)

2. "None has no _q_exports list"...  None?  That's odd, and with the
absolute path implied by "from qxdemo.ui import foo", when you're in
qxdemo.ui... Could this be a result of an import loop/deadlock?  I don't
know.  I haven't had any problems with that in a quite a while (since I
first started with Qx and learned how NOT to arrange my packages!), and I've
forgotten the symptoms.  I don't think you can get yourself in a loop that
easily, though.

I will say, "You don't need that import in step 2."

I'm attaching the version of qxdemo that I was left with after confirming it
worked, in case you wanna run diffs or something.

> I do appreciate your help in trying to troubleshoot the issue. I know
> that the principles involved are (seemingly) simple, but for some
> reason I can't get the 'foo' subdirectory to be seen by quixote. If
> anyone has any ideas of what to try, I'll be glad to experiment.

No sweat.  I think Quixote is appealing because of it's elegant simplicity.
Consequently, it's sometimes surprising how subtle little details can bite
you in a big way.  I'm not sure if this is because Qx is still a little
rough around the edges, or if it's because the core developers did such a
good job of making things appear simple, when they really aren't...  Either
way, as simple as it looks, there's a LOT of room for complexity in Quixote!

Keep us posted!

Jason


reply