def get_controller(doctype):
 from frappe.model.document import Document
 global _classes
 if (not (doctype in _classes)):
  (module_name, custom) = (frappe.db.get_value(u'DocType', doctype, [u'module', u'custom']) or [u'Core', False])
  if custom:
   _class = Document
  else:
   module = load_doctype_module(doctype, module_name)
   classname = doctype.replace(u' ', u'').replace(u'-', u'')
   if hasattr(module, classname):
    _class = getattr(module, classname)
    if issubclass(_class, BaseDocument):
     _class = getattr(module, classname)
    else:
     raise ImportError, doctype
   else:
    raise ImportError, doctype
  _classes[doctype] = _class
 return _classes[doctype]

def get_controller ( doctype ) : from frappe . model . document import Document global _classes if ( not ( doctype in _classes ) ) : ( module_name , custom ) = ( frappe . db . get_value ( u'DocType' , doctype , [ u'module' , u'custom' ] ) or [ u'Core' , False ] ) if custom : _class = Document else : module = load_doctype_module ( doctype , module_name ) classname = doctype . replace ( u' ' , u'' ) . replace ( u'-' , u'' ) if hasattr ( module , classname ) : _class = getattr ( module , classname ) if issubclass ( _class , BaseDocument ) : _class = getattr ( module , classname ) else : raise ImportError , doctype else : raise ImportError , doctype _classes [ doctype ] = _class return _classes [ doctype ]
returns the **class** object of the given doctype .