~unifield-team/unifield-web/uf-2235

« back to all changes in this revision

Viewing changes to openobject/controllers/_base.py

  • Committer: ame (Tiny)
  • Date: 2010-01-07 07:47:47 UTC
  • Revision ID: ame@tinyerp.com-20100107074747-sqc1cmm24gofqmuh
[REF] separating base API to openobject
[REF] removed all openerp related stuffs from base api

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
 
 
2
class ControllerType(type):
 
3
    
 
4
    def __new__(cls, name, bases, attrs):
 
5
        
 
6
        obj = super(ControllerType, cls).__new__(cls, name, bases, attrs)    
 
7
        path = attrs.get("_cp_path")
 
8
        
 
9
        if "path" in attrs and name != "BaseController":
 
10
            raise Exception("Can't override 'path' attribute.")
 
11
        
 
12
        if path:
 
13
            if not path.startswith("/"):
 
14
                raise Exception("Invalid path '%s', should start with '/'." % (path))
 
15
            
 
16
        return obj
 
17
 
 
18
class BaseController(object):
 
19
    
 
20
    __metaclass__ = ControllerType
 
21
    
 
22
    _cp_path = None
 
23
    
 
24
    def __new__(cls):
 
25
        return super(BaseController, cls).__new__(cls)
 
26
    
 
27
    def _get_path(self):
 
28
        return self._cp_path
 
29
    
 
30
    path = property(_get_path)
 
31