Hi List,

I'm stumbling slightly blind and just wanted to check if there is a smarter
way of doing what I'm doing. I'm using declarative classes to make the DB,
and example class below:

class ArkContact(Base):
    """
    all contacts
    """
    __tablename__ = 'contacts'

    id = Column(Integer, primary_key=True)
    project_id = Column(Integer, ForeignKey('projects.id'))
    client_id = Column(Integer, ForeignKey('clients.id'))
    firstname = Column(String)
    lastname = Column(String)
    email1 = Column(String)
    email2 = Column(String)
    workphone = Column(Integer)
    mobile = Column(Integer)
    project = relation(ArkProject, backref=backref('contacts',
order_by=func.lower(firstname)), cascade='all, delete')
    client = relation(ArkClient, backref=backref('contacts',
order_by=func.lower(firstname)), cascade='all, delete')

    def __init__(self):
        self.firstname = ''
        self.lastname = ''
        self.email1 = ''
        self.email2 = ''
        self.workphone = ''
        self.mobile = ''

In one of my controllers, I've created an ArkContact as above, and need to
set the 'client' and 'project' attributes. Currently I'm doing it like this:

contact=ArkContact()
contact.client=Session.query(ArkClient).filter(ArkClient.client=='clientName
').first()
Session.add(contact)
Session.commit()

This does seem to work, but I just wanted to know if this is the 'correct'
way of doing things, it seems a little strange to me.

Many thanks for any assistance.

Jules


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

Reply via email to