Jorey Bump
list at joreybump.com
Thu May 25 20:54:17 EDT 2006
David Bear wrote: >> def index(req): >> return "\n".join(["object name is %s " % (i,) for i in dir(req)]) Did you try this? It's very simple and should work. > I attempted a reformulation > of my original script. It still generates the 404 error. How did you access it? Show the URL you used. If you are using AddHandler, try: http://host/directory/tddb.py/index Remember to include the directory. Your original post did not, and your other message indicated that you have the module in a directory called test. This would rightly return a 404 error. > from mod_python import session > > page1 = ''' > <html> > <head> > <title>page 1 </title> > </head> > <body> > this is page 1 boo > </body> > </html> > ''' > > def index(req): > return page1 > > def info(req): > res = [] > thereq = dir(req) > for i in thereq: > res.append(i) > return("%s " % res) If your module needs reworking, you'll know it from the debug output. But you're not there yet, and I fear you're troubleshooting in the wrong place. A 404 error is a simple thing to correct, although Publisher can introduce quirks that may have us chasing a red herring. You need to get output from your published module, so create one that is really simple and get it to work: def eggs(): return "eggs" Create this as spam.py in the directory you have mod_python.publisher configured as the handler (we'll assume it's called test) and access like this: http://host/test/spam.py/eggs Get that to work, and the rest will come easily. > this is good advice. However, the best example code available at > modpython.org is at http://modpython.org/examples/ using publisher > and psp. I would love more example code to learn from. But it seem > rather scarce. There are no books at amazon about modpython. googling > for it almost always yields pages that use addons like vampire, > django, or other templating systems. > > Any good sources for information on publisher? A good book on Publisher would be only a few pages long. Examples are scarce because mod_python is extremely flexible, allowing programmers to write code according to their own style. I write Python apps in an almost purely functional style, for example, and that wouldn't appeal to someone who prefers an object oriented approach. I've also created my own templating and utility libraries, so my code wouldn't make much sense without access to those. But that's just a testament to how productive you can be, as soon as you understand mod_python enough to leverage the power of Python, which is it's primary focus. Take it slowly, read the short manual a few times, and keep a good Python reference at hand.
|