Skip to content

Instantly share code, notes, and snippets.

@thequbit
Created April 8, 2015 15:59
Show Gist options
  • Save thequbit/c9cacf9a13295211fe12 to your computer and use it in GitHub Desktop.
Save thequbit/c9cacf9a13295211fe12 to your computer and use it in GitHub Desktop.
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