Exemple #1
0
    def __init__(cls, name, bases, attrs):

        if 'Dialect' in attrs:
            items = attrs.pop('Dialect').__dict__.items()
            items = {k: v for k, v in items if not k.startswith('__')}
        else:
            items = {}
        cls._dialect = options.Dialect(**items)
        for key, attr in attrs.items():
            if hasattr(attr, 'attach_to_class'):
                attr.attach_to_class(cls, key, cls._dialect)
Exemple #2
0
    def __init__(cls, name, bases, attrs):
        if 'Dialect' in attrs:
            # Filter out Python's own additions to the namespace
            items = attrs.pop('Dialect').__dict__.items()
            items = dict((k, v) for (k, v) in items if not k.startswith('__'))
        else:
            # No options were explicitly defined
            items = {}
        cls._dialect = options.Dialect(**items)

        for key, attr in attrs.items():
            if hasattr(attr, 'attach_to_class'):
                attr.attach_to_class(cls, key, cls._dialect)
Exemple #3
0
    def __init__(cls, name, bases, attrs):
        if 'Dialect' in attrs:
            # Filter out Python's additions to the namespace
            items = attrs.pop('Dialect').__dict__.items()
            items = {k: v for k, v in items if not k.startswith('__')}
        else:
            # No dialect options defined explicitly.
            items = {}

        # Keep dialect options assigned to the class itself to maintain as much
        # information as possible.
        cls._dialect = options.Dialect(**items)

        # Locate field attributes and attach them to the class.
        for key, attr in attrs.items():
            if hasattr(attr, 'attach_to_class'):
                attr.attach_to_class(cls, key, cls._dialect)

        # Sort the columns according to the order of their instantiation
        cls._dialect.columns.sort(key=lambda column: column.counter)