Example #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
Example #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
Example #3
0
def is_descriptor(cls):
    try:
        return IModelDescriptor.implementedBy(cls)
    except (TypeError, AttributeError):
        return False
    '''
def is_descriptor(cls):
    try:
        return IModelDescriptor.implementedBy(cls)
    except (TypeError, AttributeError):
        return False
    '''