> a reference - as it is in your case (padre means parent, right?) Yes, padre means parent
> give relation( ... use_list=False). Mmmm... no: <code> Traceback (most recent call last): File "/home/marcos/easyeclipse-python-1.2.2.2/workspace/mine/jContab/ src/jContab/test.py", line 20, in ? mapper(Cuenta, cuentas_tabla, properties={'padre':relation(Cuenta,use_list=False)}) File "/usr/lib/python2.4/site-packages/SQLAlchemy-0.4.2-py2.4.egg/ sqlalchemy/orm/__init__.py", line 269, in relation return PropertyLoader(argument, secondary=secondary, **kwargs) TypeError: __init__() got an unexpected keyword argument 'use_list' </code> I did it right? or I made a mistake? Thanks for your reply, Marcos On 14 jul, 10:11, [EMAIL PROTECTED] wrote: > AFAIRemember, by default, relation assumes it is a collection, and not > a reference - as it is in your case (padre means parent, right?) > give relation( ... use_list=False). > > On Monday 14 July 2008 15:21:48 Marcos wrote: > > > Hello! > > First, sorry about my english! > > > I'm having this little problem, and i can't see where is my error. > > I have the follow code: > > > <code> > > from sqlalchemy import * > > from sqlalchemy.orm import * > > > class Cuenta(object): > > def __init__(self, codigo, de_titulo, descripcion, padre): > > self.codigo = codigo > > self.de_titulo = de_titulo > > self.descripcion = descripcion > > self.padre = padre > > > _metadata = MetaData() > > > cuentas_tabla = Table('cuentas', _metadata, > > Column('id', Integer, primary_key=True), > > Column('codigo', String(30), unique=True, > > nullable=False), > > Column('de_titulo', Boolean, nullable=False), > > Column('descripcion', String(150), > > unique=True, nullable=False), > > Column('cuenta_padre', Integer, > > ForeignKey('cuentas.id'), nullable=True) > > ) > > mapper(Cuenta, cuentas_tabla, properties={'padre':relation(Cuenta, > > backref='hijas')}) > > > engine = create_engine('sqlite:///database.txt') > > Session = sessionmaker(bind=engine, autoflush=True, > > transactional=False) > > _metadata.create_all(bind=engine) > > session = Session() > > session.begin() > > activo = Cuenta(codigo='1', > > de_titulo=True, > > descripcion='Activo', > > padre=None) > > fachadaPersistencia.save(activo) > > caja = Cuenta(codigo='1.1', > > de_titulo = False, > > descripcion='Caja', > > padre=activo) > > fachadaPersistencia.save(caja) > > banco = Cuenta(codigo='1.2', > > de_titulo = False, > > descripcion='Banco', > > padre=activo) > > fachadaPersistencia.save(banco) > > pasivo = Cuenta(codigo='2', > > de_titulo=True, > > descripcion='Pasivo', > > padre=None) > > session.save(pasivo) > > session.commit() > > </code> > > > And i have the next exception: > > <code> > > Traceback (most recent call last): > > File > > "/home/marcos/easyeclipse-python-1.2.2.2/workspace/mine/jContab/ > > src/jContab/test.py", line 30, in ? > > padre=None) > > File > > "/usr/lib/python2.4/site-packages/SQLAlchemy-0.4.2-py2.4.egg/ > > sqlalchemy/orm/attributes.py", line 1126, in init > > oldinit(instance, *args, **kwargs) > > File > > "/home/marcos/easyeclipse-python-1.2.2.2/workspace/mine/jContab/ > > src/jContab/test.py", line 9, in __init__ > > self.padre = padre > > File > > "/usr/lib/python2.4/site-packages/SQLAlchemy-0.4.2-py2.4.egg/ > > sqlalchemy/orm/attributes.py", line 36, in __set__ > > self.impl.set(instance._state, value, None) > > File > > "/usr/lib/python2.4/site-packages/SQLAlchemy-0.4.2-py2.4.egg/ > > sqlalchemy/orm/attributes.py", line 532, in set > > new_values = list(new_collection.adapt_like_to_iterable(value)) > > File > > "/usr/lib/python2.4/site-packages/SQLAlchemy-0.4.2-py2.4.egg/ > > sqlalchemy/orm/collections.py", line 509, in adapt_like_to_iterable > > raise TypeError( > > TypeError: Incompatible collection type: NoneType is not list-like > > </code> > > > If I quit the backref, i'm still having that error. If anybody can > > help me, i will appreciate that. > > > Thanks, > > > Marcos Alcazar > > Mendoza, Argentina --~--~---------~--~----~------------~-------~--~----~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en -~----------~----~----~----~------~----~------~--~---