Hi List,

I have a user class, a contact class, and a googleID class.

the contact class has can have a googleID per user in the system. I'm
trying to map it out as follows:

# ArkContact - clientprojectshot module
orm.mapper(ArkContact, contacts_table, properties={
    'notes': orm.relation(ArkNote,
            secondary=contact_notes_table,
            backref='contacts',
            single_parent=True,
            cascade="all, delete, delete-orphan"),
    'users': orm.relation(ArkUser,
            secondary=user_contact_table,
            backref='contacts'),
    'google_UID': orm.relation(ArkUserContactGUID,
            cascade="all, delete",
            backref='user')
})

#user contact google_GUID
user_contact_UID = sa.Table('user_contact_UID_table', meta.metadata,
    sa.Column('user_id', sa.types.Integer, sa.ForeignKey('users.id'),
primary_key=True),
    sa.Column('contact_id', sa.types.Integer,
sa.ForeignKey('contacts.id'), primary_key=True),
    sa.Column('google_UID', sa.types.String(length = 1024))
)

class ArkUserContactGUID(object):
    def __init__(self):
        pass

orm.mapper(ArkUserContactGUID, user_contact_UID)

This raises two issues, the first is that an instrumented list is
returned for the google_UID paramter on the contact object, whereas
there should only ever be one (since as an operator there is only ever
one user signed in - you).

The second is it outright errors :), presumably because my mapping is off:

File 'C:\\ark\\ark\\controllers\\contacts.py', line 368 in initial_sync
  contact_sync.initial_sync()
File 'C:\\ark\\ark\\arkTools\\arkGoogle.py', line 121 in initial_sync
  self.add_contact_to_google(contact)
File 'C:\\ark\\ark\\arkTools\\arkGoogle.py', line 259 in add_contact_to_google
  data.google_UID.append(entry.get_id())
File 
'C:\\ark\\env_x64\\lib\\site-packages\\sqlalchemy-0.7.1-py2.6.egg\\sqlalchemy\\orm\\collections.py',
line 952 in append
  item = __set(self, item, _sa_initiator)
File 
'C:\\ark\\env_x64\\lib\\site-packages\\sqlalchemy-0.7.1-py2.6.egg\\sqlalchemy\\orm\\collections.py',
line 927 in __set
  item = getattr(executor, 'fire_append_event')(item, _sa_initiator)
File 
'C:\\ark\\env_x64\\lib\\site-packages\\sqlalchemy-0.7.1-py2.6.egg\\sqlalchemy\\orm\\collections.py',
line 618 in fire_append_event
  item, initiator)
File 
'C:\\ark\\env_x64\\lib\\site-packages\\sqlalchemy-0.7.1-py2.6.egg\\sqlalchemy\\orm\\attributes.py',
line 741 in fire_append_event
  value = fn(state, value, initiator or self)
File 
'C:\\ark\\env_x64\\lib\\site-packages\\sqlalchemy-0.7.1-py2.6.egg\\sqlalchemy\\orm\\unitofwork.py',
line 35 in append
  item_state = attributes.instance_state(item)
AttributeError: 'str' object has no attribute '_sa_instance_state'

Many thanks for any help!

Jules

-- 
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
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