pyquery
changeset 78:85aa941b493b
rule / entry_point for deliverance
| author | Gael Pasgrimaud <gael@gawel.org> |
|---|---|
| date | Sat Jan 24 02:59:30 2009 +0100 (18 months ago) |
| parents | 8fc2caef7b4f |
| children | 58b15bae680f |
| files | pyquery/rules.py |
line diff
1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/pyquery/rules.py Sat Jan 24 02:59:30 2009 +0100 1.3 @@ -0,0 +1,31 @@ 1.4 +# -*- coding: utf-8 -*- 1.5 +try: 1.6 + from deliverance.pyref import PyReference 1.7 + from deliverance import rules 1.8 + from ajax import PyQuery as pq 1.9 +except ImportError: 1.10 + pass 1.11 +else: 1.12 + class PyQuery(rules.AbstractAction): 1.13 + """Python function""" 1.14 + name = 'py' 1.15 + def __init__(self, source_location, pyref): 1.16 + self.source_location = source_location 1.17 + self.pyref = pyref 1.18 + 1.19 + def apply(self, content_doc, theme_doc, resource_fetcher, log): 1.20 + self.pyref(pq([content_doc]), pq([theme_doc]), resource_fetcher, log) 1.21 + 1.22 + @classmethod 1.23 + def from_xml(cls, el, source_location): 1.24 + """Parses and instantiates the class from an element""" 1.25 + pyref = PyReference.parse_xml( 1.26 + el, source_location=source_location, 1.27 + default_function='transform') 1.28 + return cls(source_location, pyref) 1.29 + 1.30 + rules._actions['pyquery'] = PyQuery 1.31 + 1.32 + def deliverance_proxy(): 1.33 + import deliverance.proxycommand 1.34 + deliverance.proxycommand.main()
