# Path: suma/core/models/meta/base.py
# class Base(object):
#     @declared_attr
#     def __tablename__(cls):
#         return _camel_to_snake(cls.__name__)
# 
#     __table_args__ = {'schema': 'suma'}
# 
#     id = Column(Integer, primary_key=True)
# 
# Path: suma/core/models/meta/types.py
# class DeclEnum(object):
#     """Declarative enumeration."""
# 
#     __metaclass__ = EnumMeta
#     _reg = {}
# 
#     @classmethod
#     def from_string(cls, value):
#         try:
#             return cls._reg[value]
#         except KeyError:
#             raise ValueError(
#                     "Invalid value for %r: %r" %
#                     (cls.__name__, value)
#                 )
# 
#     @classmethod
#     def values(cls):
#         return cls._reg.keys()
# 
#     @classmethod
#     def db_type(cls):
#         return DeclEnumType(cls)
# 
# Path: suma/core/models/meta/schema.py
# class TimestampColumns(object):
#     created = Column(DateTime, default=func.now())
#     updated = Column(DateTime, default=func.now(),
#                      onupdate=func.now())


from sqlalchemy import (
    Column,
    Unicode,
    String,
    BigInteger,
    UniqueConstraint,
    or_,
    Index
)
from suma.core.models.meta import (
    Base,
    DeclEnum,
    TimestampColumns
)
from sqlalchemy.dialects.postgresql import JSONB
from sqlalchemy.ext.hybrid import hybrid_property
from sqlalchemy.sql import exists
from sqlalchemy.orm import column_property
from sqlalchemy.ext.mutable import MutableDict
from urlparse import urlparse
from hashlib import sha1



class BlockingType(DeclEnum):
    url = "url", "Url"
    netloc = "netloc", "Netloc"
    path = "path", "Path"


class BlockedLink (Base):
    url = Column('url', Unicode, nullable=False)  # this is there more for readability
    hash = Column(String, index=True, unique=True, nullable=False)
    type = Column(BlockingType.db_type(), nullable=False)



# Path: suma/core/models/meta/base.py
# class Base(object):
#     @declared_attr
#     def __tablename__(cls):
#         return _camel_to_snake(cls.__name__)
# 
#     __table_args__ = {'schema': 'suma'}
# 
#     id = Column(Integer, primary_key=True)
# 
# Path: suma/core/models/meta/types.py
# class DeclEnum(object):
#     """Declarative enumeration."""
# 
#     __metaclass__ = EnumMeta
#     _reg = {}
# 
#     @classmethod
#     def from_string(cls, value):
#         try:
#             return cls._reg[value]
#         except KeyError:
#             raise ValueError(
#                     "Invalid value for %r: %r" %
#                     (cls.__name__, value)
#                 )
# 
#     @classmethod
#     def values(cls):
#         return cls._reg.keys()
# 
#     @classmethod
#     def db_type(cls):
#         return DeclEnumType(cls)
# 
# Path: suma/core/models/meta/schema.py
# class TimestampColumns(object):
#     created = Column(DateTime, default=func.now())
#     updated = Column(DateTime, default=func.now(),
#                      onupdate=func.now())


# Path: suma/core/models/link.py
from sqlalchemy import (
    Column,
    Unicode,
    String,
    BigInteger,
    UniqueConstraint,
    or_,
    Index
)
from suma.core.models.meta import (
    Base,
    DeclEnum,
    TimestampColumns
)
from sqlalchemy.dialects.postgresql import JSONB
from sqlalchemy.ext.hybrid import hybrid_property
from sqlalchemy.sql import exists
from sqlalchemy.orm import column_property
from sqlalchemy.ext.mutable import MutableDict
from urlparse import urlparse
from hashlib import sha1




class BlockingType(DeclEnum):
    url = "url", "Url"
    netloc = "netloc", "Netloc"
    path = "path", "Path"


class BlockedLink (Base):
    url = Column('url', Unicode, nullable=False)  # this is there more for readability
    hash = Column(String, index=True, unique=True, nullable=False)
    type = Column(BlockingType.db_type(), nullable=False)



class Link(Base, TimestampColumns):