Thanks!
On Jan 26, 8:59 pm, Justin Davis <[email protected]> wrote: > In your regular expression, there is a grouping -- anything wrapped in > parentheses becomes a group. webpy calls your get method with that > passed as an argument, so you need to update your GET prototype to > look like: > > def GET(self, arg1): > > Then you can use that argument in your code. This is handy for > something like: > > urls = > '/get_widget/(.+)', 'GetWidget' > ) > > and then you can do something like: > > class GetWidget: > def GET(self, widget_id): > widget = db.select('widgets', where="id=$widget_id", vars=locals()) > [0] > return render.get_widget(widget) > > Hope this helps. > > -Justin > > On Jan 26, 2:36 pm, Giovanni <[email protected]> wrote: > > > > > > > > > I'm trying to match DOIs in the requests and I have some problems. > > > My code is the following. > > > I have a simple (generic and not complete) regular expression for the > > DOIs: > > urls = ( > > '/(doi\:)?10\.[0-9]{4}\/.*','doi', > > ) > > > class doi(object): > > """Class that takes care of a DOI""" > > def __init__(self): > > """ Constructor""" > > pass > > def GET(self): > > """manager of the get requests""" > > print 'doi' > > > but this code gives me an error if I call my server with the > > URLhttp://localhost:8000/10.1088/0004-637X/726/2 > > > the error is the following: > > > - - [26/Jan/2011 17:00:19] "HTTP/1.1 GET /101088" - 500 Internal > > Server Error > > Traceback (most recent call last): > > File "/opt/local/Library/Frameworks/Python.framework/Versions/2.5/ > > lib/python2.5/site-packages/web/application.py", line 242, in process > > return self.handle() > > File "/opt/local/Library/Frameworks/Python.framework/Versions/2.5/ > > lib/python2.5/site-packages/web/application.py", line 233, in handle > > return self._delegate(fn, self.fvars, args) > > File "/opt/local/Library/Frameworks/Python.framework/Versions/2.5/ > > lib/python2.5/site-packages/web/application.py", line 415, in > > _delegate > > return handle_class(cls) > > File "/opt/local/Library/Frameworks/Python.framework/Versions/2.5/ > > lib/python2.5/site-packages/web/application.py", line 390, in > > handle_class > > return tocall(*args) > > TypeError: GET() takes exactly 1 argument (2 given) > > > I'm running python code on Mac OS X 10.5.8 with python 2.5 (port > > version). > > > What's wrong with my code? > > I think the problem is in the regular expression, but I cannot figure > > out what it is. > > > Thanks in advance! -- 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.
