Here is my mapping, this time in german...

Building class:



class Lookup(OrmBaseObject):
    id = 0
    lookupCategoryId = 0
    category = LookupCategory
    value = ''

properties = {
                  'lookupCategoryId':tables['lookup'].c.lookup_category_id,
                  'category': relationship(LookupCategory, uselist=False)
                  }

lookupMapper = mapper(Lookup, tables['lookup'], properties=properties,
                   polymorphic_on=tables['lookup'].c.lookup_category_id,
                   polymorphic_identity=0)

#well-groomed
class Pflegezustand(Lookup):
    pass

#Year of Construction-Class
class Baujahrklasse(Lookup):
    pass

mapper(Nutzungsklasse, inherits=lookupMapper, polymorphic_identity=1)
mapper(Charakteristik, inherits=lookupMapper, polymorphic_identity=4)
mapper(Baujahrklasse, inherits=lookupMapper, polymorphic_identity=5)
mapper(Pflegezustand, inherits=lookupMapper, polymorphic_identity=6)

#BuildingCondition
class GebaeudeZustand(OrmBaseObject):
    gebaeudeId = 0
    gebaeude = Gebaeude
    charakteristikId = 0
    charakteristik = Charakteristik
    baujahrklasseId = 0
    baujahrklasse = Baujahrklasse
    pflegezustandId = 0
    pflegezustand = Pflegezustand

properties = {
                  "gebaeudeId": tables['gebaeude_zustand'].c.gebaeude_id,
                  "gebaeude": relationship(Gebaeude, uselist=False),
                  "charakteristikId": 
tables['gebaeude_zustand'].c.charakteristik_id,
                  "charakteristik": relationship(Lookup, uselist=False,
                                                 
primaryjoin=and_(tables['gebaeude_zustand'].c.charakteristik_id == 
tables['lookup'].c.id,
                                                                 
 tables['lookup'].c.lookup_category_id == 4)),
                  "baujahrklasseId": 
tables['gebaeude_zustand'].c.baujahrklasse_id,
                  "baujahrklasse": relationship(Baujahrklasse, 
uselist=False,
                                                 
primaryjoin=tables['gebaeude_zustand'].c.baujahrklasse_id == 
tables['lookup'].c.id,
                                                             ),
                  "pflegezustandId": 
tables['gebaeude_zustand'].c.pflegezustand_id,
                  "pflegezustand": relationship(Pflegezustand, 
uselist=False,
                                                 
primaryjoin=and_(tables['gebaeude_zustand'].c.pflegezustand_id == 
tables['lookup'].c.id,
                                                                 
 tables['lookup'].c.lookup_category_id == 6))
                  }
    
    mapper(GebaeudeZustand, tables['gebaeude_zustand'], 
properties=properties)

#Building
class Gebaeude(OrmBaseObject):
    id = 0
    adresseId = 0
    adresse = Adresse
    gemarkungSchluessel = 0
    gemarkung = Gemarkung
    zustand = None
    nutzung = None
    dachflaechen = []

properties = {
                  'adresseId': tables['gebaeude'].c.adresse_id,
                  'adresse': relationship(Adresse, uselist=False),
                  'gemarkungSchluessel': 
tables['gebaeude'].c.gemarkung_schluessel,
                  #'gemarkung': relationship(Gemarkung, uselist=False),
                  'zustand': relationship(GebaeudeZustand, uselist=False),
                  'nutzung': relationship(GebaeudeNutzung, uselist=False),
                  'dachflaechen': relationship(Dachflaeche, uselist=True)
                  }
    
mapper(Gebaeude, tables['gebaeude'], properties=properties)

Thats all relevant parts...

-- 
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/sqlalchemy/-/oYuPh59lYvYJ.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en.

Reply via email to