Created
April 8, 2015 15:59
-
-
Save thequbit/c9cacf9a13295211fe12 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class CreationMixin(): | |
@classmethod | |
def add(cls, session, *args, **kwargs): | |
with transaction.manager: | |
session.add(cls, *args, **kwargs) | |
class Labels(Base, CreationMixin): | |
__tablename__ = 'labels' | |
id = Column(Integer, primary_key=True) | |
contents = Column(Unicode) | |
description = Column(Unicode) | |
# usage: | |
label = Labels.add( | |
session = DBSession, | |
name = 'My Label', | |
description = 'Very Important', | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment