Hi!
I'm developing an web2py application that use an external SQL Server
database. I can connect to the SQL Server database using migrate=False in
those tables I need to access. In addition I create my own tables from
web2py (also they connect to SQL Server). My troubles begin when one of my
tables (created with web2py) intents to connect with the external database.
When I try to connect I get the "cannot resolve reference" error.
Below I show the significant code of my application:
In db.py:
db = DAL('mssql://connection to SQL Server database created with web2py')
db2= DAL('mssql://connection to External SQL Server database')
# Table personal_personal is external (was not created with web2py, it's
not complete, only show the most important)
db2.define_table('personal_personal',
Field('foto_personal', 'blob', notnull=False),
Field('firma_personal', 'blob', notnull=False),
Field('id_personal', 'id', requires=IS_NOT_IN_DB(db2,
'personal_personal.id_personal'), unique=True, notnull=True), #Primary key,
not auto-increment
Field('id_categoria', db2.personal_catalogo_categoria,
requires = IS_IN_DB(db2, db2.personal_catalogo_categoria.id_categoria,
'%(id_categoria)s'), notnull=True),
Field('id_areataller', db2.mtto_areataller, requires =
IS_IN_DB(db2, db2.mtto_areataller.id_areataller, '%(id_areataller)s'),
notnull=False),
Field('id_area', 'reference general_area.id_area',
requires = IS_IN_DB(db2, db2.general_area.id_area, '%(id_area)s -
%(nombre)s'), notnull=True),
Field('id_depto', 'reference
general_departamentos.id_depto', requires = IS_IN_DB(db2,
db2.general_departamentos.id_depto, '%(id_depto)s - %(descripcion)s'),
notnull=False),
Field('cant_hijos', 'integer', notnull=False),
Field('status_foto', 'integer', notnull=False),
Field('status_firma', 'integer', notnull=False),
Field('porcent_ret_descuent', 'integer', notnull=False),
Migrate=False)
Below personal_personal is defined the following table:
db.define_table('unidades',
Field('nombre', requires=IS_NOT_EMPTY()),
Field('descripcion'),
Field('tipo_unidad', db.tipo_unidades),
Field('operador', 'reference
db2.personal_personal.id_personal', requires = IS_IN_DB(db2,
db2.personal_personal.id_personal, '%(nombre)s')),
format='%(operador)s'
)
The 'operador' field reference the table personal_personal.
In a controller I have the following code:
def nueva_unidad():
form=SQLFORM(db.unidades, submit_button="Aceptar")
if form.accepts(request.vars, session):
redirect(URL(r=request, f='nueva_unidad'))
response.flash = 'Se ha creado una nueva unidad'
return dict( form=form)
When I call this function is when I get the error:
'Cannot resolve reference
db2.personal_personal.id_personal in unidades definition'
How can I to correct this error? Any Idea?
Thanks in advanced.
Regards.
--
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
---
You received this message because you are subscribed to the Google Groups
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.