PageRenderTime 16ms CodeModel.GetById 14ms app.highlight 1ms RepoModel.GetById 0ms app.codeStats 0ms

/cheeseprism/resources.py

http://github.com/SurveyMonkey/CheesePrism
Python | 36 lines | 7 code | 6 blank | 23 comment | 0 complexity | cd7a647ad5e490c747b7c5b8b9318ed8 MD5 | raw file
 1#from pyramid.url import resource_url
 2
 3class BaseResource(dict):
 4    """
 5    Base class for resources
 6    """
 7
 8##     @property
 9##     def approot(self):
10##         return self.recurse_parent(App)
11            
12##     def recurse_parents(self, klass, parent=None):
13##         if parent is None:
14##             parent = self.__parent__
15##         else:
16##             parent = parent.__parent__
17##         if parent is None:
18##             # we've rooted out
19##             return None
20##         if isinstance(parent, klass):
21##             return parent
22##         return self.recurse_parent(klass, parent)
23    
24##     def suburls(self, request):
25##         for name in sorted(self):
26##             obj = self[name]
27##             url = resource_url(self, request, name)
28##             yield obj, url
29
30
31class App(BaseResource):
32    __name__ = ''
33    __parent__ = None
34    
35    def __init__(self, request):
36        self.request = request