[root@scmroad controller]# python controller.py Traceback (most recent call last): File "controller.py", line 20, in <module> from Mysql import MySql File "/apps/var/app1/controller/Mysql.py", line 1, in <module> import mysql.connector ImportError: No module named mysql.connector [root@scmroad controller]#
class ModelMetaclass(type): ''' Metaclass for model objects. ''' def __new__(cls, name, bases, attrs): # skip base Model class: if name=='Model': return type.__new__(cls, name, bases, attrs)
# store all subclasses info: if not hasattr(cls, 'subclasses'): cls.subclasses = {} if not name in cls.subclasses: cls.subclasses[name] = name else: logging.warning('Redefine class: %s' % name)