Esempio n. 1
0
 def resolve_target(target):
     """A class or name of the class representing the other
     side of a relation.  Use the name of the class to avoid
     circular dependencies"""
     if isinstance(target, basestring):
         for mapped_class in _mapper_registry.keys():
             if mapped_class.class_.__name__ == target:
                 return mapped_class.class_
         raise Exception('No mapped class found for target %s'%target)
     return target
Esempio n. 2
0
 def __init__(self, app_admin, entity):
     super(EntityAdmin, self).__init__(app_admin, entity)
     from sqlalchemy.orm.exc import UnmappedClassError
     from sqlalchemy.orm.mapper import _mapper_registry
     try:
         self.mapper = orm.class_mapper(self.entity)
     except UnmappedClassError, exception:
         mapped_entities = [unicode(m) for m in _mapper_registry.keys()]
         logger.error(u'%s is not a mapped class, configured mappers include %s'%(self.entity, u','.join(mapped_entities)),
                      exc_info=exception)
         raise exception
Esempio n. 3
0
 def resolve_target(target):
     """A class or name of the class representing the other
     side of a relation.  Use the name of the class to avoid
     circular dependencies"""
     if isinstance(target, basestring):
         for mapped_class in _mapper_registry.keys():
             if mapped_class.class_.__name__ == target:
                 return mapped_class.class_
         raise Exception('No mapped class found for target %s' %
                         target)
     return target
Esempio n. 4
0
 def __init__(self, app_admin, entity):
     super(EntityAdmin, self).__init__(app_admin, entity)
     from sqlalchemy.orm.exc import UnmappedClassError
     from sqlalchemy.orm.mapper import _mapper_registry
     try:
         self.mapper = orm.class_mapper(self.entity)
     except UnmappedClassError, exception:
         mapped_entities = [unicode(m) for m in _mapper_registry.keys()]
         logger.error(
             u'%s is not a mapped class, configured mappers include %s' %
             (self.entity, u','.join(mapped_entities)),
             exc_info=exception)
         raise exception
Esempio n. 5
0
 def get_admins(self):
     """Should return all admin for which a table and a form view should be displayed,
     by default, returns for all entities their default admin"""
     from sqlalchemy.orm.mapper import _mapper_registry
      
     classes = []
     for mapper in _mapper_registry.keys():
         if hasattr(mapper, 'class_'):
             classes.append( mapper.class_ )
         else:
             raise Exception()
         
     app_admin = self.get_application_admin()
     return [app_admin.get_entity_admin(c) for c in classes if app_admin.get_entity_admin(c)]
Esempio n. 6
0
    def get_admins(self):
        """Should return all admin for which a table and a form view should be displayed,
        by default, returns for all entities their default admin"""
        from sqlalchemy.orm.mapper import _mapper_registry

        classes = []
        for mapper in _mapper_registry.keys():
            if hasattr(mapper, 'class_'):
                classes.append(mapper.class_)
            else:
                raise Exception()

        app_admin = self.get_application_admin()
        return [
            app_admin.get_entity_admin(c) for c in classes
            if app_admin.get_entity_admin(c)
        ]