def url(self, obj=None, name=None, data=None): """Return string for the URL based on the obj and name. If no arguments given, construct URL to view itself. If only `obj` argument is given, construct URL to `obj`. If only name is given as the first argument, construct URL to `context/name`. If both object and name arguments are supplied, construct URL to `obj/name`. Optionally pass a `data` keyword argument which gets added to the URL as 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 name is None and obj is None: # create URL to view itself obj = self elif name is not None and obj is None: # create URL to view on context obj = self.context return util.url(self.request, obj, name, data)
def url(self, obj=None, name=None): # if the first argument is a string, that's the name. There should # be no second argument 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 name is None and obj is None: # create URL to view itself obj = self elif name is not None and obj is None: # create URL to view on context obj = self.context return util.url(self.request, obj, name)
def url(self, obj=None, name=None, skin=util.ASIS, data=None): """Return string for the URL based on the obj and name. If no arguments given, construct URL to view itself. If only `obj` argument is given, construct URL to `obj`. If only name is given as the first argument, construct URL to `context/name`. If both object and name arguments are supplied, construct URL to `obj/name`. Optionally pass a `skin` keyword argument. This should be a skin component and the skin's name is taken from this component. The effect of this argument is a leading ``++skin++[skinname]/`` segment in the path-part of the URL. When the argument is not passed, whatever skin is currently set on the request will be effective in the URL. When passing ``None`` whatever skin is currently effective will be removed from the URLs. Optionally pass a `data` keyword argument which gets added to the URL as a CGI query string. """ if isinstance(obj, six.string_types): if name is not None: raise TypeError( 'url() takes either obj argument, obj, string arguments, ' 'or string argument') name = obj obj = None if name is None and obj is None: # create URL to view itself obj = self elif name is not None and obj is None: # create URL to view on context obj = self.context return util.url(self.request, obj, name, skin, data)
def url(self, obj=None, name=None, skin=util.ASIS, data=None): """Return string for the URL based on the obj and name. If no arguments given, construct URL to view itself. If only `obj` argument is given, construct URL to `obj`. If only name is given as the first argument, construct URL to `context/name`. If both object and name arguments are supplied, construct URL to `obj/name`. Optionally pass a `skin` keyword argument. This should be a skin component and the skin's name is taken from this component. The effect of this argument is a leading ``++skin++[skinname]/`` segment in the path-part of the URL. When the argument is not passed, whatever skin is currently set on the request will be effective in the URL. When passing ``None`` whatever skin is currently effective will be removed from the URLs. Optionally pass a `data` keyword argument which gets added to the URL as 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 name is None and obj is None: # create URL to view itself obj = self elif name is not None and obj is None: # create URL to view on context obj = self.context return util.url(self.request, obj, name, skin, data)
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 name is None and obj is None: # create URL to view itself obj = self elif name is not None and obj is None: # create URL to view on context obj = self.context return util.url(self.request, obj, name, data)