Re: [web2py] Re: FOREIGN KEY constraint failed

2017-07-18 Thread Santiago Cartasegna
Glad that my idea helped!

2017-07-18 6:20 GMT-03:00 mostwanted <godirao...@gmail.com>:

> I was able o solve the problem, when i was creating the tables i copied
> and pasted a code for the '*governmetFormPages' *table but to correct the
> error i had to delete the table and type its code word for word, that
> solved my problem. thanks for the input guys. Santiago Cartasegna  was
> right.
>
> On Sunday, July 2, 2017 at 10:37:22 AM UTC+2, mostwanted wrote:
>>
>> Hi guys, i need help, i'm pulling my hairs out over here, i have a
>> website where when i'm trying to record an entry i get an error:
>>  FOREIGN KEY constraint failed
>>
>>
>> I have been able to create 2 forms but other attempts to create more
>> forms fail!!
>>
>>
>> These are my tables;
>>
>>
>> db.define_table('government',
>> Field('govName', requires=IS_NOT_EMPTY()),
>> Field('tel', requires=IS_NOT_EMPTY()),
>> Field('email', requires=IS_NOT_EMPTY()),
>> format='%(govName)s',  migrate=False,fake_migrate=True)
>>
>>
>> db.define_table('governmenttForm',
>> Field('formImage', 'upload'),
>> Field('filledformImage', 'upload'),
>> Field('formName',requires=IS_NOT_EMPTY()),
>> Field('governmentName', 'reference government'),
>> format='%(formName)s',migrate=False,fake_migrate=True)
>>
>> db.define_table('governmetFormPages',
>> Field('formImage', 'upload'),
>> Field('formTitle',requires=IS_NOT_EMPTY()),
>> Field('formName', 'reference
>> govmntForm'),migrate=False,fake_migrate=True)
>>
>>
>> I am able to create a form for the governmentForm table but when i try to
>> load up the pages for governmentFormPages table i get the error
>>  FOREIGN KEY constraint failed
>>
>>
>> Below is the stack
>> Error ticket for "formulator" Ticket ID
>>
>> 127.0.0.1.2017-07-02.10-06-22.18c363e3-13c2-47f7-ace4-3692239493c4
>>  FOREIGN KEY constraint failed Version
>> web2py™ Version 2.14.6-stable+timestamp.2016.05.10.00.21.47 Traceback
>>
>> 1.
>> 2.
>> 3.
>> 4.
>> 5.
>> 6.
>> 7.
>> 8.
>> 9.
>> 10.
>> 11.
>> 12.
>> 13.
>> 14.
>> 15.
>> 16.
>>
>> Traceback (most recent call last):
>>   File "/home/mostwanted/web2py/gluon/restricted.py", line 227, in restricted
>> exec ccode in environment
>>   File 
>> "/home/mostwanted/web2py/applications/formulator/controllers/appadmin.py" 
>> <http://127.0.0.1:8000/admin/default/edit/formulator/controllers/appadmin.py>,
>>  line 703, in 
>>   File "/home/mostwanted/web2py/gluon/globals.py", line 417, in 
>> self._caller = lambda f: f()
>>   File 
>> "/home/mostwanted/web2py/applications/formulator/controllers/appadmin.py" 
>> <http://127.0.0.1:8000/admin/default/edit/formulator/controllers/appadmin.py>,
>>  line 151, in insert
>> if form.accepts(request.vars, session):
>>   File "/home/mostwanted/web2py/gluon/sqlhtml.py", line 1746, in accepts
>> self.vars.id = self.table.insert(**fields)
>>   File "/home/mostwanted/web2py/gluon/packages/dal/pydal/objects.py", line 
>> 726, in insert
>> ret = self._db._adapter.insert(self, self._listify(fields))
>>   File "/home/mostwanted/web2py/gluon/packages/dal/pydal/adapters/base.py", 
>> line 746, in insert
>> raise e
>> IntegrityError: FOREIGN KEY constraint failed
>>
>>
>> Please help me, i dont know what to do, i have tried to look for
>> solutions online but i just dont understand them, may someone please give
>> me light on what i'm doing wrong.
>>
> --
> 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 a topic in the
> Google Groups "web2py-users" group.
> To unsubscribe from this topic, visit https://groups.google.com/d/
> topic/web2py/CPmr9UHWvOA/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to
> web2py+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>



-- 
Santiago Cartasegna.-

-- 
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.


Re: [web2py] Re: FOREIGN KEY constraint failed

2017-07-05 Thread Santiago Cartasegna
That would do the trick.

The backup means thtat before deleteng the files, you backup the folder!

2017-07-05 4:07 GMT-03:00 Dave S <snidely@gmail.com>:

>
>
> On Tuesday, July 4, 2017 at 11:34:11 PM UTC-7, mostwanted wrote:
>>
>> Hey Santi, how do i go about doing that, deleting all the tables in the
>> database backup folder?
>>
>
> The easiest way is to use a command line, and delete the .table files.  In
> a linux system, and picking the application name from the ticket,
>
> cd [web2pydir]/applications/formulator/databases
> rm *.table
>
> For Windows, the same except substitute del for rm.
>
> (the "backup" mentioned may be a nod to a hosting service, where you might
> not manipulate the file system directly..  For instance, for heroku, I
> think you'd actually do a git delete of any dot-table files, but I've only
> done node.js on heroku, so I'm just waving my hands.)
>
> /dps
>
>
>
>> On Tuesday, July 4, 2017 at 12:08:44 AM UTC+2, Santiago Cartasegna wrote:
>>>
>>> Go to the database folder backup and delete all the .tables. Perhaps a
>>> change was not reflected on the creation of the table.
>>>
>>> A similar error ocurred to me and it was on the creation of the id's
>>> references on the forange. But your code looks ok
>>>
>>> El lunes, 3 de julio de 2017, 15:50:45 (UTC-3), mostwanted escribió:
>>>>
>>>> this is the actual code Santi:
>>>>
>>>> db.define_table('government',
>>>> Field('govName', requires=IS_NOT_EMPTY()),
>>>> Field('tel', requires=IS_NOT_EMPTY()),
>>>> Field('email', requires=IS_NOT_EMPTY()),
>>>> format='%(govName)s',  migrate=False,fake_migrate=True)
>>>>
>>>>
>>>> db.define_table(govmntForm',
>>>>
>>>> Field('formImage', 'upload'),
>>>> Field('filledformImage', 'upload'),
>>>> Field('formName',requires=IS_NOT_EMPTY()),
>>>> Field('governmentName', 'reference government'),
>>>> format='%(formName)s',migrate=False,fake_migrate=True)
>>>>
>>>> db.define_table('governmetFormPages',
>>>> Field('formImage', 'upload'),
>>>> Field('formTitle',requires=IS_NOT_EMPTY()),
>>>> Field('formName', 'reference
>>>> govmntForm'),migrate=False,fake_migrate=True)
>>>>
>>>>
>>>> On Monday, July 3, 2017 at 4:51:47 PM UTC+2, Santiago Cartasegna wrote:
>>>>>
>>>>> Hello,
>>>>>
>>>>> You should reference the table with the same name that is created so
>>>>> the table sould be like:
>>>>>
>>>>> db.define_table('governmetFormPages',
>>>>> Field('formImage', 'upload'),
>>>>> Field('formTitle',requires=IS_NOT_EMPTY()),
>>>>> Field('formName', 'reference governmenttForm
>>>>> '),migrate=False,fake_migrate=True)
>>>>>
>>>>> Best regards
>>>>>
>>>>>
>>>>> El lunes, 3 de julio de 2017, 4:15:18 (UTC-3), mostwanted escribió:
>>>>>>
>>>>>> It is the actually code Tony, i just changed it after posting it. The
>>>>>> table name was initially *govmntForm* as it is referenced in the
>>>>>> *governmetFormPages* table.
>>>>>>
>>>>>> On Sunday, July 2, 2017 at 7:48:43 PM UTC+2, Anthony wrote:
>>>>>>>
>>>>>>> Not sure if you're showing your actual code, but the table name is
>>>>>>> spelled "governmenttForm" (note the extra "t"), and for the field type, 
>>>>>>> you
>>>>>>> have "reference govmntForm".
>>>>>>>
>>>>>>> Anthony
>>>>>>>
>>>>>>> On Sunday, July 2, 2017 at 4:37:22 AM UTC-4, mostwanted wrote:
>>>>>>>>
>>>>>>>> Hi guys, i need help, i'm pulling my hairs out over here, i have a
>>>>>>>> website where when i'm trying to record an entry i get an error:
>>>>>>>>  FOREIGN KEY constraint failed
>>>>>>>>
>>>>>>>>
>>>>>>>> I have been able to create 2 forms but other at

[web2py] Re: FOREIGN KEY constraint failed

2017-07-03 Thread Santiago Cartasegna
Go to the database folder backup and delete all the .tables. Perhaps a 
change was not reflected on the creation of the table.

A similar error ocurred to me and it was on the creation of the id's 
references on the forange. But your code looks ok

El lunes, 3 de julio de 2017, 15:50:45 (UTC-3), mostwanted escribió:
>
> this is the actual code Santi:
>
> db.define_table('government',
> Field('govName', requires=IS_NOT_EMPTY()),
> Field('tel', requires=IS_NOT_EMPTY()),
> Field('email', requires=IS_NOT_EMPTY()),
> format='%(govName)s',  migrate=False,fake_migrate=True)
>
>
> db.define_table(govmntForm',
>
> Field('formImage', 'upload'),
> Field('filledformImage', 'upload'),
> Field('formName',requires=IS_NOT_EMPTY()),
> Field('governmentName', 'reference government'), 
> format='%(formName)s',migrate=False,fake_migrate=True)
>
> db.define_table('governmetFormPages',
> Field('formImage', 'upload'),
> Field('formTitle',requires=IS_NOT_EMPTY()), 
> Field('formName', 'reference 
> govmntForm'),migrate=False,fake_migrate=True)
>
>
> On Monday, July 3, 2017 at 4:51:47 PM UTC+2, Santiago Cartasegna wrote:
>>
>> Hello,
>>
>> You should reference the table with the same name that is created so the 
>> table sould be like:
>>
>> db.define_table('governmetFormPages',
>> Field('formImage', 'upload'),
>> Field('formTitle',requires=IS_NOT_EMPTY()), 
>> Field('formName', 'reference governmenttForm
>> '),migrate=False,fake_migrate=True)
>>
>> Best regards
>>
>>
>> El lunes, 3 de julio de 2017, 4:15:18 (UTC-3), mostwanted escribió:
>>>
>>> It is the actually code Tony, i just changed it after posting it. The 
>>> table name was initially *govmntForm* as it is referenced in the 
>>> *governmetFormPages* table.
>>>
>>> On Sunday, July 2, 2017 at 7:48:43 PM UTC+2, Anthony wrote:
>>>>
>>>> Not sure if you're showing your actual code, but the table name is 
>>>> spelled "governmenttForm" (note the extra "t"), and for the field type, 
>>>> you 
>>>> have "reference govmntForm".
>>>>
>>>> Anthony
>>>>
>>>> On Sunday, July 2, 2017 at 4:37:22 AM UTC-4, mostwanted wrote:
>>>>>
>>>>> Hi guys, i need help, i'm pulling my hairs out over here, i have a 
>>>>> website where when i'm trying to record an entry i get an error:
>>>>>  FOREIGN KEY constraint failed
>>>>>
>>>>>
>>>>> I have been able to create 2 forms but other attempts to create more 
>>>>> forms fail!!
>>>>>
>>>>>
>>>>> These are my tables;
>>>>>
>>>>>
>>>>> db.define_table('government',
>>>>> Field('govName', requires=IS_NOT_EMPTY()),
>>>>> Field('tel', requires=IS_NOT_EMPTY()),
>>>>> Field('email', requires=IS_NOT_EMPTY()),
>>>>> format='%(govName)s',  migrate=False,fake_migrate=True)
>>>>>
>>>>>
>>>>> db.define_table('governmenttForm',
>>>>> Field('formImage', 'upload'),
>>>>> Field('filledformImage', 'upload'),
>>>>> Field('formName',requires=IS_NOT_EMPTY()),
>>>>> Field('governmentName', 'reference government'), 
>>>>> format='%(formName)s',migrate=False,fake_migrate=True)
>>>>>
>>>>> db.define_table('governmetFormPages',
>>>>> Field('formImage', 'upload'),
>>>>> Field('formTitle',requires=IS_NOT_EMPTY()), 
>>>>> Field('formName', 'reference 
>>>>> govmntForm'),migrate=False,fake_migrate=True)
>>>>>
>>>>>
>>>>> I am able to create a form for the governmentForm table but when i try 
>>>>> to load up the pages for governmentFormPages table i get the error
>>>>>  FOREIGN KEY constraint failed 
>>>>>
>>>>>
>>>>> Below is the stack
>>>>> Error ticket for "formulator" Ticket ID 
>>>>>
>>>>> 127.0.0.1.2017-07-02.10-06-22.18c363e3-13c2-47f7-ace4-36

[web2py] Re: FOREIGN KEY constraint failed

2017-07-03 Thread Santiago Cartasegna
Hello,

You should reference the table with the same name that is created so the 
table sould be like:

db.define_table('governmetFormPages',
Field('formImage', 'upload'),
Field('formTitle',requires=IS_NOT_EMPTY()), 
Field('formName', 'reference governmenttForm
'),migrate=False,fake_migrate=True)

Best regards


El lunes, 3 de julio de 2017, 4:15:18 (UTC-3), mostwanted escribió:
>
> It is the actually code Tony, i just changed it after posting it. The 
> table name was initially *govmntForm* as it is referenced in the 
> *governmetFormPages* table.
>
> On Sunday, July 2, 2017 at 7:48:43 PM UTC+2, Anthony wrote:
>>
>> Not sure if you're showing your actual code, but the table name is 
>> spelled "governmenttForm" (note the extra "t"), and for the field type, you 
>> have "reference govmntForm".
>>
>> Anthony
>>
>> On Sunday, July 2, 2017 at 4:37:22 AM UTC-4, mostwanted wrote:
>>>
>>> Hi guys, i need help, i'm pulling my hairs out over here, i have a 
>>> website where when i'm trying to record an entry i get an error:
>>>  FOREIGN KEY constraint failed
>>>
>>>
>>> I have been able to create 2 forms but other attempts to create more 
>>> forms fail!!
>>>
>>>
>>> These are my tables;
>>>
>>>
>>> db.define_table('government',
>>> Field('govName', requires=IS_NOT_EMPTY()),
>>> Field('tel', requires=IS_NOT_EMPTY()),
>>> Field('email', requires=IS_NOT_EMPTY()),
>>> format='%(govName)s',  migrate=False,fake_migrate=True)
>>>
>>>
>>> db.define_table('governmenttForm',
>>> Field('formImage', 'upload'),
>>> Field('filledformImage', 'upload'),
>>> Field('formName',requires=IS_NOT_EMPTY()),
>>> Field('governmentName', 'reference government'), 
>>> format='%(formName)s',migrate=False,fake_migrate=True)
>>>
>>> db.define_table('governmetFormPages',
>>> Field('formImage', 'upload'),
>>> Field('formTitle',requires=IS_NOT_EMPTY()), 
>>> Field('formName', 'reference 
>>> govmntForm'),migrate=False,fake_migrate=True)
>>>
>>>
>>> I am able to create a form for the governmentForm table but when i try 
>>> to load up the pages for governmentFormPages table i get the error
>>>  FOREIGN KEY constraint failed 
>>>
>>>
>>> Below is the stack
>>> Error ticket for "formulator" Ticket ID 
>>>
>>> 127.0.0.1.2017-07-02.10-06-22.18c363e3-13c2-47f7-ace4-3692239493c4
>>>  FOREIGN KEY constraint failed Version 
>>> web2py™ Version 2.14.6-stable+timestamp.2016.05.10.00.21.47 Traceback 
>>>
>>> 1.
>>> 2.
>>> 3.
>>> 4.
>>> 5.
>>> 6.
>>> 7.
>>> 8.
>>> 9.
>>> 10.
>>> 11.
>>> 12.
>>> 13.
>>> 14.
>>> 15.
>>> 16.
>>>
>>> Traceback (most recent call last):
>>>   File "/home/mostwanted/web2py/gluon/restricted.py", line 227, in 
>>> restricted
>>> exec ccode in environment
>>>   File 
>>> "/home/mostwanted/web2py/applications/formulator/controllers/appadmin.py" 
>>> ,
>>>  line 703, in 
>>>   File "/home/mostwanted/web2py/gluon/globals.py", line 417, in 
>>> self._caller = lambda f: f()
>>>   File 
>>> "/home/mostwanted/web2py/applications/formulator/controllers/appadmin.py" 
>>> ,
>>>  line 151, in insert
>>> if form.accepts(request.vars, session):
>>>   File "/home/mostwanted/web2py/gluon/sqlhtml.py", line 1746, in accepts
>>> self.vars.id = self.table.insert(**fields)
>>>   File "/home/mostwanted/web2py/gluon/packages/dal/pydal/objects.py", line 
>>> 726, in insert
>>> ret = self._db._adapter.insert(self, self._listify(fields))
>>>   File "/home/mostwanted/web2py/gluon/packages/dal/pydal/adapters/base.py", 
>>> line 746, in insert
>>> raise e
>>> IntegrityError: FOREIGN KEY constraint failed
>>>
>>>
>>> Please help me, i dont know what to do, i have tried to look for 
>>> solutions online but i just dont understand them, may someone please give 
>>> me light on what i'm doing wrong.
>>>
>>

-- 
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.


[web2py] Strange Behavoir sql.factory()

2017-06-02 Thread Santiago Cartasegna
Hello everyone I have modified an SQLFORM.Smartgrid so when i Edit a record 
I only can modify a part of the data.
I need to make some validations, so I added a myValidation to the form (and 
it renders OK). However no validation is made on the form and 
a  response.flash with the "Success!" appears after submit the form.
In the example the error is forced so the form is not submitted

Here is some code so you can see what I am doing:
Controller documento.py
# -*- coding: utf-8 -*-
@auth.requires_login()
def nuevoDocumento():
if 'edit' in request.args:
print request.args
redirect(URL('cambiarArea', 
args=(request.args[3]),vars=dict(documentoID=request.args[3])))
form=SQLFORM.smartgrid(db.t_documentos)
db.t_documentos.f_areaActual.readable=False
db.t_documentos.f_areaActual.value = obtenerArea()
return dict(form=form)

@auth.requires_login()
def cambiarArea():
print request.args
query = (db.t_documentos.id ==request.args[0])
documento = db(query).select().first()
#db.t_documentos.f_areaActual = documento[f_areaActual]
form = SQLFORM.factory(db.t_documentos.f_areaActual)
form.validate(onvalidation=validacionesExtra(form,documento))
print "Nuevo!"
if form.process().accepted:
response.flash = 'form accepted'
elif form.errors:
response.flash = 'form has errors'
#print documento.f_areaActual
return dict(message="hello from 
documento/cambiarArea.py",documento=documento,form=form)

def obtenerArea():
groups = db((db.auth_membership.user_id==auth.user.id)& 
(db.auth_membership.group_id==db.auth_group.id)).select(db.auth_group.role)
for area in groups:
if area in ["mesa", "juridico", "titulos"]:
areaUsuario = area
break
query = (db.t_areas.f_nombre == area.role)
idArea = db.t_areas.id
ape = db(query).select(idArea).first()[idArea]
return (ape)

def validacionesExtra(form,documento):
form.errors.f_areaActual = 'El area Origen y Destino deben ser 
distintas'

View cambiarArea.html
{{extend 'layout.html'}}
This is the documento/cambiarArea.html template
{{=BEAUTIFY(response._vars)}}

Here is some log that tells me that the form is getting done:

Area 
Actualjuridicomesatitulos

If you need more data, please let me know

-- 
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.


[web2py] which is the correct way to add validations to SQLFORM.factory?

2017-05-17 Thread Santiago Cartasegna
I am creating a form using SQLFORM.factory and I have diferent problems:

1 - I can't make "invisible" some values (that i Autofill later)

2- I can't add extraValidations to the Form (as I do when a create a 
sqlsmartgrid form).

I use SQLFORM because I use the ID of the inserted row to make an insert in 
another table.

Here is some code to show what i am doing:


*MODEL*

















































*###db.define_table('t_areas',
Field('f_nombre', type='string',  label=T('Nombre')),
auth.signature,format='%(f_nombre)s',
migrate=settings.migrate)db.define_table('t_areas_archive',db.t_areas,Field('current_record','reference
 
t_areas',readable=False,writable=False))db.define_table('t_documentos',
  
  Field('f_fechaingreso', type='date',  label=T('Ingreso')),
Field('f_recibe', type='reference auth_user',  label=T('Recibe')),  
  Field('f_comentarios_multiline', type='text',  
label=T('Comentarios')),Field('f_areaActual', type='reference 
t_areas',  label=T('Area Actual')),Field('f_areaDestino', 
type='reference t_areas',  label=T('Area Destino')),
auth.signature,format='%(f_fechaingreso)s',
migrate=settings.migrate)db.define_table('t_documentos_archive',db.t_documentos,Field('current_record','reference
 
t_documentos',readable=False,writable=False))db.define_table('t_movimientos',
  
  Field('f_areaOrigen', type='reference t_areas',  
label=T('Area')),Field('f_areaDestino', type='reference t_areas',  
label=T('Destino')),Field('f_documento', type='reference 
t_documentos',  label=T('Documento')),Field('f_comentarios', 
type='text',  label=T('Comentarios')),Field('f_fecha', 
type='date',  label=T('Fecha'),default=request.now, 
writable=False),auth.signature,format='%(f_area)s',
migrate=settings.migrate)db.define_table('t_movimientos_archive',db.t_movimientos,Field('current_record','reference
 
t_movimientos',readable=False,writable=False))Controller*








































* -*- coding: utf-8 -*-@auth.requires_login()def nuevoDocumento():
form=SQLFORM.factory(db.t_documentos)
db.t_documentos.f_areaActual.readable=Falseif 
form.process(onvalidation=validacionesExtra).accepted:idAreaOrigen 
= obtenerArea()print("idAreaOrigen %s" %(idAreaOrigen))
form.vars.f_areaOrigen = idAreaOrigenid = 
db.t_documentos.insert(**db.t_documentos._filter_fields(form.vars))
print(form.vars)idDocumento=ididAreaDestino= 
form.vars.f_areaDestinoidAreaOrigen= form.vars.f_areaOrigen
comentario =  form.vars.f_comentarios_multilineid = 
db.t_movimientos.insert(f_areaOrigen=idAreaOrigen,f_documento=id,f_areaDestino=idAreaDestino,f_comentarios=comentario)
  
  response.flash='Thanks for filling the form'return 
dict(form=form)def obtenerArea():groups = 
db((db.auth_membership.user_id==auth.user.id)& 
(db.auth_membership.group_id==db.auth_group.id)).select(db.auth_group.role)  
  for area in groups:if area in ["mesa", "juridico", "titulos"]:
areaUsuario = areabreakprint (area)print 
area.rolequery = (db.t_areas.f_nombre == area.role)idArea = 
db.t_areas.idape = db(query).select(idArea).first()[idArea]return 
(ape)def validacionesExtra(form):print("VALIDACIONES")if 
(form.vars.f_areaOrigen == form.vars.f_areaDestino):response.flash 
= 'El area Origen y Destino deben ser distintas'
form.errors.f_areaOrigen = 'El area Origen y Destino deben ser distintas'*One 
thing, I been looking at 
db.mytable._after_insert
db.mytable._after_update

should be the validations part of the table definition on the model?

PS: sorry for the multiple prints on the code.

-- 
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.


[web2py] Re: Make an inster/update in a second table after inserting/update

2017-05-16 Thread Santiago Cartasegna
Thanks for the answer.


There is a way to use the facilities of the SmartGrid, and catch the 
insert? I am able to make a workaround using the One-Form-Multiple-Tables 
stile but using the data of the form of one table making a new Insert with 
the data (I see I am on the right course reading the Link Anthony gave me). 

However this 
db.mytable._after_insert
db.mytable._after_update

should be part of the table definition on the model?

Thanks in advance!

El martes, 16 de mayo de 2017, 14:38:35 (UTC-3), Anthony escribió:
>
> When you do an insert, the .insert() method returns the id of the inserted 
> record. Also, take a look at 
> http://web2py.com/books/default/chapter/29/06/the-database-abstraction-layer#callbacks-on-record-insert--delete-and-update.
>
> Anthony
>
> On Tuesday, May 16, 2017 at 1:08:59 PM UTC-4, Santiago Cartasegna wrote:
>>
>> Hello,
>>
>> I am having a struggle in doing the following workflow:
>>
>> I have One table wich I need to get the values after insert/Update (I 
>> know how to manage this case) to put in another table.
>> In the case of the update, I can make a workaround besacuse I can catch 
>> the edit. But when I have a New Record I do not have the ID.
>>
>> I been looking in 
>> http://web2py.com/books/default/chapter/29/7#One-form-for-multiple-tables 
>> but I do not think that this is what i need.
>>
>> Best 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.


[web2py] Make an inster/update in a second table after inserting/update

2017-05-16 Thread Santiago Cartasegna
Hello,

I am having a struggle in doing the following workflow:

I have One table wich I need to get the values after insert/Update (I know 
how to manage this case) to put in another table.
In the case of the update, I can make a workaround besacuse I can catch the 
edit. But when I have a New Record I do not have the ID.

I been looking 
in http://web2py.com/books/default/chapter/29/7#One-form-for-multiple-tables 
but I do not think that this is what i need.

Best 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.


Re: [web2py] Hide the achive links for a table.

2017-04-28 Thread Santiago Cartasegna
linked_tables=[] would do the trick.

Thanks! 

-- 
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.


[web2py] Hide the achive links for a table.

2017-04-28 Thread Santiago Cartasegna



Hello everyone,

I am using a Smartgrid to display some data. I was wondering if there is 
any chanche of hidding the links that redirect to the archive records.
Is there any easy way of doing this?



Thanks in advace!

-- 
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.


[web2py] Re: Smartrgrid verify old value on record before update

2017-03-26 Thread Santiago Cartasegna
I wasn't sure how to obtaien the value of the Row Id which was being 
modified!

Thanks for your answer


El lunes, 20 de marzo de 2017, 13:27:07 (UTC-3), Anthony escribió:
>
>
> def is_bigger(form):
>> idUpdate = request.args(3).first
>>
>
> What is .first supposed to do?
>  
>
>> r = db(db.t_myTable.f_quantity==idUpdate.id).select()
>>
>
> The above returns a Rows object -- you need to extract the Row from it -- 
> so, use .select().first().
>
> Anthony
>

-- 
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.


[web2py] Re: Smartrgrid verify old value on record before update

2017-03-20 Thread Santiago Cartasegna
I have made a workarround.

if (request.args[1] == 'edit'):
#obtenemos el id del campo a modificar
idUpdate = request.args[3]


El lunes, 20 de marzo de 2017, 10:40:23 (UTC-3), Santiago Cartasegna 
escribió:
>
> Hello,
>
> I am trying to do some validation before updating a record. My idea is to 
> verify that the new value of a field is bigger than the old one.
>
> However I am not getting how to do it:
>
>
> table definition:
>
>
> db.define_table('t_myTable',
> Field('f_year', type='integer',
>   label=T('Año')),
> Field('f_quantity', type='integer',
>   label=T('cantidad')),
> Field('f_user', type='reference auth_user',
>   label=T('Cargo'),default=auth.user_id,writable=False),
> auth.signature,
> format='%(f_year)s',
> migrate=settings.migrate)
>
>
> On my controller:
>
>
> # -*- coding: utf-8 -*-
> @auth.requires_login()
> def viewTable():
> form = SQLFORM.smartgrid(db.t_myTable,onupdate=auth.archive,deletable=
> False,csv=False,details=False,searchable=False
> ,onvalidation=is_bigger)
> return locals()
>
>
> def is_bigger(form):
> idUpdate = request.args(3).first
> r = db(db.t_myTable.f_quantity==idUpdate.id).select()
> if r.f_quantity < form.vars.f_quantity:
> form.errors.f_quantity = 'Some error message ' % (r.f_quantity)
>
>
> I am not getting the way of get the OLD row value before update
>

-- 
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.


[web2py] Re: problem with ldap authentication

2017-03-20 Thread Santiago Cartasegna
Have you tried to check conectivity between servers without Web2py in the 
middle? 

For example, try to do a ldapsearch to see if it works.




El martes, 7 de marzo de 2017, 12:32:42 (UTC-3), Carlos Cesar Caballero 
escribió:
>
> Hi, I am trying to include ldap authentication to my app, and for this, i 
> am using this code:
>
> auth.settings.login_methods.append(ldap_auth(
> mode='uid',
> server='10.6.xx.xx',
> base_dn='dc=comp',
> filterstr='&(objectClass=inetOrgPerson)',
> logging_level='debug'))
>
> (note: The Original server and base_dn values are changed in this example. 
> I also have tried with and without the filterstr option)
>
> But I can't login with any ldap user, and the logs only say:
>
> DEBUG:web2py.auth.ldap_auth:mode: [uid] manage_user: [False] custom_scope: 
> [subtree] manage_groups: [False]
> INFO:web2py.auth.ldap_auth:[10.6.28.93] Initialize ldap connection
>
> I Debug the ladp_auth module, and for some reason it hangs on the line 314 
> ( con.simple_bind_s(dn, password)) without throw any error.
>
> If it helps, I also have tried this code and works as expected returning 
> the ldap user data:
>
> import ldap
> ldap_server="10.6.xx.xx"
> username = "auser"
> base_dn = "dc=comp"
>
> query = "(uid=%s)" % username
> con = ldap.initialize('ldap://'+ldap_server)
>
> result = con.search_s(base_dn, ldap.SCOPE_SUBTREE, query)
> print result
>
>
> Any help or idea?
>
> Greetings.
>
>
>

-- 
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.


[web2py] Smartrgrid verify old value on record before update

2017-03-20 Thread Santiago Cartasegna
Hello,

I am trying to do some validation before updating a record. My idea is to 
verify that the new value of a field is bigger than the old one.

However I am not getting how to do it:


table definition:


db.define_table('t_myTable',
Field('f_year', type='integer',
  label=T('Año')),
Field('f_quantity', type='integer',
  label=T('cantidad')),
Field('f_user', type='reference auth_user',
  label=T('Cargo'),default=auth.user_id,writable=False),
auth.signature,
format='%(f_year)s',
migrate=settings.migrate)


On my controller:


# -*- coding: utf-8 -*-
@auth.requires_login()
def viewTable():
form = SQLFORM.smartgrid(db.t_myTable,onupdate=auth.archive,deletable=
False,csv=False,details=False,searchable=False
,onvalidation=is_bigger)
return locals()


def is_bigger(form):
idUpdate = request.args(3).first
r = db(db.t_myTable.f_quantity==idUpdate.id).select()
if r.f_quantity < form.vars.f_quantity:
form.errors.f_quantity = 'Some error message ' % (r.f_quantity)


I am not getting the way of get the OLD row value before update

-- 
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.


[web2py] Re: 'Column table.id not found (SQLTABLE)'

2017-03-20 Thread Santiago Cartasegna
Are you trying to use a table that you have defined in your database and 
not in web2py? 
If it is the case you must add an id field with autoincremental

El domingo, 12 de marzo de 2017, 20:27:08 (UTC-3), LoveWeb2py escribió:
>
> Keep getting this error for all of my tables!! What is going on?
>
> What information would be helpful for me to post to get help?
>

-- 
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.