gcodeforks / webapp-improved Goto Github PK
View Code? Open in Web Editor NEWAutomatically exported from code.google.com/p/webapp-improved
License: Other
Automatically exported from code.google.com/p/webapp-improved
License: Other
webapp2 ======= webapp2 is a lightweight Python web framework compatible with Google App Engine's webapp. - Project page: http://code.google.com/p/webapp-improved/ - User guide: http://webapp-improved.appspot.com/
The following in webapp2.Request.__init__ creates erroneous results, forcing a
'; charset="utf-8"' onto all HTTP request content types which don't include a
charset. This results in Request.headers['content-type'] and
Request.environment.headers['content-type'] not accurately reflecting the HTTP
request received by the server. Additionally, it results in broken behaviour
for POST requests which have a 0 byte body gaining a completely invalid
content-type of '; charset="utf-8"', although curiously behaves differently for
a non-zero body length.
The bottom line for me is that webapp2 should not be doing anything which
breaks fidelity of the received headers — that is something for the users of
webapp2 to decide how to handle, and a default of utf-8 is incorrect. Note in
particular http://www.ietf.org/rfc/rfc2616.txt section 3.4.1 and
http://www.ietf.org/rfc/rfc2854.txt section 6:
----
3.4.1 Missing Charset
Some HTTP/1.0 software has interpreted a Content-Type header without
charset parameter incorrectly to mean "recipient should guess."
Senders wishing to defeat this behavior MAY include a charset
parameter even when the charset is ISO-8859-1 and SHOULD do so when
it is known that it will not confuse the recipient.
Unfortunately, some older HTTP/1.0 clients did not deal properly with
an explicit charset parameter. HTTP/1.1 recipients MUST respect the
charset label provided by the sender; and those user agents that have
a provision to "guess" a charset MUST use the charset from the
content-type field if they support that charset, rather than the
recipient's preference, when initially displaying a document. See
section 3.7.1.
----
6. Charset default rules
The use of an explicit charset parameter is strongly recommended.
While [MIME] specifies "The default character set, which must be
assumed in the absence of a charset parameter, is US-ASCII." [HTTP]
Section 3.7.1, defines that "media subtypes of the 'text' type are
defined to have a default charset value of 'ISO-8859-1'". Section
19.3 of [HTTP] gives additional guidelines. Using an explicit
charset parameter will help avoid confusion.
Using an explicit charset parameter also takes into account that the
overwhelming majority of deployed browsers are set to use something
else than 'ISO-8859-1' as the default; the actual default is either a
corporate character encoding or character encodings widely deployed
in a certain national or regional community. For further
considerations, please also see Section 5.2 of [HTML40].
----
The following patch fixes the problem for me, but isn't extensively tested:
diff -r a2bdc641668c webapp2.py
--- a/webapp2.py Fri Aug 26 14:32:36 2011 -0300
+++ b/webapp2.py Thu Oct 13 15:27:04 2011 +0100
@@ -120,10 +120,7 @@
match = _charset_re.search(environ.get('CONTENT_TYPE', ''))
if match:
charset = match.group(1).lower().strip().strip('"').strip()
- else:
- charset = 'utf-8'
-
- kwargs['charset'] = charset
+ kwargs['charset'] = charset
kwargs.setdefault('unicode_errors', 'ignore')
kwargs.setdefault('decode_param_names', True)
Original issue reported on code.google.com by [email protected]
on 13 Oct 2011 at 2:36
ndb 0.9.6 is part of the upcoming appengine sdk 1.6.2.
More important: it's already running online!
More information:
http://code.google.com/p/appengine-ndb-experiment/issues/detail?id=146
The reported error from the online logs:
Expected str, got {'username': u'foo'}
Traceback (most recent call last):
File "/base/python27_runtime/python27_lib/versions/third_party/webapp2-2.3/webapp2.py", line 1511, in __call__
rv = self.handle_exception(request, response, e)
File "/base/python27_runtime/python27_lib/versions/third_party/webapp2-2.3/webapp2.py", line 1505, in __call__
rv = self.router.dispatch(request, response)
File "/base/python27_runtime/python27_lib/versions/third_party/webapp2-2.3/webapp2.py", line 1253, in default_dispatcher
return route.handler_adapter(request, response)
File "/base/python27_runtime/python27_lib/versions/third_party/webapp2-2.3/webapp2.py", line 1077, in __call__
return handler.dispatch()
File "./utils/session.py", line 48, in dispatch
self.session_store.save_sessions(self.response)
File "./webapp2_extras/sessions.py", line 420, in save_sessions
session.save_session(response)
File "./webapp2_extras/appengine/sessions_ndb.py", line 118, in save_session
self.session_model(id=self.sid, data=dict(self.session))._put()
File "/base/python27_runtime/python27_lib/versions/1/google/appengine/ext/ndb/utils.py", line 131, in positional_wrapper
return wrapped(*args, **kwds)
File "/base/python27_runtime/python27_lib/versions/1/google/appengine/ext/ndb/model.py", line 2248, in __init__
self._set_attributes(kwds)
File "/base/python27_runtime/python27_lib/versions/1/google/appengine/ext/ndb/model.py", line 2279, in _set_attributes
prop._set_value(self, value)
File "/base/python27_runtime/python27_lib/versions/1/google/appengine/ext/ndb/model.py", line 800, in _set_value
value = self._do_validate(value)
File "/base/python27_runtime/python27_lib/versions/1/google/appengine/ext/ndb/model.py", line 750, in _do_validate
value = self._call_shallow_validation(value)
File "/base/python27_runtime/python27_lib/versions/1/google/appengine/ext/ndb/model.py", line 928, in _call_shallow_validation
return call(value)
File "/base/python27_runtime/python27_lib/versions/1/google/appengine/ext/ndb/model.py", line 975, in call
newvalue = method(self, value)
File "/base/python27_runtime/python27_lib/versions/1/google/appengine/ext/ndb/model.py", line 1275, in _validate
(value,))
BadValueError: Expected str, got {'username': u'foo'}
Original issue reported on code.google.com by joernhees2
on 27 Jan 2012 at 2:36
I get the following stack when trying to use webapp2 installed in the GAE
runtime because ndb is now at google.appengine.ext.ndb:
Traceback (most recent call last):
File "/base/python27_runtime/python27_lib/versions/1/google/appengine/runtime/wsgi.py", line 168, in Handle
handler = _config_handle.add_wsgi_middleware(self._LoadHandler())
File "/base/python27_runtime/python27_lib/versions/1/google/appengine/runtime/wsgi.py", line 217, in _LoadHandler
__import__(cumulative_path)
File "/base/data/home/apps/s~icronym/1.354797738693170194/qed4/icronym/service.py", line 10, in <module>
from webapp2_extras.appengine.auth.models import User
File "/base/python27_runtime/python27_lib/versions/third_party/webapp2-2.3/webapp2_extras/appengine/auth/models.py", line 13, in <module>
from ndb import model
ImportError: No module named ndb
Original issue reported on code.google.com by [email protected]
on 19 Nov 2011 at 11:01
This bug is related to
http://code.google.com/p/appengine-ndb-experiment/issues/detail?id=103 .
It should be really easy to convert a db (or ndb) Model to json with
json.dumps(model._to_dict, default=webapp2.JsonCompatible)
What is the expected output? What do you see instead?
At the moment json.dumps(db.to_dict(model)) throws an error for
models with blobstore keys and a few other basic properties.
Original issue reported on code.google.com by [email protected]
on 5 Dec 2011 at 11:59
It would be awesome if there was a base Model class that automatically
memcached models when read, and put them back on write.
This could be done similar to how Nick Johnson describes here:
http://blog.notdot.net/2009/9/Efficient-model-memcaching
Original issue reported on code.google.com by [email protected]
on 7 Sep 2011 at 1:11
Steps will reproduce the problem:
1. create a secure cookie - e.g. self.session['foo'] = 'bar'
2. send a request with the session cookie in double quotes.
3. check existence - e.g. if not 'foo' in self.session: fail!
What is the expected output? What do you see instead?
The quotes should be removed before checking the cookie value
What version of the product are you using? On what operating system?
google sdk 1.6.1
Please provide any additional information below.
Here is a workaround. In line 66 of securecookie.py change
from the following:
parts = value.split('|')
to this:
val = value if value[0] != '"' else value[1:-1]
parts = val.split('|')
Original issue reported on code.google.com by [email protected]
on 21 Dec 2011 at 5:35
Here's a sample how to work with auth in webapp2
Original issue reported on code.google.com by [email protected]
on 14 Sep 2011 at 12:11
Attachments:
This Commit adds a helper method to auth User that checks the uniqueness of an
auth id. If it's unique it will add to the user and save else: it will return
the error.
http://code.google.com/r/kylefinley-webapp2/source/detail?r=e994be424c2403ca88da
07ca88501b6ff55a4099
Original issue reported on code.google.com by [email protected]
on 17 Nov 2011 at 10:28
What steps will reproduce the problem?
1. run the test: tests/handler_test.py
2. fails because month should be initialized to a string not an integer.
Please provide any additional information below.
The following fixes the problem:
--- a/tests/handler_test.py
+++ b/tests/handler_test.py
@@ -420,7 +420,7 @@
self.assertEqual(func('methods', _scheme='https', _full=False), 'https://localhost:80/methods')
self.assertEqual(func('methods', _scheme='https', _fragment='my-anchor'), 'https://localhost:80/methods#my-anchor')
- self.assertEqual(func('route-test', year='2010', month=0,
name='test'), '/2010/0/test')
+ self.assertEqual(func('route-test', year='2010', month='0',
name='test'), '/2010/0/test')
self.assertEqual(func('route-test', year='2010', month='07', name='test'), '/2010/07/test')
self.assertEqual(func('route-test', year='2010', month='07', name='test', foo='bar'), '/2010/07/test?foo=bar')
self.assertEqual(func('route-test', _fragment='my-anchor', year='2010', month='07', name='test', foo='bar'), '/2010/07/test?foo=bar#my-anchor')
Original issue reported on code.google.com by [email protected]
on 11 Jan 2012 at 3:14
What steps will reproduce the problem?
1. initialize application instance by webapp2.WSGIApplication() with debug=True
arg
2. run it on the dev_appserver.py
3. raise Exception() in a request handler.
What is the expected output? What do you see instead?
Expected output is stack trace on the browser.
I saw empty body status:500 error page.
What version of the product are you using? On what operating system?
Python 2.7.2 64bit
AppEngine SDK 1.6.0
Windows 7 SP1 64bit
Please provide any additional information below.
This document
http://webapp-improved.appspot.com/guide/app.html#debug-flag says:
> When in debug mode, any exception that is now caught is raised and the stack
trace is displayed to the client
Original issue reported on code.google.com by [email protected]
on 20 Nov 2011 at 1:07
What steps will reproduce the problem?
1. Add the follow route to your app:
application = webapp.WSGIApplication([
webapp.Route(r'/page/<model_id:\d+>', PageHandler, 'page'),
], debug=True)
2. Try to get the URI for this handler:
webapp.uri_for('page', self.request, model_id=0)
Result:
Exception:
File "/home/rogerta/Public/google_appengine/lib/webapp2/webapp2.py", line 1706, in uri_for
return request.app.router.build(request, _name, args, kwargs)
File "/home/rogerta/Public/google_appengine/lib/webapp2/webapp2.py", line 1224, in default_builder
return route.build(request, args, kwargs)
File "/home/rogerta/Public/google_appengine/lib/webapp2/webapp2.py", line 978, in build
path, query = self._build(args, kwargs)
File "/home/rogerta/Public/google_appengine/lib/webapp2/webapp2.py", line 1002, in _build
name.strip('_'))
KeyError: 'Missing argument "model_id" to build URI.'
What is the expected output? What do you see instead?
Should get correct URI for handler.
What version of the product are you using? On what operating system?
I am using the webapp2 package provided with the google appengine SDK v1.6.0,
running with python 2.7. I believe this is webapp2 v2.3.
From what I see of the code, it seems that line ~1000 in webapp2.py:
if not value:
should be instead:
if value is None:
Original issue reported on code.google.com by [email protected]
on 5 Dec 2011 at 11:51
What steps will reproduce the problem?
1. create user with auth_id "a1"
2. create user with auth_id "A1"
What is the expected output?
- Two different users in db.
What do you see instead?
- First user is created, second is fail.
Please provide any additional information below.
— In our system we have different case-sensitive auth_ids but webapp2 convert
them to lower case before creation.
Original issue reported on code.google.com by [email protected]
on 14 Aug 2011 at 11:29
I have no idea how to do it.
Original issue reported on code.google.com by nabokov.evgeni
on 10 Nov 2011 at 10:38
I guess this is just a formality - still
What steps will reproduce the problem?
1.make the hello app here:
http://webapp-improved.appspot.com/tutorials/quickstart.nogae.html
2. start it
3. read the output
What is the expected output? What do you see instead?
env/lib/python2.6/site-packages/webapp2.py:135: DeprecationWarning:
decode_param_names is deprecated and will not be supported starting with WebOb
1.2
super(Request, self).__init__(environ, *args, **kwargs)
What version of the product are you using? On what operating system?
N/A
Please provide any additional information below.
N/A
Original issue reported on code.google.com by [email protected]
on 14 Oct 2011 at 8:45
Hi,
shouldn't the appengine dependent parts which import ndb be updated to instead:
from google.appengine.ext import ndb ?
Jörn
Original issue reported on code.google.com by joernhees2
on 16 Nov 2011 at 5:21
Here is the code flow:
1. webapp2.Request.__init__ doesn't see a charset in the Content-Type header so
it sets charset='UTF-*'
2. webob.BaseRequest.__init__ has this logic:
if charset is not NoDefault:
self.charset = charset
3. webob.BaseRequest._charset__set has this logic:
...
content_type = self.environ.get('CONTENT_TYPE', '')
...
self.environ['CONTENT_TYPE'] = content_type
So, if there is no Content-Type header, a new one is created with the value ' ;
charset=UTF-8'
Original issue reported on code.google.com by [email protected]
on 14 Dec 2011 at 4:53
Trying to use webapp2_extras.protorpc results in the following import error on
Python 2.7:
Traceback (most recent call last):
File "/base/python27_runtime/python27_lib/versions/1/google/appengine/runtime/wsgi.py", line 168, in Handle
handler = _config_handle.add_wsgi_middleware(self._LoadHandler())
File "/base/python27_runtime/python27_lib/versions/1/google/appengine/runtime/wsgi.py", line 214, in _LoadHandler
handler = __import__('.'.join(path[:i]))
File "/base/data/home/apps/s~exabrot/1.352815502383199276/main.py", line 17, in <module>
import api
File "/base/data/home/apps/s~exabrot/1.352815502383199276/api.py", line 6, in <module>
from webapp2_extras import protorpc
File "/base/python27_runtime/python27_lib/versions/third_party/webapp2-2.0.2/webapp2_extras/protorpc.py", line 30, in <module>
class ServiceHandler(webapp2.RequestHandler, service_handlers.ServiceHandler):
TypeError: Error when calling the metaclass bases
Cannot create a consistent method resolution
order (MRO) for bases ServiceHandler, RequestHandler
Original issue reported on code.google.com by [email protected]
on 26 Aug 2011 at 6:44
The protorpc form which is quite handy is not available under wsgi/python27
environment.
It a future lost in the transition to wsgi which should return.
Original issue reported on code.google.com by erlichmen
on 26 Jan 2012 at 2:05
What steps will reproduce the problem?
1. Download and unpack webapp2-1.6.3.zip 176kB
2. Create a new GAE project and copy webapp2.py and webapp2_extras folder from
step 1 into project root
3. Sample code trying to test sessions (put this in a file main.py):
import webapp2
from google.appengine.ext.webapp import util
from webapp2_extras import sessions
class BaseHandler(webapp2.RequestHandler):
def dispatch(self):
# Get a session store for this request.
self.session_store = sessions.get_store(request=self.request)
try:
# Dispatch the request.
webapp2.RequestHandler.dispatch(self)
finally:
# Save all sessions.
self.session_store.save_sessions(self.response)
@webapp2.cached_property
def session(self):
# Returns a session using the default cookie key.
return self.session_store.get_session()
class MainHandler(BaseHandler):
def get(self):
self.session['foo'] = 'bar'
self.response.out.write('Hello world!')
def main():
application = webapp2.WSGIApplication([('/', 'main.MainHandler')],
debug=True)
util.run_wsgi_app(application)
if __name__ == '__main__':
main()
What is the expected output? What do you see instead?
expected: hello world
observed:
Traceback (most recent call last):
File "C:\Program Files\Google\google_appengine\google\appengine\tools\dev_appserver.py", line 3858, in _HandleRequest
self._Dispatch(dispatcher, self.rfile, outfile, env_dict)
File "C:\Program Files\Google\google_appengine\google\appengine\tools\dev_appserver.py", line 3792, in _Dispatch
base_env_dict=env_dict)
File "C:\Program Files\Google\google_appengine\google\appengine\tools\dev_appserver.py", line 580, in Dispatch
base_env_dict=base_env_dict)
File "C:\Program Files\Google\google_appengine\google\appengine\tools\dev_appserver.py", line 2918, in Dispatch
self._module_dict)
File "C:\Program Files\Google\google_appengine\google\appengine\tools\dev_appserver.py", line 2822, in ExecuteCGI
reset_modules = exec_script(handler_path, cgi_path, hook)
File "C:\Program Files\Google\google_appengine\google\appengine\tools\dev_appserver.py", line 2702, in ExecuteOrImportScript
exec module_code in script_module.__dict__
File "C:\Users\siddjain\PycharmProjects\webapp2_test\main.py", line 51, in <module>
main()
File "C:\Users\siddjain\PycharmProjects\webapp2_test\main.py", line 47, in main
util.run_wsgi_app(application)
File "C:\Program Files\Google\google_appengine\google\appengine\ext\webapp\util.py", line 98, in run_wsgi_app
run_bare_wsgi_app(add_wsgi_middleware(application))
File "C:\Program Files\Google\google_appengine\google\appengine\ext\webapp\util.py", line 116, in run_bare_wsgi_app
result = application(env, _start_response)
File "C:\Users\siddjain\PycharmProjects\webapp2_test\webapp2.py", line 1075, in __call__
return self._internal_error(e, environ, start_response)
File "C:\Users\siddjain\PycharmProjects\webapp2_test\webapp2.py", line 1067, in __call__
rv = self.handle_exception(request, response, e)
File "C:\Users\siddjain\PycharmProjects\webapp2_test\webapp2.py", line 1061, in __call__
rv = self.router.dispatch(request, response)
File "C:\Users\siddjain\PycharmProjects\webapp2_test\webapp2.py", line 875, in default_dispatcher
return factory(request, response)
File "C:\Users\siddjain\PycharmProjects\webapp2_test\webapp2.py", line 327, in factory
return handler.dispatch()
File "C:\Users\siddjain\PycharmProjects\webapp2_test\main.py", line 24, in dispatch
self.session_store = sessions.get_store(request=self.request)
File "C:\Users\siddjain\PycharmProjects\webapp2_test\webapp2_extras\sessions.py", line 397, in get_store
store = request.registry[key] = factory(request)
File "C:\Users\siddjain\PycharmProjects\webapp2_test\webapp2_extras\sessions.py", line 272, in __init__
self.config = request.app.config[self.config_key]
AttributeError: 'WSGIApplication' object has no attribute 'config'
What version of the product are you using? On what operating system?
webapp2-1.6.3.zip 176kB, Windows Vista
Please provide any additional information below.
this is not the first time I have tried to use webapp2 or tipfy, and found that
its broken out-of-the-box
Original issue reported on code.google.com by [email protected]
on 3 Jun 2011 at 5:31
This works with webapp but not with webapp-improved 0.5 and 0.6:
template.register_template_library(os.path.join(os.path.dirname(__file__),
"templatetags", 'templatefilters.py'))
so I moved the templatefilters.py up and used this with 0.5 and 0.6:
template.register_template_library('templatefilters')
but webapp-improved 0.7 doesn't work with that. Meaning that my templates fail
with TemplateSyntaxError: <unprintable TemplateSyntaxError object>
Thanks!
Original issue reported on code.google.com by JDeibele
on 18 Oct 2010 at 9:23
What steps will reproduce the problem?
rh.response.headers.add_header('Set-Cookie','%s=%s; path=/;'%(name,self._sid))
(ref:
http://stackoverflow.com/questions/5118639/getting-error-while-trying-to-add-hea
der-with-set-cookie-in-gae)
What is the expected output? What do you see instead?
I understood that webapp2 is a drop-in replacement with App Engine webapp. So
I expected existing code to work.
What version of the product are you using? On what operating system?
webapp2.py 1.7.1
App Engine SDK 1.5.0.
Original issue reported on code.google.com by [email protected]
on 18 Jun 2011 at 7:02
It is great that webapp2.py is a single file and it makes it easy to include in
projects wihtout installing it... but it gets hard to know which version I am
using.
It would be nice if you include something like into webapp2.py:
__version__ = "2.3.0"
Original issue reported on code.google.com by [email protected]
on 8 Feb 2012 at 4:20
Changing and compiling new translations will not cause the development server
to reload said translations. A temporary fix suggested by Rodrigo Moraes is to
replace the following in i18n.py:
self.translations[locale] = trans
-with-
if not webapp2.get_app().debug:
self.translations[locale] = trans
Tried and tested. Works perfectly.
BR / Fredrik
Original issue reported on code.google.com by [email protected]
on 14 Aug 2011 at 8:47
This is a slightly modified version of the example class in SessionStore.
The modification allows the example code to be configured with a
'default_backend' setting in the config, so that normal users who most likely
want sessions to be stored in the database backend on appengine can do so very
easily.
changeset is here:
http://code.google.com/r/joernhees-webapp2/source/detail?r=75e09133c0496132e98fe
83441e0defd27364022
Original issue reported on code.google.com by joernhees2
on 16 Nov 2011 at 6:43
On version webapp2-2.2 running python 2.6.1 OSX. I kept getting this error
when running a simple app.
handlers.CGIHandler().run(app)
NameError: global name 'app' is not defined
So I modified webapp2.py from
1580 else: # pragma: no cover
1581 handlers.CGIHandler().run(app)
to
1580 else: # pragma: no cover
1581 handlers.CGIHandler().run(self)
and it worked. Looking at previous versions, run is passed with 'self' instead
of 'app'.
Original issue reported on code.google.com by [email protected]
on 31 Jul 2011 at 7:55
Check out how slick Flask's blueprints are in this example:
http://flask.pocoo.org/docs/patterns/urlprocessors/#internationalized-blueprint-
urls
Could webabb2 offer something like this?
Original issue reported on code.google.com by [email protected]
on 16 Sep 2011 at 2:53
What steps will reproduce the problem?
1. Call url_for on an app
What is the expected output? What do you see instead?
To return the url for the named route. Instead it fails with attribute error.
Apps do not have a response:
http://code.google.com/p/webapp-improved/source/browse/webapp2/__init__.py#1100
Also it doesn't make sense that Router.build takes a response as an argument.
No router.build implementation uses it.
Original issue reported on code.google.com by evlogimenos
on 8 Aug 2010 at 11:42
Take a look at
http://www.tornadoweb.org/documentation/web.html#tornado.web.RequestHandler.chec
k_xsrf_cookie and adapt this idea for webapp2.
Original issue reported on code.google.com by [email protected]
on 12 Aug 2011 at 4:08
I downloaded webapp2-2.0.2.zip from
http://code.google.com/p/webapp-improved/downloads/list.
Then I tryed launch example with sessions stored in datastore and got error:
<type 'exceptions.ImportError'>: No module named ndb
Traceback (most recent call last):
File "/base/data/home/apps/s~projectedagae/1.352172280372792162/requesthandler.py", line 19, in <module>
from webapp2_extras import sessions_ndb
File "/base/data/home/apps/s~projectedagae/1.352172280372792162/webapp2_extras/sessions_ndb.py", line 16, in <module>
from ndb import model
File with name ndb.py does not exist in webapp2_extras.
Original issue reported on code.google.com by nabokov.evgeni
on 29 Jul 2011 at 1:02
now it's time to give support to Python 3
Original issue reported on code.google.com by [email protected]
on 15 Dec 2011 at 3:53
What steps will reproduce the problem?
Templates are rendered with Content-Type: text/html; charset=utf8 <-- utf8
should be utf-8
What is the expected output? What do you see instead?
Content-Type: text/html; charset=utf-8
What version of the product are you using? On what operating system?
0.7
Please provide any additional information below.
Original issue reported on code.google.com by johnnytee
on 13 Feb 2011 at 10:00
If you have webapp2_extras.local installed, and import another WSGIApplication
during a request, the pointer to self.app will get reset by WSGIApplication's
constructor. Among other things, this points all the routes you access via
uri_for to the other application.
Please see the attached sample application for a demonstration of the problem.
(We discovered this while working with a helper method we wrote to give you a
"global" uri_for that will give you access to named routes from all your
applications.)
It may be that this is "expected behavior" for webapp2_extras.local. We are
using GAE/python 2.5 so we aren't using multi-threading and therefore don't
need that feature. But there is no warning that you *shouldn't* use
webapp2_extras.local with Google App Engine. In fact, the doc for set_globals
says webapp2_extras.local "can also be used in environments that don't support
threading."
We have found two ways to fix this problem:
1. Delete local.py from webapp2_extras. If this is the preferred way, I think
it should be documented.
2. In WSGIApplication.initialize, change
self.app = WSGIApplication.active_instance
to
self.app = WSGIApplication.active_instance._get_current_object()
But this seems like a hack.
Original issue reported on code.google.com by [email protected]
on 3 Oct 2011 at 10:20
Attachments:
What steps will reproduce the problem?
1.http://webapp-improved.appspot.com/ and
http://code.google.com/p/webapp-improved/
2.say that webapp2 is a single file framework
What is the expected output? What do you see instead?
instead it tells that it can not be run without webob, and later complains that
without webapp2_extras.local it won't be thread-safe. I bet half users don't
know what does it mean, but it's surely sounds scary to them.
What version of the product are you using? On what operating system?
2.3 + 1.2b
Please provide any additional information below.
Starting with it, because AppEngine supports it. Quite disappointed to keep all
this stuff at the root of my project.
Original issue reported on code.google.com by [email protected]
on 18 Nov 2011 at 3:05
The URL path is encoded to unicode but not the query arguments.
What steps will reproduce the problem?
Python 2.5.5 (r255:77872, Mar 27 2011, 12:30:39)
In [1]: import webapp2
In [2]: print webapp2.__version__
2.5.1
In [3]: my_route = webapp2.Route('/')
In [4]: my_route.build(None, [], {'unicode_value':u'olá'})
---------------------------------------------------------------------------
UnicodeEncodeError Traceback (most recent call last)
/xxxxx/webapp2-2.5.1/<ipython console> in <module>()
/xxxxx/webapp2-2.5.1/webapp2.py in build(self, request, args, kwargs)
1002
1003 path, query = self._build(args, kwargs)
-> 1004 return _urlunsplit(scheme, netloc, path, query, anchor)
1005
1006 def _build(self, args, kwargs):
/xxxxx/webapp2-2.5.1/webapp2.py in _urlunsplit(scheme, netloc, path, query,
fragment)
1888
1889 # Sort args: commonly needed to build signatures for services.
-> 1890 query = urllib.urlencode(sorted(query))
1891
1892 if fragment:
/usr/local/lib/python2.5/urllib.pyc in urlencode(query, doseq)
1248 for k, v in query:
1249 k = quote_plus(str(k))
-> 1250 v = quote_plus(str(v))
1251 l.append(k + '=' + v)
1252 else:
UnicodeEncodeError: 'ascii' codec can't encode characters in position 2-3:
ordinal not in range(128)
Original issue reported on code.google.com by [email protected]
on 5 Mar 2012 at 4:53
Please provide any additional information below.
1. webapp2 executes this line on import:
from google.appengine.ext.webapp import util as _webapp_util
2. this causes webapp/__init__.py to be imported which executes this line:
from webapp2 import *
Since webapp2 has not defined Request, Response, etc. at the time of the
import, the google.appengine.ext.webapp namespace will be unusable.
Original issue reported on code.google.com by [email protected]
on 26 Aug 2011 at 1:58
The current version of WebOb found in App Engine ignores form parameters for
non GET/POST requests, which is really inconvenient for RESTfull apps.
I hope that a newer version does ship in the same release as 2.7 (that also
includes this framework AFAIK), but for the time being, I was tired on doing
workarounds so I made a really really simple override in webapp2 to handle this
issue:
@property
def str_POST(self):
method = self.method
self.method = 'POST'
vars = super(Request, self).str_POST
self.method = method
return vars
Very straightforward. Yes, it's a hack, but I think it gives the behavior
people expect.
Anyway, thought you might be interested. And of course, thank you for all the
amazing job you've done :)
Original issue reported on code.google.com by [email protected]
on 5 Sep 2011 at 5:21
Hello, i was looking for a better place to report this, but this is the only
contact method i found. Apologies if i've been staring at an email link all
along and missed it!
What steps will reproduce the problem?
1. Visit http://webapp-improved.appspot.com/guide/extras.html
2. Copy the example code into a new application
3. Attempt to run the example
What is the expected output? What do you see instead?
The app fails with "AttributeError: 'module' object has no attribute
'WSGIAppplication'"
This is a typo, WSGIApplication has 3x'P' chars instead of 2.
Hope this helps!
p.s. thanks for a great tutorial site!
Original issue reported on code.google.com by [email protected]
on 10 Feb 2012 at 6:33
What steps will reproduce the problem?
1. Add a route: webapp.Route(r'/thanks/?', ThanksHandler, 'thanks').
2. On the dev server, try to navigate to 'localhost8080://thanks'.
3. On the dev server, try to navigate to 'localhost8080://thanks/'.
What is the expected output? What do you see instead?
I expect to see the output of the ThanksHandler.
In both steps 2 and above, I see a 404 page.
What version of the product are you using? On what operating system?
I am using the webapp2 package provided with the google appengine SDK v1.6.0,
running with python 2.7.2. I believe this is webapp2 v2.3.
Please provide any additional information below.
From what I see of the code, the problem is in webapp2.py, function
_parse_route_template(). There are two places where this function passes a
string through re.escape(), and this messes up the pattern.
For example, the pattern '/thanks/?' becomes r'\/thanks\/\?', which is is not
at all the same. If you remove the calls to re.escape() the problems does not
occur.
What is the purpose of escaping the input template this way?
Original issue reported on code.google.com by [email protected]
on 6 Dec 2011 at 2:29
This is a feature request:
When creating a web application for processing HTML form, one is often lead to
process the form post data by the same RequestHandler that displays the form
(i.e. to use the post-back idiom).
In RequestHandlers like these the get and the post method usually share common
code to set up the context. It would be nice if the default dispatch method of
RequestHandler would call a common method (for example like "update" on Zope
views) once it has determined args and kwargs before it calls a handler like
get and post with these args and kwargs.
Original issue reported on code.google.com by [email protected]
on 2 Nov 2011 at 7:15
I want to serve static files. I am not using GAE. Can I configure the
paste http server to serve static files based on specific URL's?
Original issue reported on code.google.com by tister1980
on 27 Oct 2011 at 2:49
With webapp, I can write out a form using self.response.out.write( form )
I can't with webapp-improved
self.response.out.write(StateForm())
File "/home/jamesd/python/google_appengine/lib/webob/webob/__init__.py", line 1613, in write
self.body += text
TypeError: cannot concatenate 'str' and 'StateForm' objects
Original issue reported on code.google.com by JDeibele
on 13 Aug 2010 at 6:12
I had a chat with Guido about this and he seems to think that it is mature
enough.
And some users have complained about this:
http://code.google.com/p/googleappengine/issues/detail?id=6279
Original issue reported on code.google.com by [email protected]
on 22 Nov 2011 at 5:16
Attachments:
Constraining to min_value and max_value range only occurs in the obscure
condition where the default value is used in place of a non-numeric value. In
other words, it doesn't really happen.
eg get_range("a", 10, 20)
where "/?a=4"
expect 10
get 4
The block starting "if value is not None:" needs to be unindented to take it
out of the exception clause.
Original issue reported on code.google.com by [email protected]
on 3 Feb 2012 at 4:06
According to the docs:
(http://webapp-improved.appspot.com/api/webapp2_extras/i18n.html)
"""
locale_selector:
A function that receives (request, i18n_store) and returns a locale to be used
for a request. If not defined, uses default_locale. Can also be a string in
dotted notation to be imported.
"""
From the docstring in i18n.py - set_locale_selector()
"""
A callable that receives (store, request) and returns the locale for a request.
"""
Was quite perplexed until I realized the arguments order had been inverted :)
BR // Fredrik
Original issue reported on code.google.com by [email protected]
on 10 Aug 2011 at 12:20
from ndb ==> from google.appengine.ext.ndb
File
"/base/python27_runtime/python27_lib/versions/third_party/webapp2-2.3/webapp2_ex
tras/appengine/auth/models.py", line 13, in <module>
from ndb import model
ImportError: No module named ndb
Original issue reported on code.google.com by [email protected]
on 24 Dec 2011 at 2:07
Fixing a documentation typo.
Original issue reported on code.google.com by phistuck
on 11 Nov 2011 at 1:55
Attachments:
Please, write debug middleware like in tipfy/werkzeug framework.
Original issue reported on code.google.com by [email protected]
on 27 Jul 2011 at 12:55
What steps will reproduce the problem?
1. Send POST request without content-type (for example ajax POST request from
Google Chrome
2. You will see request headers like:
Content-Length:57
Content-Type:application/x-www-form-urlencoded
Then when you will access self.request.POST in webapp 2.5 you will have values
as basestrings instead of unicode. The bug is introduced in
http://code.google.com/p/webapp-improved/source/detail?r=d36c461b86ba91fa9a859cf
d8280bbe03d431380#
If browser doesn't sends charset in Content-Type header, webapp2 should use
encoding used for encoding responses ('utf-8' in most cases). ATM webapp2.5
can't properly process form submissions sent by Chrome for example.
Please revert d36c461b86ba91fa9a859cfd8280bbe03d431380.
Original issue reported on code.google.com by dogada
on 5 Feb 2012 at 11:21
What steps will reproduce the problem?
1.Setup a webapp2 route for general not found handling (last route)
2.e.g webapp2.Route(r'/.*', 'handlers.misc.NotFoundHandler',
name='misc-not_found')
What is the expected output? What do you see instead?
I was expecting the route to work, note that similar route, works in webapp
e.g (r'/.*', handlers.misc.NotFoundHandler)
What version of the product are you using? On what operating system?
Latest.
Please provide any additional information below.
I realize that I could use app.error_handlers[404] mechanism, but I rather
not, because it dispatches to a function and not to a handler (for legacy
reasons, I rather not dispatch to a function)
Original issue reported on code.google.com by ubaldo
on 2 Aug 2011 at 11:43
webapp2.Response.out creates a reference loop. Changing it to a property would
avoid this.
Original issue reported on code.google.com by [email protected]
on 23 Aug 2011 at 2:30
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.