Skip to content

Commit

Permalink
Merge pull request #590 from untitaker/url_classdoc
Browse files Browse the repository at this point in the history
Document ``werkzeug.urls`` in full detail.
  • Loading branch information
untitaker committed Sep 5, 2014
2 parents 0bacba6 + 8841b96 commit afc2c67
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 30 deletions.
1 change: 1 addition & 0 deletions docs/contents.rst.inc
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ Reference
http
datastructures
utils
urls
local
middlewares
exceptions
Expand Down
6 changes: 6 additions & 0 deletions docs/urls.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
===========
URL Helpers
===========

.. automodule:: werkzeug.urls
:members:
27 changes: 1 addition & 26 deletions docs/utils.rst
Original file line number Diff line number Diff line change
Expand Up @@ -49,32 +49,7 @@ General Helpers
URL Helpers
===========

.. module:: werkzeug.urls

.. autoclass:: Href

.. autofunction:: url_decode

.. autofunction:: url_decode_stream

.. autofunction:: url_encode

.. autofunction:: url_encode_stream

.. autofunction:: url_quote

.. autofunction:: url_quote_plus

.. autofunction:: url_unquote

.. autofunction:: url_unquote_plus

.. autofunction:: url_fix

.. autofunction:: uri_to_iri

.. autofunction:: iri_to_uri

Please refer to :doc:`urls`.

UserAgent Parsing
=================
Expand Down
16 changes: 12 additions & 4 deletions werkzeug/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,14 @@
werkzeug.urls
~~~~~~~~~~~~~
This module implements various URL related functions.
``werkzeug.urls`` used to provide several wrapper functions for Python 2
urlparse, whose main purpose were to work around the behavior of the Py2
stdlib and its lack of unicode support. While this was already a somewhat
inconvenient situation, it got even more complicated because Python 3's
``urllib.parse`` actually does handle unicode properly. In other words,
this module would wrap two libraries with completely different behavior. So
now this module contains a 2-and-3-compatible backport of Python 3's
``urllib.parse``, which is mostly API-compatible.
:copyright: (c) 2014 by the Werkzeug Team, see AUTHORS for more details.
:license: BSD, see LICENSE for more details.
Expand Down Expand Up @@ -37,7 +44,8 @@
['scheme', 'netloc', 'path', 'query', 'fragment']))


class _URLMixin(object):
class BaseURL(_URLTuple):
'''Superclass of :py:class:`URL` and :py:class:`BytesURL`.'''
__slots__ = ()

def replace(self, **kwargs):
Expand Down Expand Up @@ -268,7 +276,7 @@ def _split_host(self):


@implements_to_string
class URL(_URLTuple, _URLMixin):
class URL(BaseURL):
"""Represents a parsed URL. This behaves like a regular tuple but
also has some extra attributes that give further insight into the
URL.
Expand Down Expand Up @@ -311,7 +319,7 @@ def encode(self, charset='utf-8', errors='replace'):
)


class BytesURL(_URLTuple, _URLMixin):
class BytesURL(BaseURL):
"""Represents a parsed URL in bytes."""
__slots__ = ()
_at = b'@'
Expand Down

0 comments on commit afc2c67

Please sign in to comment.