root/gp/zope/xml/talesapi.py

Revision 261, 0.8 KB (checked in by gawel, 21 months ago)

tales implementation of xml tree

Line  
1 # -*- coding: utf-8 -*-
2 from zope.interface import implements
3 from zope.tales.interfaces import ITALESFunctionNamespace
4
5 class BaseAPI(object):
6     """
7     """
8     def __init__(self, context):
9         self.context = context
10
11     def setEngine(self, engine):
12         self._engine = engine
13
14 class FindAPI(BaseAPI):
15     implements(ITALESFunctionNamespace)
16     def __getattr__(self,attr):
17         if attr.startswith('_'):
18             return self.__dict__[attr]
19         return self.context.find(attr)
20
21 class FindAllAPI(BaseAPI):
22     implements(ITALESFunctionNamespace)
23     def __getattr__(self,attr):
24         if attr.startswith('_'):
25             return self.__dict__[attr]
26         return self.context.findall(attr)
27
28 if __name__ == '__main__':
29     import doctest
30     doctest.testmod()
Note: See TracBrowser for help on using the browser.