def test_set_jinja2(self):
     app = webapp2.WSGIApplication()
     self.assertEqual(len(app.registry), 0)
     jinja2.set_jinja2(jinja2.Jinja2(app), app=app)
     self.assertEqual(len(app.registry), 1)
     j = jinja2.get_jinja2(app=app)
     self.assertTrue(isinstance(j, jinja2.Jinja2))
Пример #2
0
 def test_set_jinja2(self):
     app = webapp2.WSGIApplication()
     self.assertEqual(len(app.registry), 0)
     jinja2.set_jinja2(jinja2.Jinja2(app), app=app)
     self.assertEqual(len(app.registry), 1)
     j = jinja2.get_jinja2(app=app)
     self.assertTrue(isinstance(j, jinja2.Jinja2))
Пример #3
0
import secrets
from webapp2 import uri_for, Route, WSGIApplication
from webapp2_extras import jinja2
from utils import md5

config = {'webapp2_extras.sessions': {'secret_key': secrets.SESSION_KEY}}

application = WSGIApplication(
    [
        Route('/', web.MainPageHandler, 'main'),
        Route('/signup', web.SignUpHandler, 'signup'),
        Route('/signin', web.SignInHandler, 'signin'),
        Route('/signout', web.SignOutHandler, 'signout'),
        Route('/dashboard', web.DashboardHandler, 'dashboard'),
        Route('/upload_avatar', web.UploadAvatarHandler, 'upload_avatar'),

        #Route(r'/a/([^/]+)?', api.AvatarDownloadHandler, 'avatar')
        Route(r'/a/<email_hash>', api.DownloadAvatarHandler, 'avatar')
    ],
    debug=True,
    config=config)

jinja2.set_jinja2(jinja2.Jinja2(
    application,
    {'globals': {
        'uri_for': uri_for,
        'md5': md5,
        'site_name': 'My Gravatar'
    }}),
                  app=application)
Пример #4
0
            Route('/counter_persist_incr', fastcounter.CounterPersistIncr),
            Route('/check_order_success', tasks.CheckOrderSuccessHandler),
            Route('/basket_notification', BasketNotificationHandler,
                  'basket_notification'),
            PathPrefixRoute('/news', [
                Route('/start', tasks.StartNewsHandler),
            ]),
            PathPrefixRoute('/pushes', [
                Route('/start', tasks.StartPushesHandler),
                Route('/review', tasks.SendPushReviewHandler),
            ]),
            PathPrefixRoute('/bitrix', [
                Route('/export', tasks.BitrixExportHandler,
                      'bitrix_export_task'),
            ])
        ]),
        PathPrefixRoute('/ext', [
            Route('/export_legals', ext_api.ExportLegalsHandler),
            PathPrefixRoute('/bitrix/<namespace:[a-z0-9]+>/<order_id:\d+>', [
                Route('/info', ext_api.BitrixOrderInfoHandler,
                      'bitrix_order_info'),
            ])
        ]),
        Route('/twilio/sms/get', api.ReceiveSms),
    ],
    config=webapp2_config)

jinja2.set_jinja2(jinja2.Jinja2(app), app=app)

app.error_handlers[500] = handle_500
Пример #5
0
from handlers import web, api
import secrets
from webapp2 import uri_for, Route, WSGIApplication
from webapp2_extras import jinja2
from utils import md5

config = {"webapp2_extras.sessions": {"secret_key": secrets.SESSION_KEY}}


application = WSGIApplication(
    [
        Route("/", web.MainPageHandler, "main"),
        Route("/signup", web.SignUpHandler, "signup"),
        Route("/signin", web.SignInHandler, "signin"),
        Route("/signout", web.SignOutHandler, "signout"),
        Route("/dashboard", web.DashboardHandler, "dashboard"),
        Route("/upload_avatar", web.UploadAvatarHandler, "upload_avatar"),
        # Route(r'/a/([^/]+)?', api.AvatarDownloadHandler, 'avatar')
        Route(r"/a/<email_hash>", api.DownloadAvatarHandler, "avatar"),
    ],
    debug=True,
    config=config,
)

jinja2.set_jinja2(
    jinja2.Jinja2(application, {"globals": {"uri_for": uri_for, "md5": md5, "site_name": "My Gravatar"}}),
    app=application,
)