# Path: productporter/extensions.py

# 
# Path: productporter/_compat.py
# PY2 = sys.version_info[0] == 2


import re
import datetime
from productporter.extensions import db, cache
from productporter._compat import max_integer

class Tag(db.Model):
    __tablename__ = "tags"

    id = db.Column(db.Integer, primary_key=True)
    name = db.Column(db.String(32), nullable=False)
    description = db.Column(db.Text)

    # Methods
    def __repr__(self):
        """Set to a unique key specific to the object in the database.
        Required for cache.memoize() to work across requests.
        """
        return "<{} {}>".format(self.__class__.__name__, self.id)

    def save(self):
        """Saves a tag"""
        db.session.add(self)
        db.session.commit()
        Tag.invalidate_cache()
        return self

    def delete(self):
        """Deletes a tag"""
        db.session.delete(self)
        db.session.commit()
        Tag.invalidate_cache()
        return self

    @classmethod

# Path: productporter/extensions.py

# 
# Path: productporter/_compat.py
# PY2 = sys.version_info[0] == 2


# Path: productporter/product/models.py
import re
import datetime
from productporter.extensions import db, cache
from productporter._compat import max_integer


class Tag(db.Model):
    __tablename__ = "tags"

    id = db.Column(db.Integer, primary_key=True)
    name = db.Column(db.String(32), nullable=False)
    description = db.Column(db.Text)

    # Methods
    def __repr__(self):
        """Set to a unique key specific to the object in the database.
        Required for cache.memoize() to work across requests.
        """
        return "<{} {}>".format(self.__class__.__name__, self.id)

    def save(self):
        """Saves a tag"""
        db.session.add(self)
        db.session.commit()
        Tag.invalidate_cache()
        return self

    def delete(self):
        """Deletes a tag"""
        db.session.delete(self)
        db.session.commit()
        Tag.invalidate_cache()
        return self

    @classmethod

    @cache.memoize(timeout=max_integer)