Esempio n. 1
0
 def application_url(self, name=None):
     """Return the URL of the nearest enclosing `grok.Application`."""
     obj = self.context.context
     while obj is not None:
         if isinstance(obj, grok.Application):
             return url(self.request, obj, name)
         obj = obj.__parent__
     raise ValueError("No application found.")
Esempio n. 2
0
    def url(self, obj=None, name=None, data=None):
        """Return string for the URL based on the obj and name. The data
        argument is used to form a CGI query string.
        """
        if isinstance(obj, basestring):
            if name is not None:
                raise TypeError(
                    'url() takes either obj argument, obj, string arguments, '
                    'or string argument')
            name = obj
            obj = None

        if obj is None:
            obj = self.context
        if data is None:
            data = {}
        else:
            if not isinstance(data, dict):
                raise TypeError('url() data argument must be a dict.')

        return util.url(self.request, obj, name, data=data)
Esempio n. 3
0
def application_url(request, obj, name=None, data={}):
    """Return the URL of the nearest enclosing `grok.Application`.

    Raises ValueError if no Application can be found.
    """
    return url(request, getApplication(), name, data)
Esempio n. 4
0
def application_url(request, obj, name=None, skin=ASIS, data={}):
    """Return the URL of the nearest enclosing :class:`grok.Application`.

    Raises :exc:`ValueError` if no application can be found.
    """
    return url(request, getApplication(), name=name, skin=skin, data=data)
Esempio n. 5
0
File: util.py Progetto: sshyran/grok
def application_url(request, obj, name=None, skin=ASIS, data={}):
    """Return the URL of the nearest enclosing :class:`grok.Application`.

    Raises :exc:`ValueError` if no application can be found.
    """
    return url(request, getApplication(), name=name, skin=skin, data=data)
Esempio n. 6
0
 def application_url(self, name=None, data={}):
     """Return the URL of the nearest enclosing `grok.Application`.
     """
     return url(self.request, getApplication(), name=name, data=data)