Commits

Atsushi Odagiri  committed 507d9b5

garden

  • Participants
  • Parent commits caacea7
  • Branches task.selectgroup

Comments (0)

Files changed (2)

File models/pyconjp2011/models/__init__.py

     permissions = orm.relationship('Permission',
             secondary=group_permission, backref="groups")
 
+    def __repr__(self):
+        return self.group_name.encode('utf-8')
 
 class Permission(Base):
     __tablename__ = 'permissions'

File models/pyconjp2011/models/commands.py

 from argparse import ArgumentParser
 from sqlalchemy import create_engine
+from sqlalchemy.orm.exc import NoResultFound
 from . import *
 
 def cmd_create(args):
     engine.echo = args.echo
     init_db(engine)
     create_all()
+    for name in (u"g1", u"g2"):
+        try:
+            DBSession.query(Group).filter_by(group_name=name).one()
+        except NoResultFound:
+            g = Group(group_name=name)
+            DBSession.add(g)
+    import transaction
+    transaction.commit()
 
 parser = ArgumentParser()
 subparsers = parser.add_subparsers()