Hi,
Whilst following the guide http://webpy.org/multiple_apps I
encountered an issue where on trying to run the python script it
encountered an exception, see traceback:
Traceback (most recent call last):
File "site.py", line 38, in <module>
delegate.run(mapping)
File "/home/damian/testing/tcms2/delegate.py", line 31, in run
web.run(handler, {})
AttributeError: 'module' object has no attribute 'run'
>From a bit of googling and looking though the source it seems that the
issue lies with the newer versions of web.py executing the
applications differently. I can't however find any suggestion on how
to do this in a newer version of web.py.
I aim to have it where each subsection of the site has a separate
python file making it easier to manage, write and expand on later. For
reference see my current files:
site.py:
#!/usr/bin/python
import web
import types
import delegate
# Sections
from sections import signup
from sections import reseller
from sections import members
from sections import main
from sections import api
from sections import admin
from sections import errors
mapping = (
("/(.*)", main.urls, main),
("/signup/(.*)", signup.urls, signup),
("/reseller/(.*)", reseller.urls, reseller),
("/members/(.*)", members.urls, members),
("/api/(.*)", api.urls, api),
("/admin/(.*)", admin.urls, admin),
("/error/(.*)", errors.urls, errors),
)
if __name__ == "__main__":
delegate.run(mapping)
delegate.py:
#!/usr/bin/python
import web
import types
def delegate_apps(mapping):
def f():
for prefix, urls, fvars in mapping:
if type(fvars) == types.ModuleType:
fvars = fvars.__dict__
if web.ctx.path.startswith(prefix):
path = web.ctx.path[len(prefix):]
web.ctx.path = path
return web.request.handle(urls, fvars)
else:
return web.notfound()
def run(mapping):
handler = delegate_apps(mapping)
web.run(handler, {})
sections/admin.py: (All modules in section are the same at the moment)
#!/usr/bin/python
urls = (
"/(.*)", "tmp",
)
class tmp:
def GET(self):
print "Not done yet"
I'm sure this is possible however I am pretty new to web.py, well to
be honest all web based programming in python. web.py so far looks
pretty ace and I hope to go with it fully but I need this
functionality for different python modules per site to work just to
make it easy enough to manage and expand.
Hope that all makes sense and someone can help!
Ta,
Damian
--
You received this message because you are subscribed to the Google Groups
"web.py" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/webpy?hl=en.