Fabiano Sidler
fabianosidler at gmail.com
Fri Jan 13 19:54:43 EST 2006
2006/1/13, Graham Dumpleton <grahamd at dscpl.com.au>: > Unfortunately your email doesn't really provide that much to go on. Sorry for that! But meanwhile I located the problem: --- testwebapp.py --- from container import WebApp, Request class MyWebApp(WebApp): title='My WebApplication' def run(): Request.setContentType('text/html') Request.write('Foobar!') --- container.py --- class WebAppMeta(type): def __new__(cls, name, bases, d): from types import FunctionType as Function for i in d: if type(d[i]) is Function: d[i] = staticmethod(d[i]) loadmodule(cls.__module__, cls) return super(WebAppMeta, cls).__new__(cls, name, bases, d) class WebApp: __metaclass__=WebAppMeta def someBasicFooBarMethods(): pass def loadmodule(mod, cls): from mod_python import apache class Request: pass def handler(req): Request.write = staticmethod(req.write) cls.run() return apache.OK mod.Request = Request mod.handler = handler The interesting[tm] thing now is that on creation of the testwebapp.MyWebApp class, loadmodule()'s mod argument is container instead of my assumption, in which it was testwebapp. As the consequence, the name testwebapp.handler is not set and mod_python delivers the script code to the client, annoyingly without any message to the logs! Is there a way to achieve what I wanted to do, or will I have to change my whole app design? As I posted earlier, I'm doing a server-independent interface for writing webapps and its specification is already made. I would dislike beginning from 0. Thank you lots for your help! Greetings, Fips
|