3
Miscelaneous notes abotu things to be documented.
5
Unordered list of topics to be documented
6
-----------------------------------------
9
- common regular expressions examples
13
- basic usage & configuration
14
- using multiple sessions in the same request
15
- using different backends
17
- updating session arguments (max_age etc)
20
- i18n (increment existing tutorial)
22
- basic usage & configuration
23
- loading locale/timezone automatically for each request
24
- formatting date/time/datetime
26
- using i18n in templates
30
- basic usage & configuration
31
- setting global filters and variables (using config or factory)
35
- basic usage & configuration
36
- setting up 'own auth'
37
- making user available automatically on each request
42
- configuration conventions ("namespaced" configuration for webapp2_extras
47
- configuration in a separate file
48
- routes in a separate file
49
- reduce verbosity when defining routes (R = webapp2.Route)
53
- "TypeError: 'unicode' object is not callable": one possible reason is that
54
the ``RequestHandler`` returned a string. If the handler returns anything, it
55
**must** be a :class:`webapp2.Response` object. Or it must not return
56
anything and write to the response instead using ``self.response.write()``.
60
Add a note about how to generate strong session secret keys::
62
$ openssl genrsa -out ${PWD}/private_rsa_key.pem 2048
66
To create Jinja2 with custom filters and global variables::
68
from webapp2_extras import jinja2
70
def jinja2_factory(app):
71
j = jinja2.Jinja2(app)
72
j.environment.filters.update({
73
'my_filter': my_filter,
75
j.environment.globals.update({
76
'my_global': my_global,
80
# When you need jinja, get it passing the factory.
81
j = jinja2.get_jinja2(factory=jinja2_factory)
85
http://stackoverflow.com/questions/3086091/debug-jinja2-in-google-app-engine/3694434#3694434
89
Notice that configuration is set primarily in the application. See:
91
http://webapp-improved.appspot.com/guide/app.html#config
93
By convention, modules that are configurable in webapp2 use the module
94
name as key, to avoid name clashes. Their configuration is then set in
95
a nested dict. So, e.g., i18n, jinja2 and sessions are configured like this::
98
config['webapp2_extras.i18n'] = {
99
'default_locale': ...,
101
config['webapp2_extras.jinja2'] = {
102
'template_path': ...,
104
config['webapp2_extras.sessions'] = {
107
app = webapp2.WSGIApplication(..., config=config)
109
You only need to set the configuration keys that differ from the default
110
ones. For convenience, configurable modules have a 'default_config'
111
variable just for the purpose of documenting the default values, e.g.:
113
http://webapp-improved.appspot.com/api/extras.i18n.html#webapp2_extras.i18n.default_config
115
Cookies, quoting & unicode
116
--------------------------
117
http://groups.google.com/group/webapp2/msg/985092351378c43e
118
http://stackoverflow.com/questions/6839922/unicodedecodeerror-is-raised-when-getting-a-cookie-in-google-app-engine
120
Marketplace integration
121
-----------------------
125
<?xml version="1.0" encoding="UTF-8" ?>
126
<ApplicationManifest xmlns="http://schemas.google.com/ApplicationManifest/2009">
127
<!-- Name and description pulled from message bundles -->
129
<Description>A simple application for testing the marketplace.</Description>
131
<!-- Support info to show in the marketplace & control panel -->
133
<!-- URL for application setup as an optional redirect during the install -->
134
<Link rel="setup" href="https://app-id.appspot.com/a/${DOMAIN_NAME}/setup" />
136
<!-- URL for application configuration, accessed from the app settings page in the control panel -->
137
<Link rel="manage" href="https://app-id.appspot.com/a/${DOMAIN_NAME}/manage" />
139
<!-- URL explaining how customers get support. -->
140
<Link rel="support" href="https://app-id.appspot.com/a/${DOMAIN_NAME}/support" />
142
<!-- URL that is displayed to admins during the deletion process, to specify policies such as data retention, how to claim accounts, etc. -->
143
<Link rel="deletion-policy" href="https://app-id.appspot.com/a/${DOMAIN_NAME}/deletion-policy" />
146
<!-- Show this link in Google's universal navigation for all users -->
147
<Extension id="navLink" type="link">
149
<Url>https://app-id.appspot.com/a/${DOMAIN_NAME}/</Url>
150
<!-- This app also uses the Calendar API -->
153
<Scope ref="Groups"/>
154
<Scope ref="Nicknames"/>
158
<!-- Declare our OpenID realm so our app is white listed -->
159
<Extension id="realm" type="openIdRealm">
160
<Url>https://app-id.appspot.com</Url>
163
<!-- Special access to APIs -->
165
<Url>https://apps-apis.google.com/a/feeds/user/#readonly</Url>
166
<Reason>Users can be selected to gain special permissions to access or modify content.</Reason>
170
<Url>https://apps-apis.google.com/a/feeds/group/#readonly</Url>
173
<Scope id="Nicknames">
174
<Url>https://apps-apis.google.com/a/feeds/nickname/#readonly</Url>
178
</ApplicationManifest>