@staticmethod
    def register():
        for i in range(len(models)):
            model = models[i]
            if '_decl_class_registry' in model.__dict__:
                continue
            _as_declarative(model, model.__name__, model.__dict__)

            #for auto-update timestamps
            event.listen(model, 'before_insert', ModelExtension.before_insert_listener)
            event.listen(model, 'before_update', ModelExtension.before_update_listener)

            # for ref grandchildren
            for j in range(i):
                if not models[j] in model.__bases__:
                    continue
                parent = models[j]
                for grandparent in parent._many_to_models:
                    setattr(grandparent, model._readable_names,
                        (lambda parent, model: property(lambda self: getattr(self, parent._readable_names)
                        .filter_by(real_type = model._readable_name)))(parent, model))

                for grandparent in parent._one_to_models:
                    setattr(grandparent, model._readable_name,
                        (lambda parent, model: property(lambda self: getattr(self, parent._readable_name)
                            if getattr(self, parent._readable_name).real_type == model._readable_name else None))(parent, model))
        models[:] = []
dataset/ETHPy150Open tylerlong/quick_orm/quick_orm/core.py/Database.register/original