Beispiel #1
0
    def test_simple(self):
        router = webapp2.Router([
            PathPrefixRoute('/a', [
                webapp2.Route('/', 'a', 'name-a'),
                webapp2.Route('/b', 'a/b', 'name-a/b'),
                webapp2.Route('/c', 'a/c', 'name-a/c'),
                PathPrefixRoute('/d', [
                    webapp2.Route('/', 'a/d', 'name-a/d'),
                    webapp2.Route('/b', 'a/d/b', 'name-a/d/b'),
                    webapp2.Route('/c', 'a/d/c', 'name-a/d/c'),
                ]),
            ])
        ])

        path = '/a/'
        match = ((), {})
        self.assertEqual(router.match(webapp2.Request.blank(path))[1:], match)
        self.assertEqual(
            router.build(webapp2.Request.blank('/'), 'name-a', match[0],
                         match[1]), path)

        path = '/a/b'
        match = ((), {})
        self.assertEqual(router.match(webapp2.Request.blank(path))[1:], match)
        self.assertEqual(
            router.build(webapp2.Request.blank('/'), 'name-a/b', match[0],
                         match[1]), path)

        path = '/a/c'
        match = ((), {})
        self.assertEqual(router.match(webapp2.Request.blank(path))[1:], match)
        self.assertEqual(
            router.build(webapp2.Request.blank('/'), 'name-a/c', match[0],
                         match[1]), path)

        path = '/a/d/'
        match = ((), {})
        self.assertEqual(router.match(webapp2.Request.blank(path))[1:], match)
        self.assertEqual(
            router.build(webapp2.Request.blank('/'), 'name-a/d', match[0],
                         match[1]), path)

        path = '/a/d/b'
        match = ((), {})
        self.assertEqual(router.match(webapp2.Request.blank(path))[1:], match)
        self.assertEqual(
            router.build(webapp2.Request.blank('/'), 'name-a/d/b', match[0],
                         match[1]), path)

        path = '/a/d/c'
        match = ((), {})
        self.assertEqual(router.match(webapp2.Request.blank(path))[1:], match)
        self.assertEqual(
            router.build(webapp2.Request.blank('/'), 'name-a/d/c', match[0],
                         match[1]), path)
Beispiel #2
0
    def test_with_variables_name_and_handler(self):
        router = webapp2.Router([
            PathPrefixRoute('/user/<username:\w+>', [
                HandlerPrefixRoute('apps.users.', [
                    NamePrefixRoute('user-', [
                        webapp2.Route('/', 'UserOverviewHandler', 'overview'),
                        webapp2.Route('/profile', 'UserProfileHandler',
                                      'profile'),
                        webapp2.Route('/projects', 'UserProjectsHandler',
                                      'projects'),
                    ]),
                ]),
            ])
        ])

        path = '/user/calvin/'
        match = ((), {'username': '******'})
        self.assertEqual(router.match(webapp2.Request.blank(path))[1:], match)
        self.assertEqual(
            router.build(webapp2.Request.blank('/'), 'user-overview', match[0],
                         match[1]), path)

        path = '/user/calvin/profile'
        match = ((), {'username': '******'})
        self.assertEqual(router.match(webapp2.Request.blank(path))[1:], match)
        self.assertEqual(
            router.build(webapp2.Request.blank('/'), 'user-profile', match[0],
                         match[1]), path)

        path = '/user/calvin/projects'
        match = ((), {'username': '******'})
        self.assertEqual(router.match(webapp2.Request.blank(path))[1:], match)
        self.assertEqual(
            router.build(webapp2.Request.blank('/'), 'user-projects', match[0],
                         match[1]), path)
Beispiel #3
0
def ResourceRoutes(route_prefix, Model, **kwargs):
    handler = create_resource_handler(Model, **kwargs)
    return PathPrefixRoute('/{}'.format(route_prefix), [
        Route('/', handler=handler, handler_method='index', methods=['GET']),
        Route(
            '/<uid:[^/]+>', handler=handler, methods=['GET', 'PUT', 'DELETE']),
    ])
Beispiel #4
0
    def test_with_variables_name_and_handler(self):
        router = webapp2.Router([
            DomainRoute('<subdomain>.<:.*>', [
                PathPrefixRoute(r'/user/<username:\w+>', [
                    HandlerPrefixRoute('apps.users.', [
                        NamePrefixRoute('user-', [
                            webapp2.Route(
                                '/',
                                'UserOverviewHandler',
                                'overview'
                            ),
                            webapp2.Route(
                                '/profile',
                                'UserProfileHandler',
                                'profile'
                            ),
                            webapp2.Route(
                                '/projects',
                                'UserProjectsHandler',
                                'projects'
                            ),
                        ]),
                    ]),
                ])
            ]),
        ])

        path = 'http://my-subdomain.app-id.appspot.com/user/calvin/'
        match = ((), {'username': '******', 'subdomain': 'my-subdomain'})
        self.assertEqual(router.match(webapp2.Request.blank(path))[1:], match)
        match[1].pop('subdomain')
        match[1]['_netloc'] = 'my-subdomain.app-id.appspot.com'
        self.assertEqual(
            router.build(webapp2.Request.blank('/'),
                         'user-overview', match[0], match[1]),
            path
        )

        path = 'http://my-subdomain.app-id.appspot.com/user/calvin/profile'
        match = ((), {'username': '******', 'subdomain': 'my-subdomain'})
        self.assertEqual(router.match(webapp2.Request.blank(path))[1:], match)
        match[1].pop('subdomain')
        match[1]['_netloc'] = 'my-subdomain.app-id.appspot.com'
        self.assertEqual(
            router.build(webapp2.Request.blank('/'),
                         'user-profile', match[0], match[1]),
            path
        )

        path = 'http://my-subdomain.app-id.appspot.com/user/calvin/projects'
        match = ((), {'username': '******', 'subdomain': 'my-subdomain'})
        self.assertEqual(router.match(webapp2.Request.blank(path))[1:], match)
        match[1].pop('subdomain')
        match[1]['_netloc'] = 'my-subdomain.app-id.appspot.com'

        self.assertEqual(
            router.build(webapp2.Request.blank('/'),
                         'user-projects', match[0], match[1]),
            path
        )
Beispiel #5
0
def get_routes():
    return [
        PathPrefixRoute('/patient', [
            Route('/bookings/<patient_key>', patient.ListPatientBookings),
            Route('/address/<patient_key>',
                  address_handler.PatientEditAddressHandler),
        ]),
    ]
Beispiel #6
0
def get_routes():
    return [
        PathPrefixRoute('/en/signup', [
            Route('/patient', signup_handler.PatientSignupHandler),
            Route('/provider', signup_handler.ProviderSignupHandler1),
            Route('/provider/<button>', signup_handler.ProviderSignupHandler1),
            Route('/provider2', signup_handler.ProviderSignupHandler2),
        ]),
        PathPrefixRoute('/fr/signup', [
            Route('/patient', signup_handler.PatientSignupHandler),
            Route('/provider', signup_handler.ProviderSignupHandler1),
            Route('/provider/<button>', signup_handler.ProviderSignupHandler1),
            Route('/provider2', signup_handler.ProviderSignupHandler2),
        ]),
        Route('/login', LoginHandler),
        Route('/en/login', LoginHandler, handler_method='get_en'),
        Route('/fr/login', LoginHandler, handler_method='get_fr'),
        Route('/login/<next_action>/<key>', LoginHandler),
        Route('/logout', LogoutHandler)
    ]
Beispiel #7
0
def include(prefix, routes):
    if isinstance(routes, StringTypes):
        routes = import_class('%s.routes' % routes)
    elif hasattr(routes, 'routes'):
        routes = routes.routes

    routes = [
        Router.route_class(*route) if isinstance(route, tuple) else route
        for route in routes
    ]

    return PathPrefixRoute(prefix, routes)
Beispiel #8
0
 def setUp(self):
     allowed_methods = webapp2.WSGIApplication.allowed_methods
     new_allowed_methods = allowed_methods.union(('PATCH', ))
     webapp2.WSGIApplication.allowed_methods = new_allowed_methods
     app = webapp2.WSGIApplication([
         Route('/users', handler=UsersHandler, name='users'),
         PathPrefixRoute('/users', [
             Route('/', handler=UsersHandler, name='users'),
             Route('/<user_id:([A-Z]|[a-z]|[0-9]|[-._])+(/)?>',
                   handler=UserHandler,
                   name='user'),
             Route(
                 '/<user_id:([A-Z]|[a-z]|[0-9]|[-._])+>/devices/<device_id:([A-Z]|[a-z]|[0-9]|[-._])+(/)?>',
                 handler=RentalHandler,
                 name='rental'),
         ]),
         Route('/devices', handler=DevicesHandler, name='devices'),
         PathPrefixRoute('/devices', [
             Route('/', handler=DevicesHandler, name='devices'),
             Route('/<device_id:([A-Z]|[a-z]|[0-9]|[-._])+(/)?>',
                   handler=DeviceHandler,
                   name='device'),
             Route(
                 '/<device_id:([A-Z]|[a-z]|[0-9]|[-._])+>/users/<user_id:([A-Z]|[a-z]|[0-9]|[-._])+(/)?>',
                 handler=RentalHandler,
                 name='rental'),
         ]),
     ])
     self.testapp = webtest.TestApp(app)
     self.testbed = testbed.Testbed()
     self.testbed.activate()
     self.testbed.init_memcache_stub()
     self.testbed.init_datastore_v3_stub()
     self.testbed.init_urlfetch_stub()
     ndb.get_context().clear_cache()
     self.v = ValidData()
Beispiel #9
0
def get_rules():
    """Returns a list of URL rules for the Hello, World! application.

    :return:
        A list of class:`tipfy.Rule` instances.
    """
    rules = [
      PathPrefixRoute('/www', [
          Route('/<realestate>/',                     name='realestate/home',           handler='apps.realestate.handlers.Index'),
          Route('/<realestate>',                      name='realestate/home',           handler='apps.realestate.handlers.Index'),
          Route('/<realestate>/busqueda',             name='realestate/search',         handler='apps.realestate.search.Search'),
          Route('/<realestate>/busqueda/<page>',      name='realestate/search/page',    handler='apps.realestate.search.Search'),
          Route('/<realestate>/ficha/<key>/<oper>',   name='realestate/ficha',          handler='apps.realestate.ficha.Show'),
          Route('/<realestate>/info',                 name='realestate/info',           handler='apps.realestate.handlers.Info'),
        ]),
      # RealEstate Home por slug
      Route('/<realestate_slug>',                     name='realestate/search_slug',    handler='apps.realestate.handlers.Index:by_slug'),
      Route('/<realestate>/theme_preview/<theme>',    name='realestate/theme_preview',  handler='apps.realestate.handlers.Index:theme_preview'),
      Route('/<realestate>/texts_preview/<title>/<message>',    name='realestate/texts_preview',  handler='apps.realestate.handlers.Index:texts_preview'),
        
    ]

    return rules
# -*- coding: utf-8 -*-

from webapp2 import Route

from webapp2_extras.routes import PathPrefixRoute


from ..handlers import MigrationHandler, QueueHandler, MigrationWorker, MigrationStatus


routes = [

    Route('/', MigrationHandler, name='migration'),
    Route('/tasks/migrate/', QueueHandler, name='migration_queue'),
    Route('/tasks/worker/', MigrationWorker, name='migration_worker'),
    Route('/tasks/status/', MigrationStatus, name='migration_status'),

    ]

main_route = PathPrefixRoute('/_ah/migration', routes)
Beispiel #11
0
session_config = {
    'secret_key': 'ghostcatch00p3rsp00dfsdferwerwer43545lzxce',
    'cookie_name': 'ghost-name-picker',
    'session_max_age': 5 * 86400,
    'cookie_args': {
        'max_age': 5 * 86400,
    }
}

config = {'webapp2_extras.sessions': session_config}

# [START app]
app = WSGIApplication([
    PathPrefixRoute('/ghost_name_picker', [
        Route('/', Overview, name='home'),
        Route('/pick-name', NamePicker, name='name_picker'),
    ]),
],
                      config=config,
                      debug=True)
# [END app]

# Populates datastore with the default set of ghosts if none exists.
ghost_initial_set_up()


def main():
    app.RUN()


if __name__ == '__main__':
Beispiel #12
0
                    rel_list.append({
                        'text': rel_found.text,
                        'link': rel_found.link,
                        'date': rel_found.date
                    })
                key_name = str(r.key().name())
                reminds[key_name]['relateds'] = rel_list
        params['reminds'] = reminds
        self.render_template('find.html', params)


class RssController(BaseHandler):
    def get(self):
        self.render_template('home.html')


app = webapp2.WSGIApplication(
    [('/', HomeController), ('/new', NewController),
     PathPrefixRoute('/new/<id:[a-zA-Z0-9-_]*>', [
         webapp2.Route('/', NewController),
         webapp2.Route('/<id:[a-zA-Z0-9-_]+>/', NewController),
     ]),
     PathPrefixRoute('/related/<id:[a-zA-Z0-9-_]*>', [
         webapp2.Route('/', RelatedController),
         webapp2.Route('/<id:[a-zA-Z0-9-_]+>/', RelatedController),
     ]),
     PathPrefixRoute('/find/<id:[a-zA-Z0-9-]*>', [
         webapp2.Route('/', TagController),
         webapp2.Route('/<id:[a-zA-Z0-9-]+>/', TagController),
     ]), ('/edit', EditController), ('/rss.xml', RssController)],
    debug=True)
Beispiel #13
0
from webapp2 import WSGIApplication, Route
from webapp2_extras.routes import PathPrefixRoute

from handlers.cron.social import SpamHandler
from handlers.cron.spelling import CheckMarkSpellingHandler
from handlers.cron.video import VideosUpdateHandler

app = WSGIApplication([
    PathPrefixRoute(
        '/cron',
        [
            PathPrefixRoute('/video', [
                Route('/update', VideosUpdateHandler),
            ]),
            PathPrefixRoute('/social', [
                Route('/spam', SpamHandler),
            ]),
            # PathPrefixRoute('/spelling', [
            #     Route('/marks', CheckMarkSpellingHandler),
            # ]),
        ]),
])
Beispiel #14
0
    HandlerPrefixRoute(
        'photoamaze.handlers.',
        [
            webapp2.Route('/', handler='LandingHandler', name='landing'),
            webapp2.Route('/credits', handler='CreditsHandler',
                          name='credits'),
            webapp2.Route('/privacy', handler='PrivacyHandler',
                          name='privacy'),
            webapp2.Route('/terms', handler='TermsHandler', name='terms'),

            # Public maze endpoints.
            PathPrefixRoute('/public', [
                webapp2.Route(
                    '/maze', name='public-maze', handler='PublicMazeHandler'),
                webapp2.Route('/image/list',
                              name='public-image-list',
                              handler='PublicImageListHandler'),
                webapp2.Route(r'/image/<image_id:.+>',
                              name='public-image',
                              handler='PublicImageHandler')
            ]),

            # Instagram auth
            PathPrefixRoute('/auth', [
                webapp2.Route('/instagram',
                              name='auth-instagram',
                              handler='AuthInstagramHandler'),
                webapp2.Route('/flickr',
                              name='auth-flickr',
                              handler='AuthFlickrHandler'),
                webapp2.Route('/facebook',
                              name='auth-facebook',
Beispiel #15
0
 PathPrefixRoute(
     '/api',
     [
         PathPrefixRoute('/alfa', [
             Route('/registration', alfa_bank.PreCheckHandler),
             Route('/check', alfa_bank.CheckStatusHandler),
             Route('/create', alfa_bank.CreateByCardHandler),
             Route('/reset', alfa_bank.ResetBlockedSumHandler),
             Route('/pay', alfa_bank.PayByCardHandler),
             Route('/unbind', alfa_bank.UnbindCardHandler),
         ]),
         PathPrefixRoute('/company', [
             PathPrefixRoute('/<company_id:\d+>', [
                 Route('/info', api.NewsHandler),
                 Route('/menu', company.CompanyMenuHandler),
                 Route('/get_remainders', company.RemaindersHandler),
                 Route('/payment_types',
                       company.CompanyPaymentTypesHandler),
                 Route('/promos', promos.CompanyPromosHandler),
                 Route('/user_data', customer.SaveClientInfoHandler),
                 Route('/enter_card', customer.SaveBonusCardHandler),
             ]),
             Route('/get_company', company.CompanyInfoHandler),
         ]),
         Route('/delivery_types', company.CompanyDeliveryTypesHandler
               ),  # it relates to company
         Route('/venues/<company_id:\d+>',
               company.CompanyVenuesHandler),  # it relates to company
         PathPrefixRoute('/venue/<delivery_terminal_id:.*>', [
             Route('/menu', venue.VenueMenuHandler),
             Route('/order/new', order.PlaceOrderHandler),
         ]),
         Route('/payment_types/<delivery_terminal_id:.*>',
               venue.VenuePaymentTypesHandler),  # it relates to venue
         Route('/iiko_promos',
               promos.VenuePromosHandler),  # it relates to venue
         PathPrefixRoute('/order/<order_id:.*>', [
             Route('/request_cancel', order.CancelOrderHandler),
             Route('/review', order.OrderReviewHandler),
             Route('', order.OrderInfoHandler),
         ]),
         Route('/status',
               order.OrdersStatusHandler),  # it relates to order
         Route('/history', order.HistoryHandler),  # it relates to order
         Route('/get_order_promo',
               order.CheckOrderHandler),  # it relates to order
         PathPrefixRoute('/customer', [
             Route('/register', api.RegisterHandler),
         ]),
         PathPrefixRoute('/admin', [
             Route('/login', admin.LoginHandler),
             Route('/logout', admin.LogoutHandler),
             PathPrefixRoute('/orders', [
                 Route('/current', admin.CurrentOrdersHandler),
                 Route('/updates', admin.OrderUpdatesHandler),
                 Route('/cancels', admin.CancelsHandler),
                 Route('/closed', admin.ClosedOrdersHandler),
             ]),
             Route('/menu', admin.MenuHandler),
             Route('/dynamic_info', admin.DynamicInfoHandler),
             Route('/stop_list/items', admin.ItemStopListHandler),
             Route('/customer_history', admin.ClientHistoryHandler),
         ]),
         PathPrefixRoute('/push_admin', [
             Route('/login', api_push_admin.LoginHandler,
                   'push_admin_login'),
             Route('/logout', api_push_admin.LogoutHandler),
             Route('/pushes', api_push_admin.PushSendingHandler,
                   'pushes'),
             Route('/history', api_push_admin.PushHistoryHandler,
                   'admin_push_history'),
             Route('/menu_reload', api_push_admin.ReloadMenuHandler),
         ]),
         PathPrefixRoute('/specials', [
             PathPrefixRoute('/mivako_gift', [
                 Route('/info', specials.MivakoPromoInfoHandler),
                 Route('/send', specials.MivakoPromoSendGiftHandler),
             ]),
             Route('/cat_add_social', specials.CATAddSocialHandler),
             Route('/cat_places', specials.CATFetchCoffeeShopsHandler),
             Route('/cat_company_id', specials.CATGetCompanyIdHandler),
             Route('/cat_company_id_2',
                   specials.CATGetCompanyIdHandler2),
         ]),
         PathPrefixRoute('/shared', [
             PathPrefixRoute('/invitation', [
                 Route('/info', specials.InvitationInfoHandler),
                 Route('/get_url', specials.InvitationUrlsHandler),
             ]),
             PathPrefixRoute('/gift', [
                 Route('/get_url', specials.GiftUrlHandler),
             ]),
         ]),
         PathPrefixRoute('/recommendation', [
             Route('/by_item', specials.ItemRecommendationHandler),
         ]),
         Route('/address', address.AddressByStreetHandler),
         Route('/get_info', trash.GetAddressByKeyHandler),
     ]),
from webapp2_extras.routes import RedirectRoute, PathPrefixRoute

from views import Index
from simple import SimpleTemplateHandler
from tags import TemplateWithTagsHandler
from jinja2 import Jinja2TemplateHandler


routes = [
    RedirectRoute('/template/', Index, name='template_index',
                  strict_slash=True),
    PathPrefixRoute('/template', [
        RedirectRoute('/simple', SimpleTemplateHandler,
                      name='template_simple', methods=['GET'],
                      strict_slash=True),
        RedirectRoute('/with_tags', TemplateWithTagsHandler,
                      name='template_with_tags', methods=['GET'],
                      strict_slash=True),
        RedirectRoute('/jinja2', Jinja2TemplateHandler,
                      name='template_jinja2', methods=['GET'],
                      strict_slash=True),
    ])
]
Beispiel #17
0
import logging
import webapp2
from webapp2_extras.routes import PathPrefixRoute
from google.appengine.ext import ndb

import app.config
from app import tasks
from app.tasks import webhooks

config = {}
config['webapp2_extras.sessions'] = {
    'secret_key': 'ezAK4re16aXlKG80cAMz'
}
application = ndb.toplevel(webapp2.WSGIApplication([
    PathPrefixRoute('/_webhooks', [
        webapp2.Route('/thonkify', webhooks.ThonkifyEndpoint),
        webapp2.Route('/debug', tasks.LogParams)
    ]),
    (r'.*', tasks.NotFound),
], debug=app.config.DEBUG, config=config))


def main():
    logging.getLogger().setLevel(logging.INFO)
    application.run()


if __name__ == "__main__":
    main()
Beispiel #18
0
    def test_with_variables_name_and_handler(self):
        router = webapp2.Router(
            [
                DomainRoute(
                    "<subdomain>.<:.*>",
                    [
                        PathPrefixRoute(
                            r"/user/<username:\w+>",
                            [
                                HandlerPrefixRoute(
                                    "apps.users.",
                                    [
                                        NamePrefixRoute(
                                            "user-",
                                            [
                                                webapp2.Route(
                                                    "/",
                                                    "UserOverviewHandler",
                                                    "overview",
                                                ),
                                                webapp2.Route(
                                                    "/profile",
                                                    "UserProfileHandler",
                                                    "profile",
                                                ),
                                                webapp2.Route(
                                                    "/projects",
                                                    "UserProjectsHandler",
                                                    "projects",
                                                ),
                                            ],
                                        ),
                                    ],
                                ),
                            ],
                        )
                    ],
                ),
            ]
        )

        path = "http://my-subdomain.app-id.appspot.com/user/calvin/"
        match = ((), {"username": "******", "subdomain": "my-subdomain"})
        self.assertEqual(router.match(webapp2.Request.blank(path))[1:], match)
        match[1].pop("subdomain")
        match[1]["_netloc"] = "my-subdomain.app-id.appspot.com"
        self.assertEqual(
            router.build(
                webapp2.Request.blank("/"), "user-overview", match[0], match[1]
            ),
            path,
        )

        path = "http://my-subdomain.app-id.appspot.com/user/calvin/profile"
        match = ((), {"username": "******", "subdomain": "my-subdomain"})
        self.assertEqual(router.match(webapp2.Request.blank(path))[1:], match)
        match[1].pop("subdomain")
        match[1]["_netloc"] = "my-subdomain.app-id.appspot.com"
        self.assertEqual(
            router.build(
                webapp2.Request.blank("/"), "user-profile", match[0], match[1]
            ),
            path,
        )

        path = "http://my-subdomain.app-id.appspot.com/user/calvin/projects"
        match = ((), {"username": "******", "subdomain": "my-subdomain"})
        self.assertEqual(router.match(webapp2.Request.blank(path))[1:], match)
        match[1].pop("subdomain")
        match[1]["_netloc"] = "my-subdomain.app-id.appspot.com"

        self.assertEqual(
            router.build(
                webapp2.Request.blank("/"), "user-projects", match[0], match[1]
            ),
            path,
        )
Beispiel #19
0
#!/usr/bin/env python

import handlers
import webapp2
from webapp2 import Route
from webapp2_extras.routes import PathPrefixRoute
from webapp2_extras.routes import RedirectRoute
from handlers.file_handlers import UploadHandler, ServeHandler

_routes = [
    Route('/', handler = 'handlers.index.MainHandler', name = 'index_uri'),
    Route('/test', handler = 'handlers.test.MainHandler', name = 'test_uri'),
    Route('/upload', UploadHandler),
    Route('/serve/<resource>', ServeHandler),
    PathPrefixRoute('/polls', [
        
    ]),
    PathPrefixRoute('/api', [
        RedirectRoute('/', handler = 'handlers.index.ApiHandler', name = 'api_uri'),
        #GET and POST allowed to this URL - for a get, a specified number of results should be specified to
        # paginate the results returned...
        #GETs a list of polls giving you just id title and description
        #or
        #POSTs a new poll to the server by supplying details of the poll as well as the contestants if applicable
        RedirectRoute('/polls/', handler = 'handlers.poll_handlers.PollsHandler', name = 'polls_uri'),
        #GETs the full details of a particular poll...details such as ownerID, status, etc
        RedirectRoute('/polls/<poll_id:\d+>', handler = 'handlers.poll_handlers.PollHandler', name = 'poll_uri'),
        #GETs the contestants for a particular poll
        RedirectRoute('/polls/<poll_id:\d+>/contestants', handler = 'handlers.poll_handlers.ContestantsHandler', name = 'poll_contestants_uri'),
        #POSTs a vote to a particular poll
        RedirectRoute('/polls/<poll_id:\d+>/vote', handler = 'handlers.vote_handlers.VoteHandler', name = 'vote_uri'),
Beispiel #20
0
from webapp2_extras.routes import RedirectRoute, PathPrefixRoute, DomainRoute
from services import sample_jsonrpc
from web import admin, handlers

_routes = [
    # Sample for administering
    PathPrefixRoute('/admin', [
        RedirectRoute(
            '/', admin.HomeHandler, name='admin-home', strict_slash=True),
    ]),
    PathPrefixRoute(
        '/user',
        [
            RedirectRoute('/login',
                          'web.handlers.LoginHandler',
                          name='user-login',
                          strict_slash=True),
            # Lazy loading sample
            RedirectRoute('/logout',
                          'web.handlers.LogoutHandler',
                          name='user-logout',
                          strict_slash=True)
        ]),

    # Main Routes
    RedirectRoute('/', handlers.HomeHandler, name='home', strict_slash=True),
    # Another Lazy loading sample, will only be loaded once its routed
    RedirectRoute('/rpc',
                  sample_jsonrpc.ApiHandler,
                  name='rpc',
                  strict_slash=True)
Beispiel #21
0
from app.generate_codes import GenerateCodesHandler
from rest_up import ResourceRoutes

from scavenger import TwilioHandler
from app.models.story import Story
from app.models.story_code import StoryCode
from app.models.clue import Clue
from app.models.answer import Answer
from app.models.message import Message
from app.models.group import Group

ROUTES = [
    PathPrefixRoute('/api', [
        ResourceRoutes('stories', Story),
        ResourceRoutes('codes', StoryCode),
        ResourceRoutes('clues', Clue),
        ResourceRoutes('answers', Answer),
        ResourceRoutes('groups', Group),
        ResourceRoutes('messages', Message),
        ResourceRoutes(
            'messages/story/<story_uid:[^/]+>', Message, method='for_story'),
        ResourceRoutes(
            'messages/group/<group_uid:[^/]+>', Message, method='for_group'),
    ]),
    PathPrefixRoute('/admin', [
        Route('/backup', BackupHandler),
        Route('/gen-codes', GenerateCodesHandler),
    ]),
    Route('/twilio', TwilioHandler),
]
Beispiel #22
0
    def test_with_variables_name_and_handler(self):
        router = webapp2.Router(
            [
                PathPrefixRoute(
                    r"/user/<username:\w+>",
                    [
                        HandlerPrefixRoute(
                            "apps.users.",
                            [
                                NamePrefixRoute(
                                    "user-",
                                    [
                                        webapp2.Route(
                                            "/", "UserOverviewHandler", "overview"
                                        ),
                                        webapp2.Route(
                                            "/profile", "UserProfileHandler", "profile"
                                        ),
                                        webapp2.Route(
                                            "/projects",
                                            "UserProjectsHandler",
                                            "projects",
                                        ),
                                    ],
                                ),
                            ],
                        ),
                    ],
                )
            ]
        )

        path = "/user/calvin/"
        match = ((), {"username": "******"})
        self.assertEqual(router.match(webapp2.Request.blank(path))[1:], match)
        self.assertEqual(
            router.build(
                webapp2.Request.blank("/"), "user-overview", match[0], match[1]
            ),
            path,
        )

        path = "/user/calvin/profile"
        match = ((), {"username": "******"})
        self.assertEqual(router.match(webapp2.Request.blank(path))[1:], match)
        self.assertEqual(
            router.build(
                webapp2.Request.blank("/"), "user-profile", match[0], match[1]
            ),
            path,
        )

        path = "/user/calvin/projects"
        match = ((), {"username": "******"})
        self.assertEqual(router.match(webapp2.Request.blank(path))[1:], match)
        self.assertEqual(
            router.build(
                webapp2.Request.blank("/"), "user-projects", match[0], match[1]
            ),
            path,
        )
Beispiel #23
0
                  name='search-update'),

    #app
    webapp2.Route('/search',
                  search_handler.GenericSearchHandler,
                  name='search'),
    PathPrefixRoute('/playgrounds', [
        webapp2.Route('/search',
                      search_handler.PlaygroundSearchHandler,
                      name='pg-search'),
        webapp2.Route(
            '/<city_name>/<locality_name>/<entity_id>/<entity_alias>',
            details_handler.PlaygroundDetailsHandler,
            name='pg-details'),
        webapp2.Route(r'/<city_name>/<locality_name>',
                      search_handler.PlaygroundSearchHandler,
                      name='pg-locality-home'),
        webapp2.Route(r'/<city_name>/<sport>',
                      search_handler.PlaygroundSearchHandler,
                      name='pg-sport-home'),
        webapp2.Route(r'/<city_name>',
                      search_handler.PlaygroundSearchHandler,
                      name='pg-city-home'),
        webapp2.Route(
            '/', search_handler.PlaygroundSearchHandler, name='pg-home'),
    ]),
    PathPrefixRoute('/training-centres', [
        webapp2.Route('/search',
                      search_handler.TrainingCentreSearchHandler,
                      name='tc-search'),
        webapp2.Route(
            '/<city_name>/<locality_name>/<entity_id>/<entity_alias>',
    def get(self):
        """Get a greeting endpoint.
        ---
        description: Get a greeting
        responses:
            200:
                description: A greeting to the client
                schema:
                    $ref: '#/definitions/Greeting'
        """
        self.response.write("hello")


webapp2_config = {
    'webapp2_extras.sessions': {
        'secret_key': 'test',
        'session_max_age': 60 * 60 * 24 * 30,
    }
}

app = webapp2.WSGIApplication([
    ('/delete', DeleteHandler),
    # api v1
    PathPrefixRoute('/v1', [
        Route('/main', MainHandler),
    ]),
], debug=True, config=webapp2_config)


spec.add_path(route=('/hello', HelloHandler))
Beispiel #25
0
__author__ = 'Eric Higgins'
__copyright__ = 'Copyright 2013, Eric Higgins'
__version__ = '0.0.1'
__email__ = '*****@*****.**'

from webapp2 import Route
from webapp2_extras.routes import PathPrefixRoute

from . import handlers

__all__ = ['urls']

urls = [
    Route(r'/health<:/?>', handlers.Health),
    Route(r'/version<:/?>', handlers.Version),
    Route('/appstats', handlers.AppStatsList),
    PathPrefixRoute('/appstats', [
        Route('/', handlers.AppStatsList),
        Route(r'/<timestamp:\w+><:/?>', handlers.AppStats),
    ]),

    # Sample routing for developer reference.
    Route('/todos', handlers.ToDoList),
    PathPrefixRoute('/todos', [
        Route('/', handlers.ToDoList),
        Route(r'/<obj_id:\w+><:/?>', handlers.ToDo),
        Route(r'/<obj_id:\w+>/<prop:\w+><:/?>', handlers.ToDoProperty),
    ]),
]
Beispiel #26
0
# -*- coding: utf-8 -*-

from webapp2_extras.routes import PathPrefixRoute
import spiner
import webapp2
import v1


class DocHandler(spiner.handlers.jsonapi.Handler):
    def get(self):
        self._send({
            '/v1': {},
        })


_routes = [webapp2.Route(r'/', handler=DocHandler)]
_routes.extend(v1.ROUTES)

app = webapp2.WSGIApplication([PathPrefixRoute('/api', _routes)],
                              debug=spiner.config.is_debug_mode())
Beispiel #27
0
from public.term_handler import TermHandler
from public.view_handler import ViewHandler

app = WSGIApplication(
    [
        RedirectRoute('/manage', redirect_to_name='manage-home'
                      ),  #fixes stupid trailing slash thing
        PathPrefixRoute('/manage', [
            Route('/', HomeHandler, 'manage-home'),
            Route('/profile/<term>', InstructorOfficeHandler,
                  'manage-profile-office'),
            Route('/profile', ProfileHandler, 'manage-profile'),
            Route('/syllabus/create', SyllabusCreateHandler,
                  'create-syllabus'),
            Route('/syllabus/<fterm>/<fname>/duplicate', SyllabusCreateHandler,
                  'duplicate-syllabus'),
            Route('/syllabus/<term>/<name>/delete', SyllabusDeleteHandler,
                  'delete-syllabus'),
            Route('/syllabus/<term>/<name>/<step>', SyllabusHandler,
                  'edit-syllabus'),
            Route('/instructor', InstructorViewHandler, 'manage-instructor'),
            Route('/instructor/<iid>/<term>', InstructorOfficeHandler,
                  'manage-instructor-office'),
        ]),
        RedirectRoute(
            '/admin',
            redirect_to_name='admin-home'),  #fixes stupid trailing slash thing
        PathPrefixRoute('/admin', [
            Route('/', AdminHandler, 'admin-home'),
            Route('/<uid>/delete', AdminDeleteHandler, 'admin-delete'),
        ]),
Beispiel #28
0
def get_routes():
    return [
        PathPrefixRoute(
            '/admin',
            [
                Route('/bookings',
                      admin_bookings_handler.AdminBookingsHandler),
                Route('/booking/<operation>/<booking_key>',
                      admin_bookings_handler.AdminBookingDetailHandler),
                Route('/providers', admin.AdminProvidersHandler),
                Route('/patients', admin.AdminPatientsHandler),
                Route('/invites', admin.AdminInvitesHandler),
                Route('/dashboard', admin.AdminDashboardHandler),
                Route('/domain', domain_handler.DomainSetupHandler),
                Route('/domain/<domain>', domain_handler.DomainSetupHandler),
                Route('/domain/<domain>/setup',
                      domain_handler.DomainSetupHandler),
                Route('/data', data_handler.AdminDataHandler),
                Route('/data/stage', data_handler.AdminStageDataHandler),
                Route('/data/delete', data_handler.AdminDeleteDataHandler),
                Route('/site_config/<feature>', admin.AdminSiteConfigHandler),

                # prospects
                Route('/prospects', prospects_handler.AdminProspectsHandler),
                Route('/prospects/search',
                      prospects_handler.AdminProspectsHandler,
                      handler_method='search'),
                Route('/prospects/delete/<prospect_id>',
                      prospects_handler.AdminProspectDeleteHandler),
                Route('/prospects/<prospect_id>',
                      prospects_handler.AdminProspectDetailsHandler),
                Route('/prospects/<prospect_id>/notes/<operation>',
                      prospects_handler.AdminProspectNotesHandler),
                Route('/prospects/<prospect_id>/notes/<operation>/<key>',
                      prospects_handler.AdminProspectNotesHandler),
                Route('/prospects/<prospect_id>/tags',
                      prospects_handler.AdminProspectTagsHandler),
                Route('/prospects/<prospect_id>/employment',
                      prospects_handler.AdminProspectEmploymentTagsHandler),
                Route('/prospects/<prospect_id>/campaign',
                      prospects_handler.AdminProspectAddToCampaignHandler),

                # campaigns
                Route('/campaigns', campaign_handler.AdminCampaignsHandler),
                Route('/campaign/delete/<campaign_key>',
                      campaign_handler.AdminCampaignDeleteHandler),
                Route('/campaign/<campaign_key>',
                      campaign_handler.AdminCampaignDetailsHandler),
                Route('/campaign/<campaign_key>/prospects',
                      campaign_handler.AdminCampaignDetailsHandler,
                      methods=['GET'],
                      handler_method='edit_prospects_get'),
                Route('/campaign/<campaign_key>/prospects',
                      campaign_handler.AdminCampaignDetailsHandler,
                      methods=['POST'],
                      handler_method='edit_prospects_post'),
                Route('/campaign/<campaign_key>/emails',
                      campaign_handler.AdminCampaignDetailsHandler,
                      handler_method='generate_emails_get'),
                Route('/campaign/<campaign_key>/email/<prospect_id>',
                      campaign_handler.AdminCampaignDetailsHandler,
                      handler_method='display_single_email_get'),
                Route('/campaign/<campaign_key>/sent/<prospect_id>',
                      campaign_handler.AdminCampaignDetailsHandler,
                      handler_method='mark_as_sent_post'),
                PathPrefixRoute(
                    '/provider',
                    [
                        # provider admin
                        Route('/admin/<vanity_url>',
                              provider_admin.ProviderAdministrationHandler),

                        # custom domain
                        Route('/vanitydomain/<vanity_url>',
                              provider_admin.ProviderDomainHandler),

                        # custom domain
                        Route('/forcefriends/<vanity_url>',
                              provider_admin.ProviderForceFriendsHandler),

                        # change password
                        Route('/changepassword/<vanity_url>',
                              provider_admin.ProviderChangePasswordHandler),

                        # generate claim
                        Route('/generateclaim/<vanity_url>',
                              provider_admin.ProviderGenerateClaimHandler),

                        # set domain
                        Route('/canonicaldomain/<vanity_url>',
                              provider_admin.ProviderDomainSetupHandler),

                        # logs
                        Route('/logs/<vanity_url>',
                              provider_admin.ProviderEventLogHandler),
                        Route('/feature/<feature_switch>/<vanity_url>',
                              provider_admin.ProviderFeaturesHandler),
                    ]),
            ]),
    ]
Beispiel #29
0
def get_rules():
    """Returns a list of URL rules for the Hello, World! application.

    .param app.
        The WSGI application instance.
    .return.
        A list of class.`tipfy.Rule` instances.
    """
    rules = [
        Route('/tsk/email_task',
              name='backend/email_task',
              handler='apps.backend.email.SendTask'),
        Route('/tsk/run_ipn/<account>',
              name='billing/payment/download',
              handler='apps.backend.payment.Download'),
        Route('/tsk/run_invoicer',
              name='billing/payment/run_invoicer',
              handler='apps.backend.payment.RunInvoicer'),
        Route('/tsk/update_ipn/<account>',
              name='billing/payment/update_ipn',
              handler='apps.backend.payment.UpdateIPN'),
        Route('/tsk/que_onda/<key>',
              name='billing/payment/que_onda',
              handler='apps.backend.payment.QueOnda'),

        # Todas las rutas de billing
        PathPrefixRoute('/billing', [
            PathPrefixRoute('/payment', [
                Route('/<invoice>/payment-cancel',
                      name='billing/payment/cancel',
                      handler='apps.backend.payment.Cancel'),
                Route('/<invoice>/payment-done',
                      name='billing/payment/done',
                      handler='apps.backend.payment.Done'),
                Route('/<invoice>/payment-pending',
                      name='billing/payment/pending',
                      handler='apps.backend.payment.Pending'),
            ]),
        ]),

        # Todas las rutas de administracion
        Route('/admin',
              name='backend/index/',
              handler='apps.backend.auth.Index'),
        PathPrefixRoute('/admin', [
            Route('/', name='backend/auth/',
                  handler='apps.backend.auth.Index'),
            Route('/help',
                  name='backend/help',
                  handler='apps.backend.help.Index'),
            Route('/login',
                  name='backend/auth/login',
                  handler='apps.backend.auth.Login'),
            Route('/signup',
                  name='backend/auth/signup',
                  handler='apps.backend.auth.SignUp'),
            Route('/signup/<promo>',
                  name='backend/auth/signup/promo',
                  handler='apps.backend.auth.SignUp'),
            Route('/logout',
                  name='backend/auth/logout',
                  handler='apps.backend.auth.Logout'),
            Route('/restore/password/<key>',
                  name='backend/auth/restore',
                  handler='apps.backend.auth.RestorePassword'),
            Route('/unrestore/password/<key>',
                  name='backend/auth/unrestore',
                  handler='apps.backend.auth.UnRestorePassword'),
            Route('/restore/request',
                  name='backend/auth/restore/request',
                  handler='apps.backend.auth.RestorePasswordRequest'),
            Route('/validate/<key>',
                  name='backend/validate/user',
                  handler='apps.backend.auth.ValidateUser'),
            PathPrefixRoute('/consultas', [
                Route('/list',
                      name='backend/consultas/list',
                      handler='apps.backend.consultas.Index'),
                Route('/list/<page>',
                      name='backend/consultas/list/page',
                      handler='apps.backend.consultas.Index:page'),
            ]),
            PathPrefixRoute('/realestate', [
                Route('/edit',
                      name='backend/realestate/edit',
                      handler='apps.backend.realestate.Edit'),
                Route('/request_import',
                      name='backend/realestate/request_import',
                      handler='apps.backend.realestate.RequestImport'),
            ]),
            PathPrefixRoute('/website', [
                Route('/edit',
                      name='backend/realestate_website/edit',
                      handler='apps.backend.realestate_website.Edit'),
                Route('/validate_domain_id',
                      name='backend/realestate_website/check_domain_id',
                      handler='apps.backend.realestate_website.CheckDomainId'),
                Route('/set_theme/<theme>',
                      name='backend/realestate_website/set_theme',
                      handler='apps.backend.realestate_website.Edit:set_theme')
            ]),
            PathPrefixRoute('/inmobiliarias_amigas', [
                Route('/list',
                      name='backend/realestatebook/list',
                      handler='apps.backend.realestatebook.Index'),
                Route('/requests',
                      name='backend/realestatebook/requests',
                      handler='apps.backend.realestatebook.Requests'),
                Route('/friends',
                      name='backend/realestatebook/friends',
                      handler='apps.backend.realestatebook.Friends'),
                Route('/friends/delete/<key>',
                      name='backend/realestatebook/friends/delete',
                      handler='apps.backend.realestatebook.Friends:delete'),
                Route('/friends/share/<key>',
                      name='backend/realestatebook/friends/share',
                      handler='apps.backend.realestatebook.Friends:share'),
                Route('/friends/unshare/<key>',
                      name='backend/realestatebook/friends/unshare',
                      handler='apps.backend.realestatebook.Friends:unshare'),
                Route('/friend_request',
                      name='backend/realestatebook/friend_request',
                      handler='apps.backend.realestatebook.FriendRequest'),
                Route(
                    '/friend_request/accept/<key>',
                    name='backend/realestatebook/friend_request/accept',
                    handler='apps.backend.realestatebook.FriendRequest:accept'
                ),
                Route(
                    '/friend_request/reject/<key>',
                    name='backend/realestatebook/friend_request/reject',
                    handler='apps.backend.realestatebook.FriendRequest:reject'
                ),
            ]),
            PathPrefixRoute('/user', [
                Route('/edit',
                      name='backend/user/edit',
                      handler='apps.backend.user.Edit'),
                Route('/change_password',
                      name='backend/user/change_password',
                      handler='apps.backend.user.Edit:password'),
            ]),
            PathPrefixRoute('/property', [
                Route('/new',
                      name='property/new',
                      handler='apps.backend.property.NewEdit'),
                Route('/<key>/edit/',
                      name='property/edit',
                      handler='apps.backend.property.NewEdit'),
                Route('/list',
                      name='property/list',
                      handler='apps.backend.property.List'),
                Route('/list/<page>',
                      name='property/listpage',
                      handler='apps.backend.property.List'),
                Route('/update_index',
                      name='property/update_index',
                      handler='apps.backend.property.UpdateIndex'),
                Route('/<key>/images',
                      name='property/images',
                      handler='apps.backend.property.Images'),
                Route('/<key>/remove',
                      name='property/remove',
                      handler='apps.backend.property.Remove'),
                Route('/remove',
                      name='property/bulkremove',
                      handler='apps.backend.property.Remove'),
                Route('/<key>/restore',
                      name='property/restore',
                      handler='apps.backend.property.Restore'),
                Route('/<key>/publish/<yes>',
                      name='property/publish',
                      handler='apps.backend.property.Publish'),
            ]),
            PathPrefixRoute('/images', [
                Route('/reorder',
                      name='images/reorder',
                      handler='apps.backend.images.Reorder'),
                Route('/<key>/upload/',
                      name='images/upload',
                      handler='apps.backend.images.Upload'),
                Route('/<key>/remove/',
                      name='images/remove',
                      handler='apps.backend.images.Remove'),
                Route('/<key>/bulkremove/',
                      name='images/bulkremove',
                      handler='apps.backend.images.Remove'),
            ]),
            PathPrefixRoute('/account', [
                Route('/status',
                      name='backend/account/status',
                      handler='apps.backend.account.Status'),
            ]),
        ])
    ]

    return rules
Beispiel #30
0
from webapp2_extras.routes import RedirectRoute
from webapp2_extras.routes import PathPrefixRoute
import users

_routes = [
    PathPrefixRoute('/admin', [
        RedirectRoute(
            '/logout/', users.Logout, name='admin-logout', strict_slash=True),
        RedirectRoute(
            '/geochart/', users.Geochart, name='geochart', strict_slash=True),
        RedirectRoute(
            '/users/', users.List, name='user-list', strict_slash=True),
        RedirectRoute('/users/<user_id>/',
                      users.Edit,
                      name='user-edit',
                      strict_slash=True,
                      handler_method='edit')
    ])
]


def get_routes():
    return _routes


def add_routes(app):
    for r in _routes:
        app.router.add(r)