X-Git-Url: https://git.decadent.org.uk/gitweb/?a=blobdiff_plain;ds=sidebyside;f=daklib%2Fdbconn.py;h=5e05c34b1c7ead15b4513e76f443586277668183;hb=e09846088b4af7a5958230c2705ca39ca6d3bfa2;hp=c2d51786cc31d9f072ddbe304f7cb14b870fc998;hpb=5b7cd835e58613831925807ec170705c937b15bb;p=dak.git diff --git a/daklib/dbconn.py b/daklib/dbconn.py index c2d51786..5e05c34b 100755 --- a/daklib/dbconn.py +++ b/daklib/dbconn.py @@ -64,14 +64,24 @@ from dak_exceptions import NoSourceFieldError # Patch in support for the debversion field type so that it works during # reflection -class DebVersion(sqltypes.Text): - """ - Support the debversion type - """ - +try: + # that is for sqlalchemy 0.6 + UserDefinedType = sqltypes.UserDefinedType +except: + # this one for sqlalchemy 0.5 + UserDefinedType = sqltypes.TypeEngine + +class DebVersion(UserDefinedType): def get_col_spec(self): return "DEBVERSION" + def bind_processor(self, dialect): + return None + + # ' = None' is needed for sqlalchemy 0.5: + def result_processor(self, dialect, coltype = None): + return None + sa_major_version = sqlalchemy.__version__[0:3] if sa_major_version in ["0.5", "0.6"]: from sqlalchemy.databases import postgres @@ -81,7 +91,7 @@ else: ################################################################################ -__all__ = ['IntegrityError', 'SQLAlchemyError'] +__all__ = ['IntegrityError', 'SQLAlchemyError', 'DebVersion'] ################################################################################ @@ -137,8 +147,9 @@ __all__.append('session_wrapper') ################################################################################ class Architecture(object): - def __init__(self, *args, **kwargs): - pass + def __init__(self, arch_string = None, description = None): + self.arch_string = arch_string + self.description = description def __eq__(self, val): if isinstance(val, str): @@ -1216,8 +1227,8 @@ __all__.append('add_poolfile') ################################################################################ class Fingerprint(object): - def __init__(self, *args, **kwargs): - pass + def __init__(self, fingerprint = None): + self.fingerprint = fingerprint def __repr__(self): return '' % self.fingerprint @@ -2491,8 +2502,9 @@ SUITE_FIELDS = [ ('SuiteName', 'suite_name'), ('OverrideSuite', 'overridesuite')] class Suite(object): - def __init__(self, *args, **kwargs): - pass + def __init__(self, suite_name = None, version = None): + self.suite_name = suite_name + self.version = version def __repr__(self): return '' % self.suite_name @@ -2578,6 +2590,7 @@ __all__.append('get_suite') ################################################################################ +# TODO: remove SuiteArchitecture class class SuiteArchitecture(object): def __init__(self, *args, **kwargs): pass @@ -2666,8 +2679,9 @@ __all__.append('get_suite_src_formats') ################################################################################ class Uid(object): - def __init__(self, *args, **kwargs): - pass + def __init__(self, uid = None, name = None): + self.uid = uid + self.name = name def __eq__(self, val): if isinstance(val, str): @@ -2861,7 +2875,8 @@ class DBConn(object): def __setupmappers(self): mapper(Architecture, self.tbl_architecture, - properties = dict(arch_id = self.tbl_architecture.c.id)) + properties = dict(arch_id = self.tbl_architecture.c.id, + suites = relation(Suite, secondary=self.tbl_suite_architectures, backref='architectures'))) mapper(Archive, self.tbl_archive, properties = dict(archive_id = self.tbl_archive.c.id,