Example #1
0
def make_rules():
    return [
        EndpointPrefix('groupy/', [
            Rule('/', endpoint='index'),
            Rule('/add_group', endpoint='add_group'),
            Rule('/edit_group', endpoint='edit_group'),
            Rule('/group_detail', endpoint='group_detail'),
        ]),
    ]
Example #2
0
def test_rule_templates():
    """Rule templates"""
    testcase = RuleTemplate(
        [ Submount('/test/$app',
          [ Rule('/foo/', endpoint='handle_foo')
          , Rule('/bar/', endpoint='handle_bar')
          , Rule('/baz/', endpoint='handle_baz')
          ]),
          EndpointPrefix('foo_',
          [ Rule('/blah', endpoint='bar')
          , Rule('/meh', endpoint='baz')
          ]),
          Subdomain('meh',
          [ Rule('/blah', endpoint='x_bar')
          , Rule('/meh', endpoint='x_baz')
          ])
        ])

    url_map = Map(
        [ testcase(app='test1')
        , testcase(app='test2')
        , testcase(app='test3')
        , testcase(app='test4')
        ])

    out = [(x.rule, x.subdomain, x.endpoint)
           for x in url_map.iter_rules()]
    assert out == (
        [ ('/test/test1/foo/', '', 'handle_foo')
        , ('/test/test1/bar/', '', 'handle_bar')
        , ('/test/test1/baz/', '', 'handle_baz')
        , ('/blah', '', 'foo_bar')
        , ('/meh', '', 'foo_baz')
        , ('/blah', 'meh', 'x_bar')
        , ('/meh', 'meh', 'x_baz')
        , ('/test/test2/foo/', '', 'handle_foo')
        , ('/test/test2/bar/', '', 'handle_bar')
        , ('/test/test2/baz/', '', 'handle_baz')
        , ('/blah', '', 'foo_bar')
        , ('/meh', '', 'foo_baz')
        , ('/blah', 'meh', 'x_bar')
        , ('/meh', 'meh', 'x_baz')
        , ('/test/test3/foo/', '', 'handle_foo')
        , ('/test/test3/bar/', '', 'handle_bar')
        , ('/test/test3/baz/', '', 'handle_baz')
        , ('/blah', '', 'foo_bar')
        , ('/meh', '', 'foo_baz')
        , ('/blah', 'meh', 'x_bar')
        , ('/meh', 'meh', 'x_baz')
        , ('/test/test4/foo/', '', 'handle_foo')
        , ('/test/test4/bar/', '', 'handle_bar')
        , ('/test/test4/baz/', '', 'handle_baz')
        , ('/blah', '', 'foo_bar')
        , ('/meh', '', 'foo_baz')
        , ('/blah', 'meh', 'x_bar')
        , ('/meh', 'meh', 'x_baz') ]
    )
Example #3
0
 def get_rules(self, app=None):
     if self.add_app_prefix_to_endpoint and app is not None:
         ret = [EndpointPrefix(app + '/', self._get_rules())]
     else:
         ret = self._get_rules()
     if self.url_prefix:
         return [Submount(self.url_prefix, ret)]
     else:
         return ret
Example #4
0
def make_rules():
    return [
        EndpointPrefix('www/', [
            Rule('/', endpoint='index'),
            Rule('/WorldWordWeb.html', endpoint='toindex'),
            Rule('/TwitterXDomainSample.html', endpoint='txd'),
            Rule('/gateway', endpoint='gateway'),
            Rule('/crossdomain.xml', endpoint='crossdomain'),
            Rule('/oauth', endpoint='oauth'),
            Rule('/oauth_cb', endpoint='oauth_cb'),
            Rule('/redirect', endpoint='redirect'),
            Rule('/morpho', endpoint='morpho'),
        ]),
    ]
Example #5
0
# Copyright 2013 Donald Stufft
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
from __future__ import absolute_import, division, print_function
from __future__ import unicode_literals

from werkzeug.routing import Rule, EndpointPrefix

urls = [
    EndpointPrefix("warehouse.accounts.views.", [
        Rule(
            "/user/<username>/",
            methods=["GET"],
            endpoint="user_profile",
        ),
    ]),
]
Example #6
0
# Copyright 2013 Donald Stufft
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
from __future__ import absolute_import, division, print_function
from __future__ import unicode_literals

from werkzeug.routing import Rule, EndpointPrefix, Submount

urls = [
    EndpointPrefix("warehouse.legacy.simple.", [
        Submount("/simple", [
            Rule("/", methods=["GET"], endpoint="index"),
            Rule("/<project_name>/", methods=["GET"], endpoint="project"),
        ]),
        Rule("/packages/<path:path>", methods=["GET"], endpoint="package"),
    ]),
    EndpointPrefix("warehouse.legacy.pypi.", [
        Rule("/pypi", methods=["GET", "POST"], endpoint="pypi"),
    ]),
]
Example #7
0
from werkzeug.routing import Map, Rule, Subdomain, Submount, EndpointPrefix

m = Map([
    # Static URLs
    EndpointPrefix('static/', [
        Rule('/', endpoint='index'),
        Rule('/about', endpoint='about'),
        Rule('/help', endpoint='help'),
    ]),
    # Knowledge Base
    Subdomain('kb', [EndpointPrefix('kb/', [
        Rule('/', endpoint='index'),
        Submount('/browse', [
            Rule('/', endpoint='browse'),
            Rule('/<int:id>/', defaults={'page': 1}, endpoint='browse'),
            Rule('/<int:id>/<int:page>', endpoint='browse')
        ])
    ])])
])
Example #8
0
# Copyright 2013 Donald Stufft
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

from werkzeug.routing import Rule, EndpointPrefix

urls = [
    EndpointPrefix("warehouse.packaging.views.", [
        Rule(
            "/project/<project_name>/",
            methods=["GET"],
            endpoint="project_detail",
        ),
        Rule(
            "/project/<project_name>/<version>/",
            methods=["GET"],
            endpoint="project_detail",
        ),
    ]),
]
Example #9
0
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

from werkzeug.routing import Rule, EndpointPrefix

urls = [
    EndpointPrefix("warehouse.accounts.views.", [
        Rule(
            "/account/login/",
            methods=["GET", "POST"],
            endpoint="login",
        ),
        Rule(
            "/account/logout/",
            methods=["GET", "POST"],
            endpoint="logout",
        ),
        Rule(
            "/user/<username>/",
            methods=["GET"],
            endpoint="user_profile",
        ),
    ]),
]
Example #10
0
from werkzeug.routing import Map, Rule, EndpointPrefix

routes = [
    EndpointPrefix('index|', [Rule('/', endpoint='index')]),
    EndpointPrefix('login|', [
        Rule('/login/g',
             defaults={'original_url': ''},
             endpoint='g_request',
             methods=['GET']),
        Rule('/login/g/<path:original_url>',
             endpoint='g_request',
             methods=['GET']),
        Rule('/login/callback/g', endpoint='g_callback', methods=['GET']),
        Rule('/login/twitter',
             defaults={'original_url': ''},
             endpoint='twitter_request',
             methods=['GET']),
        Rule('/login/twitter/<path:original_url>',
             endpoint='twitter_request',
             methods=['GET']),
        Rule('/login/callback/twitter',
             defaults={'original_url': ''},
             endpoint='twitter_callback',
             methods=['GET']),
        Rule('/login/callback/twitter/<path:original_url>',
             endpoint='twitter_callback',
             methods=['GET']),
        Rule('/login/fb',
             defaults={'original_url': ''},
             endpoint='fb_request',
             methods=['GET']),
Example #11
0
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

from werkzeug.routing import Rule, EndpointPrefix, Submount

urls = [
    EndpointPrefix("warehouse.legacy.simple.", [
        Submount("/simple", [
            Rule("/", methods=["GET"], endpoint="index"),
            Rule("/<project_name>/", methods=["GET"], endpoint="project"),
        ]),
        Rule("/packages/<path:path>", methods=["GET"], endpoint="package"),
    ]),
    EndpointPrefix("warehouse.legacy.pypi.", [
        Rule("/pypi", methods=["GET", "POST"], endpoint="pypi"),
        Rule("/pypi/<project_name>/json", methods=["GET"],
             endpoint="project_json"),
        Rule("/pypi/<project_name>/<version>/json", methods=["GET"],
             endpoint="project_json"),
        Rule("/daytime", methods=["GET"], endpoint="daytime"),
    ]),
    EndpointPrefix("warehouse.legacy.xmlrpc.", [
        Rule("/_legacy/xmlrpc/", methods=["POST"], endpoint="handler"),
    ]),
]
from werkzeug.routing import EndpointPrefix
from werkzeug.routing import Map
from werkzeug.routing import Rule
from werkzeug.routing import Subdomain
from werkzeug.routing import Submount

m = Map([
    # Static URLs
    EndpointPrefix(
        "static/",
        [
            Rule("/", endpoint="index"),
            Rule("/about", endpoint="about"),
            Rule("/help", endpoint="help"),
        ],
    ),
    # Knowledge Base
    Subdomain(
        "kb",
        [
            EndpointPrefix(
                "kb/",
                [
                    Rule("/", endpoint="index"),
                    Submount(
                        "/browse",
                        [
                            Rule("/", endpoint="browse"),
                            Rule(
                                "/<int:id>/",
                                defaults={"page": 1},