# HG changeset patch # User Bitbucket # Date 0 0 # Node ID a61d18b9db515d234ec7aea236667ca16c7cad4a # Parent 3b3ee9df3977c09a8d166889ce36f7b577bd18c6 # Parent 45ab36980a6ddc8d3a7cd817032b77879bf75748 Merge preview of source (45ab36980a6ddc8d3a7cd817032b77879bf75748) to destination (3b3ee9df3977c09a8d166889ce36f7b577bd18c6). diff -r 3b3ee9df3977c09a8d166889ce36f7b577bd18c6 -r a61d18b9db515d234ec7aea236667ca16c7cad4a demos/guestbook/app.py --- a/demos/guestbook/app.py +++ b/demos/guestbook/app.py @@ -18,9 +18,11 @@ if __name__ == '__main__': + from wsgiref.handlers import BaseHandler from wsgiref.simple_server import make_server try: print('Visit http://localhost:8080/') + BaseHandler.http_version = '1.1' make_server('', 8080, main).serve_forever() except KeyboardInterrupt: pass diff -r 3b3ee9df3977c09a8d166889ce36f7b577bd18c6 -r a61d18b9db515d234ec7aea236667ca16c7cad4a demos/guestbook/config.py --- a/demos/guestbook/config.py +++ b/demos/guestbook/config.py @@ -5,8 +5,12 @@ from wheezy.caching.memory import MemoryCache from wheezy.caching.patterns import Cached -from wheezy.html.ext.mako import widget_preprocessor -from wheezy.web.templates import MakoTemplate +from wheezy.html.ext.template import WidgetExtension +from wheezy.html.utils import html_escape +from wheezy.template.engine import Engine +from wheezy.template.ext.core import CoreExtension +from wheezy.template.loader import FileLoader +from wheezy.web.templates import WheezyTemplate cache = MemoryCache() @@ -17,16 +21,25 @@ return sqlite3.connect('guestbook.db', detect_types=sqlite3.PARSE_DECLTYPES) - -options = { - 'render_template': MakoTemplate( - directories=['templates'], - filesystem_checks=False, - preprocessor=[widget_preprocessor] - ) -} +options = {} # HTTPCacheMiddleware options.update({ 'http_cache': cache }) + + +# Template Engine +searchpath = ['templates'] +engine = Engine( + loader=FileLoader(searchpath), + extensions=[ + CoreExtension(), + WidgetExtension(), + ]) +engine.global_vars.update({ + 'h': html_escape +}) +options.update({ + 'render_template': WheezyTemplate(engine) +}) diff -r 3b3ee9df3977c09a8d166889ce36f7b577bd18c6 -r a61d18b9db515d234ec7aea236667ca16c7cad4a demos/guestbook/templates/add.html --- a/demos/guestbook/templates/add.html +++ b/demos/guestbook/templates/add.html @@ -1,23 +1,27 @@ -<%inherit file="/layout.html"/> +@extends("layout.html") + +@def content(): +@require(greeting, path_for, errors)

Sign Guestbook

-${greeting.error()} -
+@greeting.error() +

- ${greeting.author.label('Author:')} - ${greeting.author.textbox()} - ${greeting.author.error()} + @greeting.author.label('Author:') + @greeting.author.textbox() + @greeting.author.error()

- ${greeting.message.textarea()} - ${greeting.message.error()} + @greeting.message.textarea() + @greeting.message.error()

-Back +Back +@end diff -r 3b3ee9df3977c09a8d166889ce36f7b577bd18c6 -r a61d18b9db515d234ec7aea236667ca16c7cad4a demos/guestbook/templates/layout.html --- a/demos/guestbook/templates/layout.html +++ b/demos/guestbook/templates/layout.html @@ -1,17 +1,20 @@ +@require(path_for) Guestbook - + src="@path_for('static', path='site.js')">
- ${self.body()} + @def content(): + @end + @content()
diff -r 3b3ee9df3977c09a8d166889ce36f7b577bd18c6 -r a61d18b9db515d234ec7aea236667ca16c7cad4a demos/guestbook/templates/list.html --- a/demos/guestbook/templates/list.html +++ b/demos/guestbook/templates/list.html @@ -1,11 +1,14 @@ -<%inherit file="/layout.html"/> +@extends("layout.html") +@def content(): +@require(path_for, greetings)

Guestbook

-Sign guestbook -%for g in greetings: -

- ${g.id}. On ${g.created_on.strftime('%m/%d/%Y %I:%M %p')}, - ${g.author or 'anonymous'} wrote: -

${g.message.replace('\n', '
')}
+Sign guestbook +@for g in greetings: +

+ @g.id!s. On @g.created_on.strftime('%m/%d/%Y %I:%M %p'), + @str(g.author or 'anonymous') wrote: +

@g.message.replace('\n', '
')

-%endfor +@end +@end diff -r 3b3ee9df3977c09a8d166889ce36f7b577bd18c6 -r a61d18b9db515d234ec7aea236667ca16c7cad4a demos/guestbook/views.py --- a/demos/guestbook/views.py +++ b/demos/guestbook/views.py @@ -35,7 +35,8 @@ class AddHandler(BaseHandler): @handler_cache(CacheProfile('both', duration=timedelta(hours=1), - vary_environ=['HTTP_ACCEPT_ENCODING'])) + vary_environ=['HTTP_ACCEPT_ENCODING'], + http_vary=['Accept-Encoding'])) @handler_transforms(gzip_transform(compress_level=9, min_length=250)) def get(self, greeting=None): greeting = greeting or Greeting() diff -r 3b3ee9df3977c09a8d166889ce36f7b577bd18c6 -r a61d18b9db515d234ec7aea236667ca16c7cad4a demos/quickstart-empty/content/maintenance.html --- a/demos/quickstart-empty/content/maintenance.html +++ b/demos/quickstart-empty/content/maintenance.html @@ -3,7 +3,7 @@ Maintenance