import web
urls = (
'/(.*)', 'hello'
)
class hello:
def GET(self, name):
i = web.input(times=1)
if not name: name = 'world'
for c in xrange(int(i.times)): print 'Hello,', name+'!'
application = web.wsgifunc(web.webpyfunc(urls, globals()))
and tried as suggested in roadmap:
application = web.application(urls, globals())
always got this error:
AttributeError: application instance has no __call__ method
mod_wsgi (pid=31745): Exception occurred within WSGI script
Anand... have an idea?
I think that should be:
application = web.application(urls, globals()).wsgifunc()
Presuming that that is the correct way for 0.3, have updated:
http://code.google.com/p/modwsgi/wiki/IntegrationWithWebPy
Someone may want to also update:
if it has indeed changed.
Graham
>
> On Oct 6, 9:54 am, Adam Atlas <a...@atlas.st> wrote:
>> On 5 Oct 2007, at 19:48, blaf wrote:
>>
>>> application = web.application(urls, globals())
>>
>> I think that should be:
>>
>> application = web.application(urls, globals()).wsgifunc()
>
> Presuming that that is the correct way for 0.3, have updated:
>
> http://code.google.com/p/modwsgi/wiki/IntegrationWithWebPy
Can you say 0.3 (development version) instead of just 0.3?
I think it is better sepearate web.application like this in the example.
import web
urls = (
'/(.*)', 'hello'
)
app = web.application(urls, globals())
class hello:
def GET(self, name):
i = web.input(times=1)
if not name: name = 'world'
for c in xrange(int(i.times)): print 'Hello,', name+'!'
application = app.wsgifunc()
Traceback (most recent call last):
File "/path/to/web/application.py", line 129, in wsgi
result = self.handle_with_processors()
File "/path/to/web/application.py", line 106, in
handle_with_processors
return process(self.processors)
File "/path/to/web/application.py", line 103, in process
return self.handle()
File "/path/to/web/application.py", line 95, in handle
return self._delegate(fn, self.fvars, args)
File "/path/to/web/application.py", line 233, in _delegate
return handle_class(cls)
File "/path/to/web/application.py", line 215, in handle_class
return tocall(*args)
File "/path/to/run-wsgi.py", line 13, in GET
for c in xrange(int(i.times)): print 'Hello,', name+'!'
IOError: sys.stdout access restricted by mod_wsgi
Thanks all!
Graham, I think you should ajust the wiki page to reflect changes
proposed by Anand.
: ("'module' object has no attribute 'loadhooks'",)
Traceback:
function in run.py at line 89
function run in application.py at line 179
function wsgifunc in application.py at line 161
function __init__ in http.py at line 181
On Oct 5, 11:15 pm, Anand <anandol...@gmail.com> wrote:
in http.py do
from application import loadhook
and in Reloader class change
web.loadhooks['reloader'] = self.check
to
loadhook(self.check)
and to load the database use:
def loaddb():
web.database(**web.config.db_parameters)
app.add_processor(web.loadhook(loaddb))
Graham
Major changes will be
* return instead of print
* moving away from globals
* better db api
And it uses return now in the dev branch.
On Oct 6, 6:50 pm, Graham Dumpleton <Graham.Dumple...@gmail.com>
wrote:
You don't need this now. New db api has been implemented.
db = web.database(dbn='postgres', db=...)
db.select
db.query
...
On Oct 6, 8:47 pm, Anand <anandol...@gmail.com> wrote:
> You don't need this now. New db api has been implemented.
>
> db = web.database(dbn='postgres', db=...)
> db.select
> db.query
> ...
Works great!
I apologize if this has been covered before. What's the thinking
behind changing print to return? Are there benefits?
-Greg