On Mar 14, 2011, at 6:26 AM, Christian Démolis wrote:

> Hi all,
> 
> I have a question about many to many Table containing attribute.
> How to access and write Max attribute in many to many table ?
> 
> I already read that but i try to not use mapper and stay in declarative mode 
> which is more user friendly :)
> http://www.sqlalchemy.org/docs/05/reference/ext/associationproxy.html

not sure why google keeps returning the 05 docs, I've got them disallowed in 
robots.txt.

Here's the current docs which illustrate a declarative example:

http://www.sqlalchemy.org/docs/orm/relationships.html#association-object




> 
> PlageTypeActe = Table('plage_type_acte', Base.metadata,
>     Column('IdPlage', Integer, ForeignKey('plage_type.IdPlage'), 
> primary_key=True),
>     Column('IdActe', Integer, ForeignKey('acte.IdActe'), primary_key=True),
>     Column('Max', Integer)
> )
> 
> class PlageType(Base):
>     __tablename__ = 'plage_type'
>     Typage = 2
>     IdPlage = Column('IdPlage', Integer, primary_key=True)
>     Debut = Column('Debut', DateTime)
>     Fin = Column('Fin', DateTime)
>     JourSemaine = Column('JourSemaine', Integer)
>     EtatPrecedent = Column('EtatPrecedent', String)
>     EtatCourant = Column('EtatCourant', String)
>     EtatSuivant = Column('EtatSuivant', String)
>     Max = Column('Max', Integer)
>     SurchargeVad = Column('SurchargeVad', Boolean)
>     StopVad = Column('StopVad', Time)
>     Creation = Column('Creation', DateTime)
>     Modification = Column('Modification', DateTime)
>     MaxDejaVenu = Column('MaxDejaVenu', Integer)
>     MaxJamaisVenu = Column('MaxJamaisVenu', Integer)
>     MaxActif = Column('MaxActif', Integer)
>     MaxInactif = Column('MaxInactif', Integer)
>     MaxPatient = Column('MaxPatient', Integer)
>     MaxDelegue = Column('MaxDelegue', Integer)
>     MaxCmu = Column('MaxCmu', Integer)
>     MaxNonCmu = Column('MaxNonCmu', Integer)
>     AgeMini = Column('AgeMini', Integer)
>     AgeMaxi = Column('AgeMaxi', Integer)
>     IdSemaineType = Column('IdSemaineType', 
> ForeignKey('semaine_type.IdSemaineType'))
>     IdDossier = Column('IdDossier', ForeignKey('dossier.IdDossier'))
>     IdLieu = Column('IdLieu', ForeignKey('lieu.IdLieu'))
>     NomRemplacement = Column('NomRemplacement', String)
>     PlageTypeActe = relationship(Acte, secondary=PlageTypeActe, 
> backref="plage_type")
>     def __init__(self,
>         Debut=datetime.datetime.today(),
>         Fin=datetime.datetime.today(),
>         JourSemaine=0,
>         EtatPrecedent="",
>         EtatCourant="",
>         EtatSuivant="",
>         Max=0,
>         SurchargeVad=0,
>         StopVad=datetime.time(),
>         Creation=datetime.datetime.today(),
>         Modification=datetime.datetime.today(),
>         MaxDejaVenu=-1,
>         MaxJamaisVenu=-1,
>         MaxActif=-1,
>         MaxInactif=-1,
>         MaxPatient=-1,
>         MaxDelegue=-1,
>         MaxCmu=-1,
>         MaxNonCmu=-1,
>         AgeMini = 0,
>         AgeMaxi = 0, 
>         IdSemaineType = 0,
>         IdDossier = 0,
>         IdLieu = 0,
>         NomRemplacement = ""
>         ):
>         self.Debut = Debut
>         self.Fin = Fin
>         self.JourSemaine = JourSemaine
>         self.EtatPrecedent = EtatPrecedent
>         self.EtatCourant = EtatCourant
>         self.EtatSuivant = EtatSuivant
>         self.Max = Max
>         self.SurchargeVad = SurchargeVad
>         self.StopVad = StopVad
>         self.Creation = Creation
>         self.Modification = Modification
>         self.MaxDejaVenu = MaxDejaVenu
>         self.MaxJamaisVenu = MaxJamaisVenu
>         self.MaxActif = MaxActif
>         self.MaxInactif = MaxInactif
>         self.MaxPatient = MaxPatient
>         self.MaxDelegue = MaxDelegue
>         self.MaxCmu = MaxCmu
>         self.MaxNonCmu = MaxNonCmu
>         self.AgeMini = AgeMini
>         self.AgeMaxi = AgeMaxi
>         self.IdSemaineType = IdSemaineType
>         self.IdDossier = IdDossier
>         self.IdLieu = IdLieu
>         self.NomRemplacement = NomRemplacement
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "sqlalchemy" group.
> To post to this group, send email to sqlalchemy@googlegroups.com.
> To unsubscribe from this group, send email to 
> sqlalchemy+unsubscr...@googlegroups.com.
> For more options, visit this group at 
> http://groups.google.com/group/sqlalchemy?hl=en.

-- 
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To post to this group, send email to sqlalchemy@googlegroups.com.
To unsubscribe from this group, send email to 
sqlalchemy+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en.

Reply via email to