Python Path Manipulation
I am using GAE and webapp2 to create a simple PM application. This is part of my code for adding a task, associated to my project. class AddTask(webapp2.RedirectHandler): def
Solution 1:
You shouldn't be trying to extract parameters by splitting URLs. You should let the webapp2 route matcher do the work, and pass the parameters to your handler.
The documentation is fairly comprehensive, but to summarise for your case:
classAddTask(webapp2.RedirectHandler):
defget(self, project_id):
project = Project.get_by_id(int(project_id))
app = webapp2.WSGIApplication([
...
(r'/projects/(\d+)/tasks/add', AddTask),
])
Post a Comment for "Python Path Manipulation"