Did I find the right examples for you? yes no

All Samples(349)  |  Call(262)  |  Derive(0)  |  Import(87)
Generates a URL 

All keys given to url_for are sent to the Routes Mapper instance for 
generation except for::
    
    anchor          specified the anchor name to be appened to the path
    host            overrides the default (current) host if provided
    protocol        overrides the default (current) protocol if provided
    qualified       creates the URL with the host/port information as 
                    needed(more...)

        def url_for(*args, **kargs):
    """Generates a URL 
    
    All keys given to url_for are sent to the Routes Mapper instance for 
    generation except for::
        
        anchor          specified the anchor name to be appened to the path
        host            overrides the default (current) host if provided
        protocol        overrides the default (current) protocol if provided
        qualified       creates the URL with the host/port information as 
                        needed
        
    The URL is generated based on the rest of the keys. When generating a new 
    URL, values will be used from the current request's parameters (if 
    present). The following rules are used to determine when and how to keep 
    the current requests parameters:
    
    * If the controller is present and begins with '/', no defaults are used
    * If the controller is changed, action is set to 'index' unless otherwise 
      specified
    
    For example, if the current request yielded a dict of
    {'controller': 'blog', 'action': 'view', 'id': 2}, with the standard 
    ':controller/:action/:id' route, you'd get the following results::
    
        url_for(id=4)                    =>  '/blog/view/4',
        url_for(controller='/admin')     =>  '/admin',
        url_for(controller='admin')      =>  '/admin/view/2'
        url_for(action='edit')           =>  '/blog/edit/2',
        url_for(action='list', id=None)  =>  '/blog/list'
    
    **Static and Named Routes**
    
    If there is a string present as the first argument, a lookup is done 
    against the named routes table to see if there's any matching routes. The
    keyword defaults used with static routes will be sent in as GET query 
    arg's if a route matches.
    
    If no route by that name is found, the string is assumed to be a raw URL. 
    Should the raw URL begin with ``/`` then appropriate SCRIPT_NAME data will
    be added if present, otherwise the string will be used as the url with 
    keyword args becoming GET query args.
    
    """
    anchor = kargs.get('anchor')
    host = kargs.get('host')
    protocol = kargs.get('protocol')
    qualified = kargs.pop('qualified', None)
    
    # Remove special words from kargs, convert placeholders
    for key in ['anchor', 'host', 'protocol']:
        if kargs.get(key):
            del kargs[key]
    config = request_config()
    route = None
    static = False
    encoding = config.mapper.encoding
    url = ''
    if len(args) > 0:
        route = config.mapper._routenames.get(args[0])
        
        # No named route found, assume the argument is a relative path
        if not route:
            static = True
            url = args[0]
        
        if url.startswith('/') and hasattr(config, 'environ') \
                and config.environ.get('SCRIPT_NAME'):
            url = config.environ.get('SCRIPT_NAME') + url
        
        if static:
            if kargs:
                url += '?'
                query_args = []
                for key, val in kargs.iteritems():
                    if isinstance(val, (list, tuple)):
                        for value in val:
                            query_args.append("%s=%s" % (
                                urllib.quote(unicode(key).encode(encoding)),
                                urllib.quote(unicode(value).encode(encoding))))
                    else:
                        query_args.append("%s=%s" % (
                            urllib.quote(unicode(key).encode(encoding)),
                            urllib.quote(unicode(val).encode(encoding))))
                url += '&'.join(query_args)
    environ = getattr(config, 'environ', {})
    if 'wsgiorg.routing_args' not in environ:
        environ = environ.copy()
        mapper_dict = getattr(config, 'mapper_dict', None)
        if mapper_dict is not None:
            match_dict = mapper_dict.copy()
        else:
            match_dict = {}
        environ['wsgiorg.routing_args'] = ((), match_dict)
    
    if not static:
        route_args = []
        if route:
            if config.mapper.hardcode_names:
                route_args.append(route)
            newargs = route.defaults.copy()
            newargs.update(kargs)
            
            # If this route has a filter, apply it
            if route.filter:
                newargs = route.filter(newargs)
            
            if not route.static:
                # Handle sub-domains
                newargs = _subdomain_check(newargs, config.mapper, environ)
        else:
            newargs = _screenargs(kargs, config.mapper, environ)
        anchor = newargs.pop('_anchor', None) or anchor
        host = newargs.pop('_host', None) or host
        protocol = newargs.pop('_protocol', None) or protocol
        url = config.mapper.generate(*route_args, **newargs)
    if anchor is not None:
        url += '#' + _url_quote(anchor, encoding)
    if host or protocol or qualified:
        if not host and not qualified:
            # Ensure we don't use a specific port, as changing the protocol
            # means that we most likely need a new port
            host = config.host.split(':')[0]
        elif not host:
            host = config.host
        if not protocol:
            protocol = config.protocol
        if url is not None:
            url = protocol + '://' + host + url
    
    if not ascii_characters(url) and url is not None:
        raise GenerationException("url_for can only return a string, got "
                        "unicode instead: %s" % url)
    if url is None:
        raise GenerationException(
            "url_for could not generate URL. Called with args: %s %s" % \
            (args, kargs))
    return url
        


src/c/k/ckan-2.2/ckan/lib/alphabet_paginate.py   ckan(Download)
from sqlalchemy.orm.query import Query
from webhelpers.html.builder import HTML
from routes import url_for
 
 
        page = q or self.page
        for letter in self.letters:
            href = url_for(controller=self.controller_name, action='index', page=letter)
            link = HTML.a(href=href, c=letter)
            if letter != page:

src/c/k/ckan-HEAD/ckan/lib/alphabet_paginate.py   ckan(Download)
from sqlalchemy.orm.query import Query
from webhelpers.html.builder import HTML
from routes import url_for
 
 
        page = q or self.page
        for letter in self.letters:
            href = url_for(controller=self.controller_name, action='index', page=letter)
            link = HTML.a(href=href, c=letter)
            if letter != page:

src/g/i/gibe-0.12.4/gibe/feeds.py   gibe(Download)
        # front page in gibe.blog_base in the configuration.  Otherwise, the
        # front page will be used.
        blog_base = cherrypy.config.get("gibe.blog_base", routes.url_for("frontpage", host=host))
 
        return dict(
                dict(title=post.title, content=post.content, summary=post.excerpt, updated = post.modification_time, published = post.creation_time,
                author=dict(name=post.author.display_name),
                link=routes.url_for('posts', post=post, host=host),
                id=routes.url_for('posts', post=post, host=host)) for post in last_entries],
        )
        feed = self.get_feed_data(**kwargs)
        self.format_dates(feed, 3339)
        feed["id"] = routes.url_for('atom1_0', host=host)
        feed["href"] = routes.url_for('atom1_0', host=host)
        self.depr_entrys(feed)

src/s/p/spline-pokedex-HEAD/splinext/pokedex/__init__.py   spline-pokedex(Download)
 
from pylons import config, tmpl_context as c
from routes import url_for as url
from sqlalchemy.orm.exc import MultipleResultsFound, NoResultFound
 
        # All good, return the structure now
        return [
            TranslatablePluginLink(_(u'Pokédex'), url('/dex'), children=[
                TranslatablePluginLink(_(u'Core pages'), None, children=[
                    TranslatablePluginLink(_(u'Pokémon'), url(controller='dex', action='pokemon_list'), i18n_context='plural', children=[
                        TranslatablePluginLink(_(u'Awesome search'), url(controller='dex_search', action='pokemon_search')),
                    ]),
                    TranslatablePluginLink(_(u'Moves'), url(controller='dex', action='moves_list'), children=[

src/t/a/TaskTracker-0.4/tasktracker/lib/helpers.py   TaskTracker(Download)
from webhelpers import *
from pylons.util import _, log, set_lang, get_lang
from routes import url_for
from pylons import Response, c, g, cache, request, session, config
from tasktracker.models import Task, TaskList, Comment
    tr.append('editable_title = "%s" ' % editable_title)
    if is_preview:
        tr.append("""onclick = "window.location.href = '%s'" """ % url_for(controller='task', action='show', id=id))
    tr.append('class = "taskrow task-item ')
    if has_permission('task', 'update', id=id):

src/p/u/pub-dartlang-HEAD/app/handlers/cloud_storage.py   pub-dartlang(Download)
            self._url = "https://storage.googleapis.com"
        else:
            self._url = routes.url_for(controller="api.versions",
                                       action="upload",
                                       qualified=True)

src/c/k/ckanext-dgu-HEAD/ckanext/dgu/lib/alphabet_paginate_large.py   ckanext-dgu(Download)
from pylons.i18n import _
from webhelpers.html.builder import HTML
from routes import url_for
 
from ckan.lib.alphabet_paginate import AlphaPage
        page = q or self.page
        for letter in self.letters:
            href = url_for(controller=self.controller_name, action='index', page=letter)
            link = HTML.a(href=href, c=letter)
            if letter != page:

src/t/w/twMaps-0.1a0.dev-r720/twMapsSampleAppPylons/twmapssampleapppylons/tests/__init__.py   twMaps(Download)
 
from twmapssampleapppylons.config.routing import *
from routes import request_config, url_for
 
test_file = os.path.join(conf_dir, 'test.ini')

src/c/o/cogen-0.2.1/examples/cogen-irc/CogenIrcApp/cogenircapp/tests/__init__.py   cogen(Download)
import paste.script.appinstall
from paste.deploy import loadapp
from routes import url_for
 
__all__ = ['url_for', 'TestController']

src/c/o/cogen-0.2.1/examples/cogen-chat/ChatApp/chatapp/tests/__init__.py   cogen(Download)
import paste.script.appinstall
from paste.deploy import loadapp
from routes import url_for
 
__all__ = ['url_for', 'TestController']

  1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9  Next