webapp2

Redirect Route strict slash

早过忘川 提交于 2019-12-07 16:45:56
问题 I'm trying to use strict slash with webapp2 redirect route and I'm getting this value error - ValueError: Routes with strict_slash must have a name. This is an example of one of my routes - RedirectRoute(r'/',handler=IndexHandler,strict_slash=True) It works fine if I don't have the strict_slash bit. 回答1: I don't know why routes with a strict_slash need to have a name, but the following should work: RedirectRoute(r'/',handler=IndexHandler,strict_slash=True,name='some_name') 来源: https:/

Best practices for storing passwords in GAE/python

核能气质少年 提交于 2019-12-07 15:36:13
问题 I need to implement password storage in my GAE/python2.7 app. I've already implemented cookies for authorization, I already have a Account/user model, and I already have authentication via 3rd parties. Now I need to add authentication via password (a customer request). I want the passwords to be stored securely. I've identified a couple of options (below), that seem sensible, but I've never implemented password storage before, so I dont know what I dont know. I'd rather avoid a problem than

webapp2 - How to reverse URL in templates?

人盡茶涼 提交于 2019-12-07 06:30:34
问题 I'm starting with webapp2. My english is not very good, so i'll use an example to explain my problem: Suppose i'm building an application that will handle cars information. I've these handlers: ViewHandler: will display a view for a single car, with all of its information (engine, year, brand, model, etc..) ListHandler: will display all the cars in the application, with a link to the view page. The problem is that i can't build that link to the single view. I could do this in the template:

Google App Engine Python Webapp2 301 redirect from www to non-www domain

天涯浪子 提交于 2019-12-06 20:40:29
I have an application built on gae. I use python with webapp2 framework. I need to make 301 redirect from www.my-crazy-domain.com to my-crazy.domain.com so to eliminate www and not-www doubles in search results. Does anybody have ready-to-use solution? Thanks for any help! I'v made the trick. class BaseController(webapp2.RequestHandler): """ Base controller, all contollers in my cms extends it """ def initialize(self, request, response): super(BaseController, self).initialize(request, response) if request.host_url != config.host_full: # get request params without domain url = request.url

How to get uri_for with webapp2 in unit test?

梦想与她 提交于 2019-12-06 20:17:25
问题 I'm trying to unit test a handler with webapp2 and am running into what has to be just a stupid little error. I'd like to be able to use webapp2.uri_for in the test, but I can't seem to do that: def test_returns_200_on_home_page(self): response = main.app.get_response(webapp2.uri_for('index')) self.assertEqual(200, response.status_int) If I just do main.app.get_response('/') it works just fine. The exception received is: Traceback (most recent call last): File "/Library/Frameworks/Python

Error in deployed GAE RequestHandler using Webapp2

China☆狼群 提交于 2019-12-06 15:53:11
I am using the webapp2 framework on Google App Engine, and I'm getting a basic error in one of my Request Handlers. The app is running ok in the local instance, but causes the following traceback on the deployed version of Google App Engine: Here's the code: import os from google.appengine.ext.webapp import template import webapp2 import logging class MainHandler(webapp2.RequestHandler): def get(self): logging.info('hi there 34') template_values = {} self.response.out.write('hello world 4') path = os.path.join(os.path.dirname(__file__), 'index.html') ## This is the code that causes the bug ##

Best practices for storing passwords in GAE/python

萝らか妹 提交于 2019-12-06 03:50:36
I need to implement password storage in my GAE/python2.7 app. I've already implemented cookies for authorization, I already have a Account/user model, and I already have authentication via 3rd parties. Now I need to add authentication via password (a customer request). I want the passwords to be stored securely. I've identified a couple of options (below), that seem sensible, but I've never implemented password storage before, so I dont know what I dont know. I'd rather avoid a problem than wait for a problem. My question is: is this best practice for GAE? If not, what is? Note that I'm only

Can't get POST parameters

荒凉一梦 提交于 2019-12-06 03:46:58
I'm developing a web app in Python using WebApp2 as framework. I can't get the http POST request parameters submitted by filling a form. That's the HTML code of the form I created <html> <head> <title>Normal Login Page </title> </head> <body> <form method="post" action="/loginN/" enctype="text/plain" > eMail: <input type="text" name="eMail"><br/> password: <input type="text" name="pwd"><br/> <input type="submit"> </form> </body> That's the result of the POST request after pressing the submit button POST /loginN/ HTTP/1.1 Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,

Redirect Route strict slash

僤鯓⒐⒋嵵緔 提交于 2019-12-05 20:36:44
I'm trying to use strict slash with webapp2 redirect route and I'm getting this value error - ValueError: Routes with strict_slash must have a name. This is an example of one of my routes - RedirectRoute(r'/',handler=IndexHandler,strict_slash=True) It works fine if I don't have the strict_slash bit. I don't know why routes with a strict_slash need to have a name, but the following should work: RedirectRoute(r'/',handler=IndexHandler,strict_slash=True,name='some_name') 来源: https://stackoverflow.com/questions/15180210/redirect-route-strict-slash

getting TypeError, “not indexable” upon execution of if self.request.POST['file'] inside post method of webapp2.RequestHandler

 ̄綄美尐妖づ 提交于 2019-12-05 18:13:17
I am trying to upload a file using this code: <form id="form1" action="convert" enctype="multipart/form-data" method="post"> <input type="file" name="file"/> <div><input id="submit_button" type="submit" value="Upload"/></div> </form> class Convert(RequestHandler): @login_required def post(self): session = Session(writer="cookie", session_expire_time = 3600, set_cookie_expires = True) if session['id']: file = self.request.POST['file'] if file and file.type and file.value: but I keep on getting this error: if file and file.type and file.value: File "C:\Python25\lib\cgi.py", line 633, in __len__