Exemplo n.º 1
0
 def descriptor_classes():
     """A generator of descriptor classes in this module, preserving the
     order of definition.
     """
     # dir() returns names in alphabetical order
     decorated = []
     for key in dir(module):
         cls = getattr(module, key)
         try:
             assert IModelDescriptor.implementedBy(cls)
             # we decorate with the source code line number for the cls
             decorated.append((inspect.getsourcelines(cls)[1], cls))
         except (TypeError, AttributeError, AssertionError):
             debug.log_exc(sys.exc_info(), log_handler=log.debug)
     # we yield each cls in order of definition
     for cls in [ cls for (line_num, cls) in sorted(decorated) ]:
         yield cls
Exemplo n.º 2
0
 def descriptor_classes():
     """A generator of descriptor classes in this module, preserving the
     order of definition.
     """
     # dir() returns names in alphabetical order
     decorated = []
     for key in dir(module):
         cls = getattr(module, key)
         try:
             assert IModelDescriptor.implementedBy(cls)
             # we decorate with the source code line number for the cls
             decorated.append((inspect.getsourcelines(cls)[1], cls))
         except (TypeError, AttributeError, AssertionError):
             debug.log_exc(sys.exc_info(), log_handler=log.debug)
     # we yield each cls in order of definition
     for cls in [ cls for (line_num, cls) in sorted(decorated) ]:
         yield cls
Exemplo n.º 3
0
def is_descriptor(cls):
    try:
        return IModelDescriptor.implementedBy(cls)
    except (TypeError, AttributeError):
        return False
    '''
Exemplo n.º 4
0
def is_descriptor(cls):
    try:
        return IModelDescriptor.implementedBy(cls)
    except (TypeError, AttributeError):
        return False
    '''