File: ajax.txt

package info (click to toggle)
pyquery 1.2.1-1
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 308 kB
  • sloc: python: 1,428; makefile: 2
file content (56 lines) | stat: -rw-r--r-- 1,368 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
:mod:`pyquery.ajax` -- PyQuery AJAX extension
=============================================

.. automodule:: pyquery.ajax


.. fake imports

    >>> from ajax import PyQuery as pq

You can query some wsgi app if `WebOb`_ is installed (it's not a pyquery
dependencie). IN this example the test app returns a simple input at `/` and a
submit button at `/submit`::

    >>> d = pq('<form></form>', app=input_app)
    >>> d.append(d.get('/'))
    [<form>]
    >>> print d
    <form><input name="youyou" type="text" value=""/></form>

The app is also available in new nodes::

    >>> d.get('/').app is d.app is d('form').app
    True

You can also request another path::

    >>> d.append(d.get('/submit'))
    [<form>]
    >>> print d
    <form><input name="youyou" type="text" value=""/><input type="submit" value="OK"/></form>

If `Paste`_ is installed, you are able to get url directly with a `Proxy`_ app::

    >>> a = d.get('http://packages.python.org/pyquery/')
    >>> a
    [<html>]

You can retrieve the app response::

    >>> print a.response.status
    200 OK

The response attribute is a `WebOb`_ `Response`_

.. _webob: http://pythonpaste.org/webob/
.. _response: http://pythonpaste.org/webob/#response
.. _paste: http://pythonpaste.org/
.. _proxy: http://pythonpaste.org/modules/proxy.html#paste.proxy.Proxy

Api
---

.. autoclass:: PyQuery
   :members: