1
0
Fork 0

Code style changes

* make code PEP8 clean (addresses #18)
 * add copyright information to all python files


git-svn-id: file:///home/www/usr01/svn/gnuviechadmin/trunk@257 a67ec6bc-e5d5-0310-a910-815c51eb3124
This commit is contained in:
Jan Dittberner 2008-06-06 19:20:18 +00:00
parent 7c4d25da43
commit 09180938f1
45 changed files with 759 additions and 514 deletions

View file

@ -1,4 +1,5 @@
#!/usr/bin/python
from migrate.versioning.shell import main
main(url='postgres://jan:heyyou97@localhost:5432/jan',repository='ormaptest_repo')
main(url='postgres://jan:heyyou97@localhost:5432/jan',
repository='ormaptest_repo')

View file

@ -1,26 +1,47 @@
#!/usr/bin/python
# -*- coding: UTF-8 -*-
# -*- coding: utf-8 -*-
#
# Copyright (C) 2007, 2008 by Jan Dittberner.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
# USA.
#
# Version: $Id$
from sqlalchemy import *
meta = BoundMetaData('postgres://jan:heyyou97@localhost:5432/jan')
domains_table = Table('domains', meta, autoload=True)
records_table = Table('records', meta, autoload=True)
class Domain(object):
def __repr__(self):
return "%s(%r,%r)" % (
self.__class__.__name__, self.id, self.name)
class Record(object):
def __repr__(self):
return "%s(%r,%r,%r)" % (
self.__class__.__name__, self.id, self.domain_id, self.domain)
recordmapper = mapper(Record, records_table)
domainmapper = mapper(Domain, domains_table, properties = {
'records': relation(Record, backref='domain')
})
'records': relation(Record, backref='domain')})
session = create_session()
query = session.query(Domain)

View file

@ -7,8 +7,10 @@ account = Table('account', meta,
Column('login', String(40)),
Column('passwd', String(40)))
def upgrade():
account.create()
def downgrade():
account.drop()

View file

@ -4,8 +4,10 @@ from migrate import *
meta = BoundMetaData(migrate_engine)
account = Table('account', meta)
def upgrade():
account.drop()
def downgrade():
account.create()

View file

@ -15,8 +15,7 @@ domains = Table('domains', meta,
Column('type', String(6), nullable=False),
Column('notified_serial', Integer),
Column('account', String(40)),
UniqueConstraint('name', name='name_index')
)
UniqueConstraint('name', name='name_index'))
records = Table('records', meta,
Column('id', Integer, primary_key=True),
@ -28,17 +27,18 @@ records = Table('records', meta,
Column('prio', Integer),
Column('change_date', Integer),
ForeignKeyConstraint(['domain_id'], ['domains.id'],
ondelete='CASCADE', name='domain_exists')
)
ondelete='CASCADE', name='domain_exists'))
Index('domain_id', records.c.domain_id)
Index('nametype_index', records.c.name, records.c.type)
Index('rec_name_index', records.c.name)
def upgrade():
supermasters.create()
domains.create()
records.create()
def downgrade():
records.drop()
domains.drop()