Пример #1
0
 def testModelNonExistingTables(self):
     M = Model()
     M.add("non_existing_table")
     db = createSAWrapper(self.dsn, model=M)
     try:
         db.getMapper("non_existing_table")
     except exc.NoSuchTableError:
         pass
Пример #2
0
 def testModelNonExistingTables(self):
     M = Model()
     M.add('non_existing_table')
     db = createSAWrapper(self.dsn, model=M)
     try:
         db.getMapper('non_existing_table')
     except exc.NoSuchTableError:
         pass
Пример #3
0
    def testMapperWithCustomModel(self):
        class myUser(MappedClassBase):
            pass

        M = Model()
        M.add('users', mapper_class=myUser)

        db = createSAWrapper(self.dsn, model=M)
        User = db.getMapper('users')
        self.assertEqual(User, myUser)
Пример #4
0
    def testMapperWithCustomModel(self):
        class myUser(MappedClassBase):
            pass

        M = Model()
        M.add("users", mapper_class=myUser)

        db = createSAWrapper(self.dsn, model=M)
        User = db.getMapper("users")
        self.assertEqual(User, myUser)
Пример #5
0
        def getModel(metadata):

            model = Model()
            Base = declarative_base(metadata=metadata)

            class Foo(Base):
                __tablename__ = 'foo'

                id = Column('id', Integer, primary_key=True)
                name = Column('name', String(50))

            model.add('foo', mapper_class=Foo)
            Base.metadata.create_all()
            return model
Пример #6
0
        def getModel(metadata):

            model = Model()
            Base = declarative_base(metadata=metadata)

            class Foo(Base):
                __tablename__ = "foo"

                id = Column("id", Integer, primary_key=True)
                name = Column("name", String(50))

            model.add("foo", mapper_class=Foo)
            Base.metadata.create_all()
            return model
Пример #7
0
    def getModel(self, metadata=None):
        """
        ipplf database model
        """
        model = Model()
        model.metadata = metadata

## table demande intervention ##
        demandeInterventionTable = getDemandeIntervention(metadata)
        demandeInterventionTable.create(checkfirst=True)
        mapper(DemandeIntervention, demandeInterventionTable)



        return model
Пример #8
0
 def testModelWeirdParameters(self):
     M = Model()
     self.assertRaises(ValueError,
                       M.add,
                       'users',
                       relations=('foo', 'bar'),
                       autodetect_relations=True)
Пример #9
0
 def testModelWeirdRelationsParameters(self):
     M = Model()
     self.assertRaises(TypeError, M.add, 'users', relations=('foo'))
Пример #10
0
    def getModel(self, metadata=None):
        """
            table de demo employe
        """
        model = Model()
        model.metadata = metadata

        ## table province ##
        provinceTable = getAllProvince(metadata)
        provinceTable.create(checkfirst=True)
        mapper(Province, provinceTable)
        model.add('province', table=provinceTable, mapper_class=Province)

        ## table commune ##
        communeTable = getAllCommune(metadata)
        communeTable.create(checkfirst=True)
        mapper(Commune,
               communeTable,
               properties={
                   'province':
                   relation(Province,
                            uselist=False,
                            backref=backref('commune',
                                            lazy=True,
                                            uselist=False))
               })
        model.add('commune', table=communeTable, mapper_class=Commune)

        ## table clps ##
        clpsTable = getAllClps(metadata)
        clpsTable.create(checkfirst=True)
        mapper(Clps,
               clpsTable,
               properties={'commune': relation(Commune, uselist=False)})
        model.add('clps', table=clpsTable, mapper_class=Clps)

        ## table plateforme ##
        plateformeTable = getAllPlateForme(metadata)
        plateformeTable.create(checkfirst=True)
        mapper(PlateForme, plateformeTable)
        model.add('plateforme', table=plateformeTable, mapper_class=PlateForme)

        ## table sous_plateforme ##
        sousplateformeTable = getAllSousPlateForme(metadata)
        sousplateformeTable.create(checkfirst=True)
        mapper(SousPlateForme,
               sousplateformeTable,
               properties={
                   'plateforme':
                   relation(PlateForme,
                            uselist=False,
                            backref=backref('sousplateforme',
                                            lazy=True,
                                            uselist=False))
               })
        model.add('sousplateforme',
                  table=sousplateformeTable,
                  mapper_class=SousPlateForme)

        ## table public ##
        publicTable = getAllPublic(metadata)
        publicTable.create(checkfirst=True)
        mapper(Public, publicTable)
        model.add('public', table=publicTable, mapper_class=Public)

        ## table milieu de vie ##
        milieuDeVieTable = getAllMilieuDeVie(metadata)
        milieuDeVieTable.create(checkfirst=True)
        mapper(MilieuDeVie, milieuDeVieTable)
        model.add('milieudevie',
                  table=milieuDeVieTable,
                  mapper_class=MilieuDeVie)

        ## table theme ##
        themeTable = getAllTheme(metadata)
        themeTable.create(checkfirst=True)
        mapper(Theme, themeTable)
        model.add('theme', table=themeTable, mapper_class=Theme)

        ## table motcle ##
        motCleTable = getAllMotCle(metadata)
        motCleTable.create(checkfirst=True)
        mapper(MotCle, motCleTable)
        model.add('motcle', table=motCleTable, mapper_class=MotCle)

        ## table auteur  ##
        auteurTable = getAllAuteur(metadata)
        auteurTable.create(checkfirst=True)
        mapper(Auteur,
               auteurTable,
               properties={
                   'experienceFromAuteur':
                   relation(Experience,
                            uselist=False,
                            backref=backref('auteurFromExperience',
                                            lazy=True,
                                            uselist=False)),
                   'clpsOrigine':
                   relation(Clps, uselist=False)
               })
        model.add('auteur', table=auteurTable, mapper_class=Auteur)

        ## table institution-type ##
        institutionTypeTable = getAllInstitutionType(metadata)
        institutionTypeTable.create(checkfirst=True)
        mapper(InstitutionType, institutionTypeTable)
        model.add('institution_type',
                  table=institutionTypeTable,
                  mapper_class=InstitutionType)

        ## table institution ##
        institutionTable = getAllInstitution(metadata)
        institutionTable.create(checkfirst=True)
        mapper(Institution,
               institutionTable,
               properties={
                   'commune':
                   relation(Commune,
                            uselist=False,
                            backref=backref('institution',
                                            lazy=True,
                                            uselist=False)),
                   'auteur':
                   relation(Auteur, uselist=False),
                   'type':
                   relation(InstitutionType, uselist=False)
               })
        model.add('institution',
                  table=institutionTable,
                  mapper_class=Institution)

        LinkInstitutionSousPlateFormeTable = getLinkInstitutionSousPlateForme(
            metadata)
        LinkInstitutionSousPlateFormeTable.create(checkfirst=True)
        mapper(LinkInstitutionSousPlateForme,
               LinkInstitutionSousPlateFormeTable)
        model.add('link_institution_sousplateforme',
                  table=LinkInstitutionSousPlateFormeTable,
                  mapper_class=LinkInstitutionSousPlateForme)

        linkInstitutionCommuneCouverteTable = getLinkInstitutionCommuneCouverte(
            metadata)
        linkInstitutionCommuneCouverteTable.create(checkfirst=True)
        mapper(LinkInstitutionCommuneCouverte,
               linkInstitutionCommuneCouverteTable,
               primary_key=[
                   linkInstitutionCommuneCouverteTable.c.institution_fk,
                   linkInstitutionCommuneCouverteTable.c.commune_fk
               ])
        model.add('link_institution_commune_couverte',
                  table=linkInstitutionCommuneCouverteTable,
                  mapper_class=LinkInstitutionCommuneCouverte)

        LinkInstitutionClpsProprioTable = getLinkInstitutionClpsProprio(
            metadata)
        LinkInstitutionClpsProprioTable.create(checkfirst=True)
        mapper(LinkInstitutionClpsProprio, LinkInstitutionClpsProprioTable)
        model.add('link_institution_clps_proprio',
                  table=LinkInstitutionClpsProprioTable,
                  mapper_class=LinkInstitutionClpsProprio)

        ## table info assuetude pour institution ##
        AssuetudeInterventionForInstitutionTable = getAllAssuetudeInterventionForInstitution(
            metadata)
        AssuetudeInterventionForInstitutionTable.create(checkfirst=True)
        mapper(AssuetudeInterventionForInstitution,
               AssuetudeInterventionForInstitutionTable)
        model.add('assuetude_intervention_for_institution',
                  table=AssuetudeInterventionForInstitutionTable,
                  mapper_class=AssuetudeInterventionForInstitution)

        linkAssuetudeInterventionForInstitutionTable = getLinkAssuetudeInterventionForInstitution(
            metadata)
        linkAssuetudeInterventionForInstitutionTable.create(checkfirst=True)
        mapper(
            LinkAssuetudeInterventionForInstitution,
            linkAssuetudeInterventionForInstitutionTable,
            primary_key=[
                linkAssuetudeInterventionForInstitutionTable.c.institution_fk,
                linkAssuetudeInterventionForInstitutionTable.c.
                assuetude_intervention_fk
            ],
            properties={
                'assuetudeIntervention':
                relation(AssuetudeInterventionForInstitution, uselist=False)
            })
        model.add('link_institution_asuetude_intervention',
                  table=linkAssuetudeInterventionForInstitutionTable,
                  mapper_class=LinkAssuetudeInterventionForInstitution)

        assuetudeActiviteProposeeForInstitutionTable = getAllAssuetudeActiviteProposeeForInstitution(
            metadata)
        assuetudeActiviteProposeeForInstitutionTable.create(checkfirst=True)
        mapper(AssuetudeActiviteProposeeForInstitution,
               assuetudeActiviteProposeeForInstitutionTable)
        model.add('assuetude_activite_proposee_for_institution',
                  table=assuetudeActiviteProposeeForInstitutionTable,
                  mapper_class=AssuetudeActiviteProposeeForInstitution)

        linkAssuetudeActiviteProposeePublicForInstitutionTable = getLinkAssuetudeActiviteProposeeForInstitutionPublic(
            metadata)
        linkAssuetudeActiviteProposeePublicForInstitutionTable.create(
            checkfirst=True)
        mapper(LinkAssuetudeActiviteProposeeForInstitutionPublic,
               linkAssuetudeActiviteProposeePublicForInstitutionTable,
               primary_key=[
                   linkAssuetudeActiviteProposeePublicForInstitutionTable.c.
                   institution_fk,
                   linkAssuetudeActiviteProposeePublicForInstitutionTable.c.
                   assuetude_activite_proposee_public_fk
               ])
        model.add(
            'link_institution_asuetude_activite_proposee_public',
            table=linkAssuetudeActiviteProposeePublicForInstitutionTable,
            mapper_class=LinkAssuetudeActiviteProposeeForInstitutionPublic)

        linkAssuetudeActiviteProposeeProForInstitutionTable = getLinkAssuetudeActiviteProposeeForInstitutionPro(
            metadata)
        linkAssuetudeActiviteProposeeProForInstitutionTable.create(
            checkfirst=True)
        mapper(LinkAssuetudeActiviteProposeeForInstitutionPro,
               linkAssuetudeActiviteProposeeProForInstitutionTable,
               primary_key=[
                   linkAssuetudeActiviteProposeeProForInstitutionTable.c.
                   institution_fk,
                   linkAssuetudeActiviteProposeeProForInstitutionTable.c.
                   assuetude_activite_proposee_pro_fk
               ])
        model.add('link_institution_asuetude_activite_proposee_pro',
                  table=linkAssuetudeActiviteProposeeProForInstitutionTable,
                  mapper_class=LinkAssuetudeActiviteProposeeForInstitutionPro)

        assuetudeThematiqueForInstitutionTable = getAllAssuetudeThemeForInstitution(
            metadata)
        assuetudeThematiqueForInstitutionTable.create(checkfirst=True)
        mapper(AssuetudeThemeForInstitution,
               assuetudeThematiqueForInstitutionTable)
        model.add('assuetude_thematique_for_institution',
                  table=assuetudeThematiqueForInstitutionTable,
                  mapper_class=AssuetudeThemeForInstitution)

        linkAssuetudeThemeForInstitutionTable = getLinkAssuetudeThemeForInstitution(
            metadata)
        linkAssuetudeThemeForInstitutionTable.create(checkfirst=True)
        mapper(
            LinkAssuetudeThemeForInstitution,
            linkAssuetudeThemeForInstitutionTable,
            primary_key=[
                linkAssuetudeThemeForInstitutionTable.c.institution_fk,
                linkAssuetudeThemeForInstitutionTable.c.assuetude_thematique_fk
            ])
        model.add('link_institution_assuetude_thematique',
                  table=linkAssuetudeThemeForInstitutionTable,
                  mapper_class=LinkAssuetudeThemeForInstitution)

        ## table support ##
        supportTable = getAllSupport(metadata)
        supportTable.create(checkfirst=True)
        mapper(Support, supportTable)
        model.add('support', table=supportTable, mapper_class=Support)

        ## table ressource liee a la table support et a la table theme ##
        ressourceTable = getAllRessource(metadata)
        ressourceTable.create(checkfirst=True)
        mapper(Ressource, ressourceTable)
        model.add('ressource', table=ressourceTable, mapper_class=Ressource)

        LinkRessourceSupportTable = getLinkRessourceSupport(metadata)
        LinkRessourceSupportTable.create(checkfirst=True)
        mapper(LinkRessourceSupport, LinkRessourceSupportTable)
        model.add('link_ressource_support',
                  table=LinkRessourceSupportTable,
                  mapper_class=LinkRessourceSupport)

        LinkRessourceThemeTable = getLinkRessourceTheme(metadata)
        LinkRessourceThemeTable.create(checkfirst=True)
        mapper(LinkRessourceTheme, LinkRessourceThemeTable)
        model.add('link_ressource_theme',
                  table=LinkRessourceThemeTable,
                  mapper_class=LinkRessourceTheme)

        LinkRessourcePublicTable = getLinkRessourcePublic(metadata)
        LinkRessourcePublicTable.create(checkfirst=True)
        mapper(LinkRessourcePublic, LinkRessourcePublicTable)
        model.add('link_ressource_public',
                  table=LinkRessourcePublicTable,
                  mapper_class=LinkRessourcePublic)

        LinkRessourceClpsProprioTable = getLinkRessourceClpsProprio(metadata)
        LinkRessourceClpsProprioTable.create(checkfirst=True)
        mapper(LinkRessourceClpsProprio,
               LinkRessourceClpsProprioTable,
               properties={
                   'ressourceOfClpsProprio': relation(Ressource, lazy=True),
                   'proprio': relation(Clps, lazy=True)
               })
        model.add('link_ressource_clps_proprio',
                  table=LinkRessourceClpsProprioTable,
                  mapper_class=LinkRessourceClpsProprio)

        LinkRessourceClpsDispoTable = getLinkRessourceClpsDispo(metadata)
        LinkRessourceClpsDispoTable.create(checkfirst=True)
        mapper(LinkRessourceClpsDispo, LinkRessourceClpsDispoTable)
        model.add('link_ressource_clps_dispo',
                  table=LinkRessourceClpsDispoTable,
                  mapper_class=LinkRessourceClpsDispo)

        ## table recit ##
        recitTable = getAllRecit(metadata)
        recitTable.create(checkfirst=True)
        mapper(Recit, recitTable)
        model.add('recit', table=recitTable, mapper_class=Recit)

        ## table experience ##
        LinkExperienceInstitutionPorteurTable = getLinkExperienceInstitutionPorteur(
            metadata)
        LinkExperienceInstitutionPorteurTable.create(checkfirst=True)
        mapper(LinkExperienceInstitutionPorteur,
               LinkExperienceInstitutionPorteurTable,
               properties={
                   'institution_porteur': relation(Institution, lazy=True)
               })
        model.add('link_experience_institution_porteur',
                  table=LinkExperienceInstitutionPorteurTable,
                  mapper_class=LinkExperienceInstitutionPorteur)

        LinkExperienceInstitutionPartenaireTable = getLinkExperienceInstitutionPartenaire(
            metadata)
        LinkExperienceInstitutionPartenaireTable.create(checkfirst=True)
        mapper(LinkExperienceInstitutionPartenaire,
               LinkExperienceInstitutionPartenaireTable,
               properties={
                   'institution_partenaire': relation(Institution, lazy=True)
               })
        model.add('link_experience_institution_partenaire',
                  table=LinkExperienceInstitutionPartenaireTable,
                  mapper_class=LinkExperienceInstitutionPartenaire)

        LinkExperienceInstitutionRessourceTable = getLinkExperienceInstitutionRessource(
            metadata)
        LinkExperienceInstitutionRessourceTable.create(checkfirst=True)
        mapper(LinkExperienceInstitutionRessource,
               LinkExperienceInstitutionRessourceTable,
               properties={
                   'institution_ressource': relation(Institution, lazy=True)
               })
        model.add('link_experience_institution_ressource',
                  table=LinkExperienceInstitutionRessourceTable,
                  mapper_class=LinkExperienceInstitutionRessource)

        LinkExperienceClpsProprioTable = getLinkExperienceClpsProprio(metadata)
        LinkExperienceClpsProprioTable.create(checkfirst=True)
        mapper(LinkExperienceClpsProprio, LinkExperienceClpsProprioTable)
        model.add('link_experience_clps_proprio',
                  table=LinkExperienceClpsProprioTable,
                  mapper_class=LinkExperienceClpsProprio)

        LinkExperienceRessourceTable = getLinkExperienceRessource(metadata)
        LinkExperienceRessourceTable.create(checkfirst=True)
        mapper(LinkExperienceRessource, LinkExperienceRessourceTable)
        model.add('link_experience_ressource',
                  table=LinkExperienceRessourceTable,
                  mapper_class=LinkExperienceRessource)

        LinkExperienceMilieuDeVieTable = getLinkExperienceMilieuDeVie(metadata)
        LinkExperienceMilieuDeVieTable.create(checkfirst=True)
        mapper(LinkExperienceMilieuDeVie, LinkExperienceMilieuDeVieTable)
        model.add('link_experience_milieudevie',
                  table=LinkExperienceMilieuDeVieTable,
                  mapper_class=LinkExperienceMilieuDeVie)

        LinkExperienceSousPlateFormeTable = getLinkExperienceSousPlateForme(
            metadata)
        LinkExperienceSousPlateFormeTable.create(checkfirst=True)
        mapper(LinkExperienceSousPlateForme, LinkExperienceSousPlateFormeTable)
        model.add('link_experience_sousplateforme',
                  table=LinkExperienceSousPlateFormeTable,
                  mapper_class=LinkExperienceSousPlateForme)

        LinkExperienceMotCleTable = getLinkExperienceMotCle(metadata)
        LinkExperienceMotCleTable.create(checkfirst=True)
        mapper(LinkExperienceMotCle, LinkExperienceMotCleTable)
        model.add('link_experience_mot_cle',
                  table=LinkExperienceMotCleTable,
                  mapper_class=LinkExperienceMotCle)

        LinkExperienceThemeTable = getLinkExperienceTheme(metadata)
        LinkExperienceThemeTable.create(checkfirst=True)
        mapper(LinkExperienceTheme, LinkExperienceThemeTable)
        model.add('link_experience_theme',
                  table=LinkExperienceThemeTable,
                  mapper_class=LinkExperienceTheme)

        LinkExperiencePublicTable = getLinkExperiencePublic(metadata)
        LinkExperiencePublicTable.create(checkfirst=True)
        mapper(LinkExperiencePublic, LinkExperiencePublicTable)
        model.add('link_experience_public',
                  table=LinkExperiencePublicTable,
                  mapper_class=LinkExperiencePublic)

        LinkExperienceCommuneTable = getLinkExperienceCommune(metadata)
        LinkExperienceCommuneTable.create(checkfirst=True)
        mapper(LinkExperienceCommune, LinkExperienceCommuneTable)
        model.add('link_experience_commune',
                  table=LinkExperienceCommuneTable,
                  mapper_class=LinkExperienceCommune)

        experienceTable = getAllExperience(metadata)
        experienceTable.create(checkfirst=True)
        mapper(Experience,
               experienceTable,
               properties={
                   'institution_porteur':
                   relation(LinkExperienceInstitutionPorteur, lazy=True),
                   'institution_partenaire':
                   relation(LinkExperienceInstitutionPartenaire, lazy=True),
                   'clpsOrigine':
                   relation(Clps, uselist=False)
               })
        #'institution_ressource': relation(LinkExperienceInstitutionRessource, lazy=True),
        #'ressource': relation(LinkExperienceRessource, lazy=True)

        model.add('experience', table=experienceTable, mapper_class=Experience)

        ## table experiencemaj > versionning ##
        experienceMajTable = getAllExperienceMaj(metadata)
        experienceMajTable.create(checkfirst=True)
        mapper(ExperienceMaj,
               experienceMajTable,
               properties={'clps_proprio': relation(Clps, uselist=False)})
        model.add('experience_maj',
                  table=experienceMajTable,
                  mapper_class=ExperienceMaj)

        ## table rechercheLog ##
        rechercheLogTable = getAllRechercheLog(metadata)
        rechercheLogTable.create(checkfirst=True)
        mapper(RechercheLog, rechercheLogTable)
        model.add('rechercheLog', table=rechercheLogTable, mapper_class=Recit)

        metadata.create_all()
        return model
Пример #11
0
mapper(HierarchyNode,
       HierarchyTable,
       properties={
           'children':
           relation(
               HierarchyNode,
               primaryjoin=HierarchyTable.c.parentid == HierarchyTable.c.id,
               cascade="all",
               backref=backref("parent", remote_side=[HierarchyTable.c.id])),
           'parent':
           relation(
               HierarchyNode,
               primaryjoin=HierarchyTable.c.parentid == HierarchyTable.c.id,
               remote_side=[HierarchyTable.c.id],
               uselist=False,
           ),
       })

m = Model()
m.add('hierarchy', table=HierarchyTable, mapper_class=HierarchyNode)

wrapper = createSQLAlchemyWrapper(dsn, model=m)
session = wrapper.session

H = wrapper.getMapper('hierarchy')

print(H)
rows = session.query(H).select_by(H.c.id == 8)
print(rows[0].children)
Пример #12
0
    def getModel(self, metadata=None):
        """
            table de demo employe
        """
        model = Model()
        model.metadata = metadata

## table province ##
        provinceTable = getAllProvince(metadata)
        provinceTable.create(checkfirst=True)
        mapper(Province, provinceTable)
        model.add('province',
                  table=provinceTable,
                  mapper_class=Province)

## table commune ##
        communeTable = getAllCommune(metadata)
        communeTable.create(checkfirst=True)
        mapper(Commune, communeTable,
               properties={'province': relation(Province,
                                                uselist=False,
                                                backref=backref('commune',
                                                                lazy=True,
                                                                uselist=False))})
        model.add('commune',
                  table=communeTable,
                  mapper_class=Commune)

## table clps ##
        clpsTable = getAllClps(metadata)
        clpsTable.create(checkfirst=True)
        mapper(Clps, clpsTable,
               properties={'commune': relation(Commune,
                                               uselist=False)})
        model.add('clps',
                  table=clpsTable,
                  mapper_class=Clps)

## table plateforme ##
        plateformeTable = getAllPlateForme(metadata)
        plateformeTable.create(checkfirst=True)
        mapper(PlateForme, plateformeTable)
        model.add('plateforme',
                  table=plateformeTable,
                  mapper_class=PlateForme)

## table sous_plateforme ##
        sousplateformeTable = getAllSousPlateForme(metadata)
        sousplateformeTable.create(checkfirst=True)
        mapper(SousPlateForme, sousplateformeTable,
               properties={'plateforme': relation(PlateForme,
                                                  uselist=False,
                                                  backref=backref('sousplateforme',
                                                                  lazy=True,
                                                                  uselist=False))})
        model.add('sousplateforme',
                  table=sousplateformeTable,
                  mapper_class=SousPlateForme)

## table public ##
        publicTable = getAllPublic(metadata)
        publicTable.create(checkfirst=True)
        mapper(Public, publicTable)
        model.add('public',
                  table=publicTable,
                  mapper_class=Public)

## table milieu de vie ##
        milieuDeVieTable = getAllMilieuDeVie(metadata)
        milieuDeVieTable.create(checkfirst=True)
        mapper(MilieuDeVie, milieuDeVieTable)
        model.add('milieudevie', table=milieuDeVieTable, mapper_class=MilieuDeVie)

## table theme ##
        themeTable = getAllTheme(metadata)
        themeTable.create(checkfirst=True)
        mapper(Theme, themeTable)
        model.add('theme',
                  table=themeTable,
                  mapper_class=Theme)

## table motcle ##
        motCleTable = getAllMotCle(metadata)
        motCleTable.create(checkfirst=True)
        mapper(MotCle, motCleTable)
        model.add('motcle',
                  table=motCleTable,
                  mapper_class=MotCle)

## table auteur  ##
        auteurTable = getAllAuteur(metadata)
        auteurTable.create(checkfirst=True)
        mapper(Auteur, auteurTable,
               properties={'experienceFromAuteur': relation(Experience,
                                                            uselist=False,
                                                            backref=backref('auteurFromExperience',
                                                                            lazy=True,
                                                                            uselist=False)),
                           'clpsOrigine': relation(Clps,
                                                   uselist=False)})
        model.add('auteur',
                  table=auteurTable,
                  mapper_class=Auteur)

## table institution-type ##
        institutionTypeTable = getAllInstitutionType(metadata)
        institutionTypeTable.create(checkfirst=True)
        mapper(InstitutionType, institutionTypeTable)
        model.add('institution_type',
                  table=institutionTypeTable,
                  mapper_class=InstitutionType)

## table institution ##
        institutionTable = getAllInstitution(metadata)
        institutionTable.create(checkfirst=True)
        mapper(Institution, institutionTable,
               properties={'commune': relation(Commune,
                                               uselist=False,
                                               backref=backref('institution',
                                                               lazy=True,
                                                               uselist=False)),
                           'auteur': relation(Auteur,
                                              uselist=False),
                           'type': relation(InstitutionType,
                                            uselist=False)})
        model.add('institution',
                  table=institutionTable,
                  mapper_class=Institution)

        LinkInstitutionSousPlateFormeTable = getLinkInstitutionSousPlateForme(metadata)
        LinkInstitutionSousPlateFormeTable.create(checkfirst=True)
        mapper(LinkInstitutionSousPlateForme, LinkInstitutionSousPlateFormeTable)
        model.add('link_institution_sousplateforme',
                  table=LinkInstitutionSousPlateFormeTable,
                  mapper_class=LinkInstitutionSousPlateForme)

        linkInstitutionCommuneCouverteTable = getLinkInstitutionCommuneCouverte(metadata)
        linkInstitutionCommuneCouverteTable.create(checkfirst=True)
        mapper(LinkInstitutionCommuneCouverte, linkInstitutionCommuneCouverteTable,
               primary_key=[linkInstitutionCommuneCouverteTable.c.institution_fk, linkInstitutionCommuneCouverteTable.c.commune_fk])
        model.add('link_institution_commune_couverte',
                  table=linkInstitutionCommuneCouverteTable,
                  mapper_class=LinkInstitutionCommuneCouverte)

        LinkInstitutionClpsProprioTable = getLinkInstitutionClpsProprio(metadata)
        LinkInstitutionClpsProprioTable.create(checkfirst=True)
        mapper(LinkInstitutionClpsProprio, LinkInstitutionClpsProprioTable,
               properties={'institutionOfClpsProprio': relation(Institution, lazy=True),
                           'proprio': relation(Clps, lazy=True)})
        model.add('link_institution_clps_proprio',
                  table=LinkInstitutionClpsProprioTable,
                  mapper_class=LinkInstitutionClpsProprio)

## table info assuetude pour institution ##
        AssuetudeInterventionForInstitutionTable = getAllAssuetudeInterventionForInstitution(metadata)
        AssuetudeInterventionForInstitutionTable.create(checkfirst=True)
        mapper(AssuetudeInterventionForInstitution, AssuetudeInterventionForInstitutionTable)
        model.add('assuetude_intervention_for_institution', table=AssuetudeInterventionForInstitutionTable, mapper_class=AssuetudeInterventionForInstitution)

        linkAssuetudeInterventionForInstitutionTable = getLinkAssuetudeInterventionForInstitution(metadata)
        linkAssuetudeInterventionForInstitutionTable.create(checkfirst=True)
        mapper(LinkAssuetudeInterventionForInstitution, linkAssuetudeInterventionForInstitutionTable,
               primary_key=[linkAssuetudeInterventionForInstitutionTable.c.institution_fk, linkAssuetudeInterventionForInstitutionTable.c.assuetude_intervention_fk],
               properties={'assuetudeIntervention': relation(AssuetudeInterventionForInstitution,
                                                             uselist=False)})
        model.add('link_institution_asuetude_intervention',
                  table=linkAssuetudeInterventionForInstitutionTable,
                  mapper_class=LinkAssuetudeInterventionForInstitution)

        assuetudeActiviteProposeeForInstitutionTable = getAllAssuetudeActiviteProposeeForInstitution(metadata)
        assuetudeActiviteProposeeForInstitutionTable.create(checkfirst=True)
        mapper(AssuetudeActiviteProposeeForInstitution, assuetudeActiviteProposeeForInstitutionTable)
        model.add('assuetude_activite_proposee_for_institution',
                  table=assuetudeActiviteProposeeForInstitutionTable,
                  mapper_class=AssuetudeActiviteProposeeForInstitution)

        linkAssuetudeActiviteProposeePublicForInstitutionTable = getLinkAssuetudeActiviteProposeeForInstitutionPublic(metadata)
        linkAssuetudeActiviteProposeePublicForInstitutionTable.create(checkfirst=True)
        mapper(LinkAssuetudeActiviteProposeeForInstitutionPublic, linkAssuetudeActiviteProposeePublicForInstitutionTable,
               primary_key=[linkAssuetudeActiviteProposeePublicForInstitutionTable.c.institution_fk, linkAssuetudeActiviteProposeePublicForInstitutionTable.c.assuetude_activite_proposee_public_fk])
        model.add('link_institution_asuetude_activite_proposee_public',
                  table=linkAssuetudeActiviteProposeePublicForInstitutionTable,
                  mapper_class=LinkAssuetudeActiviteProposeeForInstitutionPublic)

        linkAssuetudeActiviteProposeeProForInstitutionTable = getLinkAssuetudeActiviteProposeeForInstitutionPro(metadata)
        linkAssuetudeActiviteProposeeProForInstitutionTable.create(checkfirst=True)
        mapper(LinkAssuetudeActiviteProposeeForInstitutionPro, linkAssuetudeActiviteProposeeProForInstitutionTable,
               primary_key=[linkAssuetudeActiviteProposeeProForInstitutionTable.c.institution_fk, linkAssuetudeActiviteProposeeProForInstitutionTable.c.assuetude_activite_proposee_pro_fk])
        model.add('link_institution_asuetude_activite_proposee_pro',
                  table=linkAssuetudeActiviteProposeeProForInstitutionTable,
                  mapper_class=LinkAssuetudeActiviteProposeeForInstitutionPro)

        assuetudeThematiqueForInstitutionTable = getAllAssuetudeThemeForInstitution(metadata)
        assuetudeThematiqueForInstitutionTable.create(checkfirst=True)
        mapper(AssuetudeThemeForInstitution, assuetudeThematiqueForInstitutionTable)
        model.add('assuetude_thematique_for_institution',
                  table=assuetudeThematiqueForInstitutionTable,
                  mapper_class=AssuetudeThemeForInstitution)

        linkAssuetudeThemeForInstitutionTable = getLinkAssuetudeThemeForInstitution(metadata)
        linkAssuetudeThemeForInstitutionTable.create(checkfirst=True)
        mapper(LinkAssuetudeThemeForInstitution, linkAssuetudeThemeForInstitutionTable,
               primary_key=[linkAssuetudeThemeForInstitutionTable.c.institution_fk, linkAssuetudeThemeForInstitutionTable.c.assuetude_thematique_fk])
        model.add('link_institution_assuetude_thematique',
                  table=linkAssuetudeThemeForInstitutionTable,
                  mapper_class=LinkAssuetudeThemeForInstitution)

## table support ##
        supportTable = getAllSupport(metadata)
        supportTable.create(checkfirst=True)
        mapper(Support, supportTable)
        model.add('support',
                  table=supportTable,
                  mapper_class=Support)

## table ressource liee a la table support et a la table theme ##
        ressourceTable = getAllRessource(metadata)
        ressourceTable.create(checkfirst=True)
        mapper(Ressource, ressourceTable)
                #properties={'support': relation(Support,
                #                                uselist=False,
                #                                backref=backref('ressource',
                #                                                lazy=True,
                #                                                uselist=False))})
        model.add('ressource',
                  table=ressourceTable,
                  mapper_class=Ressource)

        LinkRessourceSupportTable = getLinkRessourceSupport(metadata)
        LinkRessourceSupportTable.create(checkfirst=True)
        mapper(LinkRessourceSupport, LinkRessourceSupportTable)
        model.add('link_ressource_support',
                  table=LinkRessourceSupportTable,
                  mapper_class=LinkRessourceSupport)

        LinkRessourceThemeTable = getLinkRessourceTheme(metadata)
        LinkRessourceThemeTable.create(checkfirst=True)
        mapper(LinkRessourceTheme, LinkRessourceThemeTable)
        model.add('link_ressource_theme',
                  table=LinkRessourceThemeTable,
                  mapper_class=LinkRessourceTheme)

        LinkRessourcePublicTable = getLinkRessourcePublic(metadata)
        LinkRessourcePublicTable.create(checkfirst=True)
        mapper(LinkRessourcePublic, LinkRessourcePublicTable)
        model.add('link_ressource_public',
                  table=LinkRessourcePublicTable,
                  mapper_class=LinkRessourcePublic)

        LinkRessourceClpsProprioTable = getLinkRessourceClpsProprio(metadata)
        LinkRessourceClpsProprioTable.create(checkfirst=True)
        mapper(LinkRessourceClpsProprio, LinkRessourceClpsProprioTable,
               properties={'ressourceOfClpsProprio': relation(Ressource, lazy=True),
                           'proprio': relation(Clps, lazy=True)})
        model.add('link_ressource_clps_proprio',
                  table=LinkRessourceClpsProprioTable,
                  mapper_class=LinkRessourceClpsProprio)

        LinkRessourceClpsDispoTable = getLinkRessourceClpsDispo(metadata)
        LinkRessourceClpsDispoTable.create(checkfirst=True)
        mapper(LinkRessourceClpsDispo, LinkRessourceClpsDispoTable)
        model.add('link_ressource_clps_dispo',
                  table=LinkRessourceClpsDispoTable,
                  mapper_class=LinkRessourceClpsDispo)

## table recit ##
        recitTable = getAllRecit(metadata)
        recitTable.create(checkfirst=True)
        mapper(Recit, recitTable)
        model.add('recit',
                  table=recitTable,
                  mapper_class=Recit)

## table experience ##
        experienceTable = getAllExperience(metadata)
        experienceTable.create(checkfirst=True)
        mapper(Experience, experienceTable,
               properties={'institution_porteur': relation(LinkExperienceInstitutionPorteur, lazy=True),
                           'institution_partenaire': relation(LinkExperienceInstitutionPartenaire, lazy=True),
                           'clpsOrigine': relation(Clps,
                                                   uselist=False)})
                           #'institution_ressource': relation(LinkExperienceInstitutionRessource, lazy=True),
                           #'ressource': relation(LinkExperienceRessource, lazy=True)
        model.add('experience',
                  table=experienceTable,
                  mapper_class=Experience)

        LinkExperienceInstitutionPorteurTable = getLinkExperienceInstitutionPorteur(metadata)
        LinkExperienceInstitutionPorteurTable.create(checkfirst=True)
        mapper(LinkExperienceInstitutionPorteur, LinkExperienceInstitutionPorteurTable,
               properties={'institution_porteur': relation(Institution, lazy=True)})
        model.add('link_experience_institution_porteur',
                  table=LinkExperienceInstitutionPorteurTable,
                  mapper_class=LinkExperienceInstitutionPorteur)

        LinkExperienceInstitutionPartenaireTable = getLinkExperienceInstitutionPartenaire(metadata)
        LinkExperienceInstitutionPartenaireTable.create(checkfirst=True)
        mapper(LinkExperienceInstitutionPartenaire, LinkExperienceInstitutionPartenaireTable,
               properties={'institution_partenaire': relation(Institution, lazy=True)})
        model.add('link_experience_institution_partenaire',
                  table=LinkExperienceInstitutionPartenaireTable,
                  mapper_class=LinkExperienceInstitutionPartenaire)

        LinkExperienceInstitutionRessourceTable = getLinkExperienceInstitutionRessource(metadata)
        LinkExperienceInstitutionRessourceTable.create(checkfirst=True)
        mapper(LinkExperienceInstitutionRessource, LinkExperienceInstitutionRessourceTable,
               properties={'institution_ressource': relation(Institution, lazy=True)})
        model.add('link_experience_institution_ressource',
                  table=LinkExperienceInstitutionRessourceTable,
                  mapper_class=LinkExperienceInstitutionRessource)

        LinkExperienceRessourceTable = getLinkExperienceRessource(metadata)
        LinkExperienceRessourceTable.create(checkfirst=True)
        mapper(LinkExperienceRessource, LinkExperienceRessourceTable)
        model.add('link_experience_ressource',
                  table=LinkExperienceRessourceTable,
                  mapper_class=LinkExperienceRessource)

        LinkExperienceMilieuDeVieTable = getLinkExperienceMilieuDeVie(metadata)
        LinkExperienceMilieuDeVieTable.create(checkfirst=True)
        mapper(LinkExperienceMilieuDeVie, LinkExperienceMilieuDeVieTable)
        model.add('link_experience_milieudevie',
                  table=LinkExperienceMilieuDeVieTable,
                  mapper_class=LinkExperienceMilieuDeVie)

        LinkExperienceSousPlateFormeTable = getLinkExperienceSousPlateForme(metadata)
        LinkExperienceSousPlateFormeTable.create(checkfirst=True)
        mapper(LinkExperienceSousPlateForme, LinkExperienceSousPlateFormeTable)
        model.add('link_experience_sousplateforme',
                  table=LinkExperienceSousPlateFormeTable,
                  mapper_class=LinkExperienceSousPlateForme)

        LinkExperienceMotCleTable = getLinkExperienceMotCle(metadata)
        LinkExperienceMotCleTable.create(checkfirst=True)
        mapper(LinkExperienceMotCle, LinkExperienceMotCleTable)
        model.add('link_experience_mot_cle',
                  table=LinkExperienceMotCleTable,
                  mapper_class=LinkExperienceMotCle)

        LinkExperienceThemeTable = getLinkExperienceTheme(metadata)
        LinkExperienceThemeTable.create(checkfirst=True)
        mapper(LinkExperienceTheme, LinkExperienceThemeTable)
        model.add('link_experience_theme',
                  table=LinkExperienceThemeTable,
                  mapper_class=LinkExperienceTheme)

        LinkExperiencePublicTable = getLinkExperiencePublic(metadata)
        LinkExperiencePublicTable.create(checkfirst=True)
        mapper(LinkExperiencePublic, LinkExperiencePublicTable)
        model.add('link_experience_public',
                  table=LinkExperiencePublicTable,
                  mapper_class=LinkExperiencePublic)

        LinkExperienceClpsProprioTable = getLinkExperienceClpsProprio(metadata)
        LinkExperienceClpsProprioTable.create(checkfirst=True)
        mapper(LinkExperienceClpsProprio, LinkExperienceClpsProprioTable)
        model.add('link_experience_clps_proprio',
                  table=LinkExperienceClpsProprioTable,
                  mapper_class=LinkExperienceClpsProprio)

        LinkExperienceCommuneTable = getLinkExperienceCommune(metadata)
        LinkExperienceCommuneTable.create(checkfirst=True)
        mapper(LinkExperienceCommune, LinkExperienceCommuneTable)
        model.add('link_experience_commune',
                  table=LinkExperienceCommuneTable,
                  mapper_class=LinkExperienceCommune)

## table experiencemaj > versionning ##
        experienceMajTable = getAllExperienceMaj(metadata)
        experienceMajTable.create(checkfirst=True)
        mapper(ExperienceMaj, experienceMajTable,
               properties={'clps_proprio': relation(Clps, uselist=False)})
        model.add('experience_maj',
                  table=experienceMajTable,
                  mapper_class=ExperienceMaj)

## table rechercheLog ##
        rechercheLogTable = getAllRechercheLog(metadata)
        rechercheLogTable.create(checkfirst=True)
        mapper(RechercheLog, rechercheLogTable)
        model.add('rechercheLog',
                  table=rechercheLogTable,
                  mapper_class=Recit)

        metadata.create_all()
        return model
Пример #13
0
    def getModel(self, metadata=None):
        """
            The model is described as an ordered dictionary.  The entries are
            (tablename, some_dict) where 'some_dict' is a dictionary containing a
            key 'table' referencing a Table() instance and an optional key
            'relationships' referencing a sequence of related table names. An
            optional mapper class can be specified through the 'class' key
            (otherwise a default mapper class will be autogenerated).
        """
        utils.initialize_declarative_mappers(DeclarativeBase, metadata)
        model = Model()
        model.metadata = metadata
        model.add('reservation_proprio',
                  table=ReservationProprio.__table__,
                  mapper_class=ReservationProprio)
        model.add('commune', table=Commune.__table__,
                  mapper_class=Commune)

        model.add('localite', table=Localite.__table__,
                  mapper_class=Localite)

        model.add('proprio', table=Proprio.__table__,
                  mapper_class=Proprio)
        model.add('proprio_maj', table=ProprioMaj.__table__,
                  mapper_class=ProprioMaj)
        model.add('province', table=Province.__table__,
                  mapper_class=Province)
        model.add('charge', table=Charge.__table__,
                  mapper_class=Charge)
        model.add('hebergement', table=Hebergement.__table__,
                  mapper_class=Hebergement)
        model.add('hebergement_app', table=HebergementApp.__table__,
                  mapper_class=HebergementApp)
        model.add('hebergement_maj', table=HebergementMaj.__table__,
                  mapper_class=HebergementMaj)
        model.add('hebergement_video', table=HebergementVideo.__table__,
                  mapper_class=HebergementVideo)
        model.add('maison_tourisme', table=MaisonTourisme.__table__,
                  mapper_class=MaisonTourisme)
        model.add('type_heb', TypeHebergement.__table__,
                  mapper_class=TypeHebergement)
        model.add('info_touristique', table=InfoTouristique.__table__,
                  mapper_class=InfoTouristique)
        model.add('type_info_touristique', table=TypeInfoTouristique.__table__,
                  mapper_class=TypeInfoTouristique)
        model.add('info_pratique', table=InfoPratique.__table__,
                  mapper_class=InfoPratique)
        model.add('type_info_pratique', table=TypeInfoPratique.__table__,
                  mapper_class=TypeInfoPratique)
        model.add('table_hote', table=TableHote.__table__,
                  mapper_class=TableHote)
        model.add('heb_tab_hote_maj', table=TypeTableHoteOfHebergementMaj.__table__,
                  mapper_class=TypeTableHoteOfHebergementMaj)
        model.add('log_item', table=LogItem.__table__,
                  mapper_class=LogItem)
        model.add('map_provider',
                  table=MapProvider.__table__,
                  mapper_class=MapProvider)
        model.add('map_blacklist',
                  table=MapBlacklist.__table__,
                  mapper_class=MapBlacklist)
        model.add('map_external_data',
                  table=MapExternalData.__table__,
                  mapper_class=MapExternalData)
        model.add('link_hebergement_metadata',
                  table=LinkHebergementMetadata.__table__,
                  mapper_class=LinkHebergementMetadata)
        model.add('metadata_type',
                  table=MetadataType.__table__,
                  mapper_class=MetadataType)
        model.add('metadata',
                  table=Metadata.__table__,
                  mapper_class=Metadata)
        model.add('civilite',
                  table=Civilite.__table__,
                  mapper_class=Civilite)
        model.add('blockinghistory',
                  table=BlockingHistory.__table__,
                  mapper_class=BlockingHistory)
        model.add('hebergementblockinghistory',
                  table=HebergementBlockingHistory.__table__,
                  mapper_class=HebergementBlockingHistory)
        model.add('linkhebergementepis',
                  table=LinkHebergementEpis.__table__,
                  mapper_class=LinkHebergementEpis)

        model.add('notification_origin', table=NotificationOrigin.__table__,
                  mapper_class=NotificationOrigin)
        model.add('notification', table=Notification.__table__,
                  mapper_class=Notification)
        model.add('cron', table=Cron.__table__, mapper_class=Cron)

        utils.initialize_defered_mappers(model.metadata)
        return model
Пример #14
0
    def getModel(self, metadata=None):
        """
            table de demo employe
        """
        model = Model()
        model.metadata = metadata

## table periodique ##
        periodiqueTable = getAllPeriodique(metadata)
        periodiqueTable.create(checkfirst=True)
        mapper(Periodique, periodiqueTable)
        model.add('periodique', table=periodiqueTable, mapper_class=Periodique)

## table auteur ##
        auteurTable = getAllAuteur(metadata)
        auteurTable.create(checkfirst=True)
        mapper(Auteur, auteurTable)
        model.add('auteur', table=auteurTable, mapper_class=Auteur)

## table livre ##
        livreTable = getAllLivre(metadata)
        livreTable.create(checkfirst=True)
        mapper(Livre, livreTable)
        model.add('livre', table=livreTable, mapper_class=Livre)

## table jointure link_livre_auteur ##
        linkLivreAuteurTable = getLinkLivreAuteur(metadata)
        linkLivreAuteurTable.create(checkfirst=True)
        mapper(LinkLivreAuteur, linkLivreAuteurTable,
                primary_key=[linkLivreAuteurTable.c.livre_fk, linkLivreAuteurTable.c.auteur_fk],
                properties={'livres': relationship(Livre,
                                                   order_by=[livreTable.c.liv_titre]),
                            'auteurs': relationship(Auteur,
                                                    order_by=[auteurTable.c.auteur_nom])})
        model.add('link_livre_auteur',
                   table=linkLivreAuteurTable,
                   mapper_class=LinkLivreAuteur)

## table affiche ##
        afficheTable = getAllAffiche(metadata)
        afficheTable.create(checkfirst=True)
        mapper(Affiche, afficheTable)
        model.add('affiche', table=afficheTable, mapper_class=Affiche)

## table formation ##
        formationTable = getAllFormation(metadata)
        formationTable.create(checkfirst=True)
        mapper(Formation, formationTable)
        model.add('formation', table=formationTable, mapper_class=Formation)

## table formation_inscription ##
        formationInscriptionTable = getAllFormationInscription(metadata)
        formationInscriptionTable.create(checkfirst=True)
        mapper(FormationInscription, formationInscriptionTable)
        model.add('formation_inscription', table=formationInscriptionTable, mapper_class=FormationInscription)

## table jointure link_formation_inscription
        linkFormationInscriptionTable = getLinkFormationInscription(metadata)
        linkFormationInscriptionTable.create(checkfirst=True)
        mapper(LinkFormationInscription, linkFormationInscriptionTable,
                primary_key=[linkFormationInscriptionTable.c.lnk_formation_pk, linkFormationInscriptionTable.c.lnk_inscription_pk],
                properties={'formations' : relationship(Formation, order_by=[formationTable.c.form_titre]),
                            'inscrits' : relationship(FormationInscription, order_by=[formationInscriptionTable.c.form_ins_nom])})
        model.add('link_formation_inscription',
                   table=linkFormationInscriptionTable,
                   mapper_class=LinkFormationInscription)

        metadata.create_all()
        return model
Пример #15
0
    def getModel(self, metadata=None):
        """
        cesstex
        """
        model = Model()
        model.metadata = metadata

        etatPublicationTable = getEtatPublication(metadata)
        etatPublicationTable.create(checkfirst=True)

        statutMembreTable = getStatutMembre(metadata)
        statutMembreTable.create(checkfirst=True)

        ecoleTable = getEcole(metadata)
        ecoleTable.create(checkfirst=True)

        implantationTable = getImplantation(metadata)
        implantationTable.create(checkfirst=True)

        professeurTable = getProfesseur(metadata)
        professeurTable.create(checkfirst=True)

        eleveIsmTable = getEleveIsm(metadata)
        eleveIsmTable.create(checkfirst=True)

        classeIsmTable = getClasseIsm(metadata)
        classeIsmTable.create(checkfirst=True)

        eleveDossierDisciplinaireTable = getEleveDossierDisciplinaire(metadata)
        eleveDossierDisciplinaireTable.create(checkfirst=True)

        dossierDisciplinaireTable = getDossierDisciplinaire(metadata)
        dossierDisciplinaireTable.create(checkfirst=True)

        evenementActeTable = getEvenementActe(metadata)
        evenementActeTable.create(checkfirst=True)

        evenementActeDocumentTable = getEvenementActeDocument(metadata)
        evenementActeDocumentTable.create(checkfirst=True)

        evenementActeLogModificationTable = getEvenementActeLogModification(metadata)
        evenementActeLogModificationTable.create(checkfirst=True)

        logOperationTable = getLogOperation(metadata)
        logOperationTable.create(checkfirst=True)

        mapper(EtatPublication, etatPublicationTable)

        mapper(StatutMembre, statutMembreTable)

        mapper(Ecole, ecoleTable)

        mapper(Implantation, implantationTable)

        mapper(Professeur, professeurTable,
               properties={'statut': relationship(StatutMembre,
                                     primaryjoin=(professeurTable.c.prof_statut_fk == statutMembreTable.c.statmembre_pk)),
                           'ecole': relationship(Ecole,
                                     primaryjoin=(professeurTable.c.prof_ecole_fk == ecoleTable.c.ecole_pk))})

        mapper(ClasseIsm, classeIsmTable,
               properties={'titulaire01': relationship(Professeur,
                                          primaryjoin=(classeIsmTable.c.classeism_titulaire_01_fk == professeurTable.c.prof_pk)),
                           'titulaire02': relationship(Professeur,
                                          primaryjoin=(classeIsmTable.c.classeism_titulaire_02_fk == professeurTable.c.prof_pk))})

        mapper(EleveIsm, eleveIsmTable,
               properties={'classe': relationship(ClasseIsm,
                                     primaryjoin=(eleveIsmTable.c.eleveism_classe_fk == classeIsmTable.c.classeism_pk))})


        mapper(DossierDisciplinaire, dossierDisciplinaireTable,
                       properties={'student': relationship(EleveDossierDisciplinaire),
                                   'auteur': relationship(Professeur)})

        mapper(EleveDossierDisciplinaire, eleveDossierDisciplinaireTable,
               properties={'dossierEleve': relationship(DossierDisciplinaire,
                                           primaryjoin=(dossierDisciplinaireTable.c.dosdis_eleve_fk == eleveDossierDisciplinaireTable.c.eleve_pk)),
                           'titulaire01': relationship(Professeur,
                                          primaryjoin=(eleveDossierDisciplinaireTable.c.eleve_prof_titulaire_01_fk == professeurTable.c.prof_pk),
                                          order_by=[eleveDossierDisciplinaireTable.c.eleve_nom]),
                           'titulaire02': relationship(Professeur,
                                          primaryjoin=(eleveDossierDisciplinaireTable.c.eleve_prof_titulaire_02_fk == professeurTable.c.prof_pk)),
                           'educateurReferent': relationship(Professeur,
                                                primaryjoin=(eleveDossierDisciplinaireTable.c.eleve_educateur_referent_fk == professeurTable.c.prof_pk),
                                                order_by=[eleveDossierDisciplinaireTable.c.eleve_nom])})

        mapper(EvenementActe, evenementActeTable,
               properties={'etat': relationship(EtatPublication,
                                   primaryjoin=(evenementActeTable.c.eventact_etat_publication_fk == etatPublicationTable.c.etat_pk),
                                   order_by=[etatPublicationTable.c.etat_titre]),
                           'auteur': relationship(Professeur,
                                     primaryjoin=(evenementActeTable.c.eventact_auteur_creation_fk == professeurTable.c.prof_pk)),
                           'dossier': relationship(DossierDisciplinaire,
                                      primaryjoin=(evenementActeTable.c.eventact_dossier_diciplinaire_fk == dossierDisciplinaireTable.c.dosdis_pk),
                                      order_by=[desc(dossierDisciplinaireTable.c.dosdis_date_creation)]),
                           'documentAttache': relationship(EvenementActeDocument,
                                              primaryjoin=(evenementActeTable.c.eventact_pk == evenementActeDocumentTable.c.eventactdoc_eventact_fk))})

        mapper(EvenementActeDocument, evenementActeDocumentTable,
               properties={'auteur': relationship(Professeur,
                                        primaryjoin=(evenementActeDocumentTable.c.eventactdoc_auteur_creation_fk == professeurTable.c.prof_pk)),
                           'evenement': relationship(EvenementActe,
                                        primaryjoin=(evenementActeDocumentTable.c.eventactdoc_eventact_fk == evenementActeTable.c.eventact_pk)),
                           'dossier': relationship(DossierDisciplinaire,
                                      primaryjoin=(evenementActeDocumentTable.c.eventactdoc_dossier_disciplinaire_fk == dossierDisciplinaireTable.c.dosdis_pk))})

        mapper(EvenementActeLogModification, evenementActeLogModificationTable,
               properties={'logmodif': relationship(EvenementActe,
                                       primaryjoin=(evenementActeLogModificationTable.c.eventactlogmodif_evenement_acte_fk == evenementActeTable.c.eventact_pk),
                                       order_by=[evenementActeLogModificationTable.c.eventactlogmodif_date_modification])})

        mapper(LogOperation, logOperationTable)

        metadata.create_all()
        return model
Пример #16
0
    'children' : relation(
                    HierarchyNode,
                    primaryjoin=HierarchyTable.c.parentid==HierarchyTable.c.id,
                    cascade="all",
                    backref=backref("parent", remote_side=[HierarchyTable.c.id])
                 ),
    'parent' : relation(
                    HierarchyNode,
                    primaryjoin=HierarchyTable.c.parentid==HierarchyTable.c.id,
                    remote_side=[HierarchyTable.c.id],
                    uselist=False,
                 ),
    }
)

m = Model()
m.add('hierarchy', table=HierarchyTable, mapper_class=HierarchyNode)





wrapper = createSQLAlchemyWrapper(dsn, model=m)
session = wrapper.session


H = wrapper.getMapper('hierarchy')

print H
rows = session.query(H).select_by(H.c.id==8)
print rows[0].children