paste.url – URL convenience class — Paste v1.7.5 documentation

### Navigation

- index
- modules |
- Paste v1.7.5 documentation »

# `paste.url` – URL convenience class

This module implements a class for handling URLs.

## Module Contents

class `paste.url.` `URL`(url, vars=None, attrs=None, params=None)

      >>> u = URL('http://localhost')
      >>> u
      <URL http://localhost>
      >>> u = u['view']
      >>> str(u)
      'http://localhost/view'
      >>> u['//foo'].param(content='view').html
      '<a href="http://localhost/view/foo">view</a>'
      >>> u.param(confirm='Really?', content='goto').html
      '<a href="http://localhost/view" onclick="return confirm(\'Really?\')">goto</a>'
      >>> u(title='See "it"', content='goto').html
      '<a href="http://localhost/view?title=See+%22it%22">goto</a>'
      >>> u('another', var='fuggetaboutit', content='goto').html
      '<a href="http://localhost/view/another?var=fuggetaboutit">goto</a>'
      >>> u.attr(content='goto').html
      Traceback (most recent call last):
          ....
      ValueError: You must give a content param to <URL http://localhost/view attrs(content="goto")> generate anchor tags
      >>> str(u['foo=bar%20stuff'])
      'http://localhost/view?foo=bar+stuff'

class `paste.url.` `Image`(url, vars=None, attrs=None, params=None)

      >>> i = Image('/images')
      >>> i = i / '/foo.png'
      >>> i.html
      '<img src="/images/foo.png" />'
      >>> str(i['alt=foo'])
      '<img src="/images/foo.png" alt="foo" />'
      >>> i.href
      '/images/foo.png'

### Navigation

- index
- modules |
- Paste v1.7.5 documentation »