[web2py] Re: IntegrityError('FOREIGN KEY constraint failed',)

2017-10-25 Thread sesenmaister
Hi, your shown code is incomplete. It seems you are doing an insert or 
update to the db.

This "FOREIGN KEY constriaint failed" is meaning that in one of your 
referenced fields [db.student.guardian, db.student.class_name] you tried to 
reference a registry that doesn't exist on the parent tables [db.guardian, 
db.class_name]

As an example, *db.student.insert(db.guardian=2)* will raise this error if 
*db.guardian(2)==None*  (doesn't exist).




On Wednesday, October 25, 2017 at 9:55:28 AM UTC+2, mostwanted wrote:
>
>
>
> *WHEN I TRY ENTERING A STUDENT'S DETAILS AND SELECTING THEIR GUARDIAN AS 
> FROM THE DROP DOWN MENU AS REFERNCED I GET A FOREIGN CONSTRAINT FAILED 
> ERROR MESSAGEMY TABLES*
>
> db.define_table('guardian',
> Field('surname', requires=IS_NOT_EMPTY()),
> Field('name', requires=IS_NOT_EMPTY()),
> Field('contact_number'),
> format='%(surname)s')
> 
> db.define_table('student',
> Field('surname', requires=IS_NOT_EMPTY()),
> Field('name', requires=IS_NOT_EMPTY()),
> Field('photo', 'upload', requires=IS_NOT_EMPTY()),
> Field('guardian', 'reference guardian'),
> Field('class_name', 'reference student_class'),
> Field('dob', 'date', requires=IS_NOT_EMPTY()),
> format='%(surname)s')
>
> *MY CONTROLLER*
>
> def show_students():
> show_students=db(db.student).select(db.student.ALL)
> return locals()
>
>
>
> *MY VIEW*
> SELECT A STUDENT TO VIEW THEIR PROFILE
> 
> 
> SURNAME
> NAME
> CLASS
> GUARDIAN
> 
> {{for students in show_students:}}
> 
> {{=A('VIEW', _class="glyphicon glyphicon-user", 
> _href=URL('student_profile', args=students.id))}} | 
>  {{=students.surname}}
> {{=students.name}}
> {{=students.class_name.class_name}}
> {{=students.guardian.guardian}}
> 
> {{pass}}
> 
> 
>
>
> *MY TRACEBACK ERROR*
>  FOREIGN KEY constraint failed 
>
>
>
> Traceback (most recent call last):
>   File "/home/mostwanted/web2py/gluon/restricted.py", line 219, in restricted
> exec(ccode, environment)
>   File "/home/mostwanted/web2py/applications/SRMS/controllers/appadmin.py" 
> , line 
> 696, in 
>   File "/home/mostwanted/web2py/gluon/globals.py", line 409, in 
> self._caller = lambda f: f()
>   File "/home/mostwanted/web2py/applications/SRMS/controllers/appadmin.py" 
> , line 
> 147, in insert
> if form.accepts(request.vars, session):
>   File "/home/mostwanted/web2py/gluon/sqlhtml.py", line 1862, in accepts
> self.vars.id = self.table.insert(**fields)
>   File "/home/mostwanted/web2py/gluon/packages/dal/pydal/objects.py", line 
> 734, in insert
> ret = self._db._adapter.insert(self, row.op_values())
>   File "/home/mostwanted/web2py/gluon/packages/dal/pydal/adapters/base.py", 
> line 486, in insert
> raise e
> IntegrityError: FOREIGN KEY constraint failed
>
> Error snapshot [image: help] 
> 
>  
>
> (FOREIGN KEY constraint failed) 
>
> inspect attributes 
> Frames 
>
>- 
>
>*File /home/mostwanted/web2py/gluon/restricted.py in restricted at 
>line 219* code arguments variables 
>- 
>
>*File 
>/home/mostwanted/web2py/applications/SRMS/controllers/appadmin.py in 
> at line 696* code arguments variables 
>- 
>
>*File /home/mostwanted/web2py/gluon/globals.py in  at line 409* 
>code arguments variables 
>- 
>
>*File 
>/home/mostwanted/web2py/applications/SRMS/controllers/appadmin.py in 
> insert 
>at line 147* code arguments variables 
>- 
>
>*File /home/mostwanted/web2py/gluon/sqlhtml.py in accepts at line 1862* 
>code arguments variables 
>- 
>
>*File /home/mostwanted/web2py/gluon/packages/dal/pydal/objects.py in 
>insert at line 734* code arguments variables 
>- 
>
>*File 
>/home/mostwanted/web2py/gluon/packages/dal/pydal/adapters/base.py in 
> insert 
>at line 486* code arguments variables 
>Function argument list 
>
>(self=, table=surname, name, photo, guardian, class_name, dob)>, 
>fields=[(, 'Leburu'), (object>, 'Percy'), (, '2010-10-05'), 
>(, 5), (, 21), 
>(, 
>'student.photo.a21f46af61cba907.706963322e6a7067.jpg')])
>Code listing 
>
>481.
>482.
>483.
>484.
>485.
>486.
>
>487.
>488.
>489.
>490.
>
>self.execute(query)
>except:
>e = sys.exc_info()[1]
>if hasattr(table, '_on_insert_error'):
>return table._on_insert_error(table, fields, e)
>raise e
>

[web2py] How to get the last few records except the last record

2017-10-25 Thread Maurice Waka
If using the code: limitby=(0,10) am able to get the last 10 records,  Is 
there a way to get the same(last few records) except the very last 
record(last record posted to the db) from the db.
 I have tried:
records  = db(db.post.author == auth.user_id).select(orderby=(db.post.ALL, 
limitby=(0,-9))...getting a blank screen instead
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] Re: do LOAD statements work in layout.html?

2017-10-25 Thread Dave S


On Wednesday, October 25, 2017 at 3:55:13 PM UTC-7, Dave S wrote:
>
> Last night, I thought I had it working.  Today it doesn't seem  to be.
>
> (I wanted to have a blurb on the page, and also be able to show the blurb 
> as an specific page).
>
> The specific page still works, using blurb.html, but the blurb doesn't 
> show on other pages with blurb.load.  I don't even see blurb.load being 
> requested in httpserver.log, which it did last night.   One obvious thought 
> is javascript blocking, but I've got my site whitelisted in noscript, and 
> the Chrome browser is also not showing it.
>
>
The "share tray" -- or social-drawer div -- slides in and out ok, although 
I'm not sure if that's js or just css.
 

> There are other ways to handle this, but what the heck happened?
>
>  
/dps

-- 
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] do LOAD statements work in layout.html?

2017-10-25 Thread Dave S
Last night, I thought I had it working.  Today it doesn't seem  to be.

(I wanted to have a blurb on the page, and also be able to show the blurb 
as an specific page).

The specific page still works, using blurb.html, but the blurb doesn't show 
on other pages with blurb.load.  I don't even see blurb.load being 
requested in httpserver.log, which it did last night.   One obvious thought 
is javascript blocking, but I've got my site whitelisted in noscript, and 
the Chrome browser is also not showing it.

There are other ways to handle this, but what the heck happened?

/dps

-- 
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: sistemExit during scheduler execution

2017-10-25 Thread Manuele Pesenti
Il 25/10/17 08:56, Dave S ha scritto:
> Line 166 is the error handler after a try: run_models_in() .  Anything
> unusual about the models for this app?
> Do you see an exception printed (on the console -- sys.stderr is used)
> with the stack trace?
>
> /dps

Thank you Dave for your answare. I'm still looking for the cause of this
problem but I think it could be related to the trouble I got with the
database max number connections (look the thread "[...] too many db
connections to db [...]" for details).

Best regards

    Manuele

-- 
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: New syntax error?

2017-10-25 Thread Dave S


On Wednesday, October 25, 2017 at 6:03:10 AM UTC-7, Anthony wrote:
>
> I cannot reproduce, and I can't think of anything web2py would be doing 
> that would be relevant, as this is a standard Python exception. I was 
> thinking maybe you switched to Python 3, but in that case, I would expect a 
> more specific error message indicating the parentheses are missing (unless 
> you're using an older version of Python 3 and the message is different in 
> that version).
>
> Anthony
>

Python 2.7.12 on AWS linux.

I have both flavors of web2py (that is, good ol' 2.14.6 and the 
up-and-coming 2.15.4) on the same machine (VM/cloud instance), using 
different ports.  The application code was copied via tar from 2.14.6 to 
2.15.4.

The web2py signon (version info) doesn't show the python version, but 
"python" defaults to 2.7.12.

BTW, I see the logger statement are coming out on the console, rather than 
going to the log file, but that was because I needed to fix the permissions 
on the log file.

/dps


> On Monday, October 23, 2017 at 6:38:27 PM UTC-4, Dave S wrote:
>>
>> In  my 2.15.x testing, I've been concentrating on the https interface, 
>> but I now tried to do a -M -S that would queue up a Scheduler task.  And I 
>> ran into an unexpected problem with syntax errors on print statements.
>>
>>if when:
>>   print "ri_s: when " + when
>>
>> Even when I shorten the line to remove the concatenation, I get a syntax 
>> error:
>>
>> Traceback (most recent call last):
>>   File "web2py.py", line 33, in 
>> gluon.widget.start(cron=True)
>>   File "/home/ec2-user/web2py/web2py-2.15.4/web2py/gluon/widget.py", 
>> line 1152, in start
>> cronjob=options.cronjob)
>>   File "/home/ec2-user/web2py/web2py-2.15.4/web2py/gluon/shell.py", line 
>> 258, in run
>> execfile(pyfile, _env)
>>   File "applications/updater/controllers/default.py", line 140
>> print "ri_s: when "
>>   ^
>> SyntaxError: invalid syntax
>>
>> I tried changing the variable name to "pwhen" in case this was an 
>> if-statement/keyword issue, but still "invalid syntax".
>>
>> As you might guess, default.py loads fine for https requests, and this 
>> code loads fine with -S under 2.14.6, so I'm not sure what's going on here.
>>
>> /dps
>>
>>
>>

-- 
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: limiting the SSL max fragment size on development server (Rocket)

2017-10-25 Thread Dave S


On Wednesday, October 25, 2017 at 6:18:08 AM UTC-7, icodk wrote:
>
> Some small IoT units can't  afford the standard 16K fragment size required 
> by default for SSl negotiation.
> On some servers it is possible to set such limit, ex 
> nginx: ssl_buffer_size 4k;
>
> Is it possible to do the same on web2py development server ? 
>

A quick look at rocket.py doesn't make it obvious how to do it.  I don't 
know if the ssl.wrap_socket() call has optional parameters for this; if it 
does, it's not obvious [to me] in the Python docs at 17.3.

/dps




-- 
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] Make a form and edit multiple rows in web2py

2017-10-25 Thread Dave S


On Wednesday, October 25, 2017 at 7:01:33 AM UTC-7, Richard wrote:
>
> Use sqlform.factory and custom.form and web2py helpers and you create an 
> html table with you fields into... with sqlform.factory you can use 
> field().clone() method to manager field attributes like requires and you 
> will have to manually insert, update you model and db.commit() since 
> facotry doesn't commit and manage that for you...
>
> Richard
>

I thought you'd be recommending SQLFORM.grid.

has examples.

/dps
 

>
> On Mon, Oct 23, 2017 at 10:11 PM, Joilson Quinteiro  > wrote:
>
>
>> Hi all,
>>
>> Anyone can help me this question? ?  
>>
>> its very importante to me.
>>
>> Give me one example please.
>>
>>

-- 
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: MySQL, self-reference, and null values

2017-10-25 Thread Dave S


On Wednesday, October 25, 2017 at 9:54:08 AM UTC-7, Oasis Agano wrote:
>
> Has this issue been solved still facing it after 4 years on mysql
>
>
Dunno.  In the current tracking system, I'd expect the imported issue to 
show up on this page:
https://github.com/web2py/web2py/issues?page=25=is%3Aissue=%E2%9C%93>
but I don't see it there (disclaimer: quick check) as either still open or 
closed-in-github.
Clicking the link below redirects to the github #1342, which is unrelated 
(and from 2016).

/dps


I don't know where the lo

> On Monday, February 18, 2013 at 12:28:45 PM UTC+2, Loïc wrote:
>>
>> Done
>> http://code.google.com/p/web2py/issues/detail?id=1342
>> Thanks
>>
>> Le lundi 11 février 2013 00:40:59 UTC+1, Massimo Di Pierro a écrit :
>>>
>>> Can you please open a ticket so the issue is tracked?
>>>
>>> On Friday, 1 February 2013 09:20:54 UTC-6, Loïc wrote:

 Dear All,

 I have a 'page' model with a sef-reference: 
 db.define_table('page',
 Field('parent', 'reference page', readable=False, writable=False),
 Field('title', unique=True, notnull=True)
 //more fields not important here
 )

 When I insert a new page via appadmin without specifying a 'parent', 
 everything is OK with sqlite

 Since I moved my database to mysql, I have an error : 
  (1452, 'Cannot add or update 
 a child row: a foreign key constraint fails (`dommartin25`.`page`, 
 CONSTRAINT `page_ibfk_1` FOREIGN KEY (`parent`) REFERENCES `page` (`id`) 
 ON 
 DELETE CASCADE)')
 How can I allow null values for the 'parent' field?

 Thank you

>>>
>

-- 
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] Make a form and edit multiple rows in web2py

2017-10-25 Thread Richard Vézina
Use sqlform.factory and custom.form and web2py helpers and you create an
html table with you fields into... with sqlform.factory you can use
field().clone() method to manager field attributes like requires and you
will have to manually insert, update you model and db.commit() since
facotry doesn't commit and manage that for you...

Richard

On Mon, Oct 23, 2017 at 10:11 PM, Joilson Quinteiro 
wrote:

>
> Hi all,
>
> Anyone can help me this question? ?
>
> its very importante to me.
>
> Give me one example please.
>
> --
> 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.
>

-- 
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] limiting the SSL max fragment size on development server (Rocket)

2017-10-25 Thread icodk
Some small IoT units can't  afford the standard 16K fragment size required 
by default for SSl negotiation.
On some servers it is possible to set such limit, ex nginx: ssl_buffer_size 
4k;

Is it possible to do the same on web2py development server ? 

-- 
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 a form and edit multiple rows in web2py

2017-10-25 Thread Joilson Quinteiro

Hi all,

Anyone can help me this question? ?  

its very importante to me.

Give me one example please.

-- 
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: New syntax error?

2017-10-25 Thread Anthony
I cannot reproduce, and I can't think of anything web2py would be doing 
that would be relevant, as this is a standard Python exception. I was 
thinking maybe you switched to Python 3, but in that case, I would expect a 
more specific error message indicating the parentheses are missing (unless 
you're using an older version of Python 3 and the message is different in 
that version).

Anthony

On Monday, October 23, 2017 at 6:38:27 PM UTC-4, Dave S wrote:
>
> In  my 2.15.x testing, I've been concentrating on the https interface, but 
> I now tried to do a -M -S that would queue up a Scheduler task.  And I ran 
> into an unexpected problem with syntax errors on print statements.
>
>if when:
>   print "ri_s: when " + when
>
> Even when I shorten the line to remove the concatenation, I get a syntax 
> error:
>
> Traceback (most recent call last):
>   File "web2py.py", line 33, in 
> gluon.widget.start(cron=True)
>   File "/home/ec2-user/web2py/web2py-2.15.4/web2py/gluon/widget.py", line 
> 1152, in start
> cronjob=options.cronjob)
>   File "/home/ec2-user/web2py/web2py-2.15.4/web2py/gluon/shell.py", line 
> 258, in run
> execfile(pyfile, _env)
>   File "applications/updater/controllers/default.py", line 140
> print "ri_s: when "
>   ^
> SyntaxError: invalid syntax
>
> I tried changing the variable name to "pwhen" in case this was an 
> if-statement/keyword issue, but still "invalid syntax".
>
> As you might guess, default.py loads fine for https requests, and this 
> code loads fine with -S under 2.14.6, so I'm not sure what's going on here.
>
> /dps
>
>
>

-- 
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: IntegrityError('FOREIGN KEY constraint failed',)

2017-10-25 Thread mostwanted




*OK I JUMPED THE GUN & GOT TOO EXCITED WAAAY TO EARLY! I'M STILL FACED WITH 
THE SAME PROBLEM, I MADE ONE ENTRY WHEN TRYING TO MAKE ANOTHER THE SAME 
PROBLEM CROPS UP FOREIGN KEY constraint 
failedI'M SERIOUSLY LOST COZ I THOUGHT I NAILED IT! PLEASE HELP ME!!!*
On Wednesday, October 25, 2017 at 9:55:28 AM UTC+2, mostwanted wrote:
>
>
>
> *WHEN I TRY ENTERING A STUDENT'S DETAILS AND SELECTING THEIR GUARDIAN AS 
> FROM THE DROP DOWN MENU AS REFERNCED I GET A FOREIGN CONSTRAINT FAILED 
> ERROR MESSAGEMY TABLES*
>
> db.define_table('guardian',
> Field('surname', requires=IS_NOT_EMPTY()),
> Field('name', requires=IS_NOT_EMPTY()),
> Field('contact_number'),
> format='%(surname)s')
> 
> db.define_table('student',
> Field('surname', requires=IS_NOT_EMPTY()),
> Field('name', requires=IS_NOT_EMPTY()),
> Field('photo', 'upload', requires=IS_NOT_EMPTY()),
> Field('guardian', 'reference guardian'),
> Field('class_name', 'reference student_class'),
> Field('dob', 'date', requires=IS_NOT_EMPTY()),
> format='%(surname)s')
>
> *MY CONTROLLER*
>
> def show_students():
> show_students=db(db.student).select(db.student.ALL)
> return locals()
>
>
>
> *MY VIEW*
> SELECT A STUDENT TO VIEW THEIR PROFILE
> 
> 
> SURNAME
> NAME
> CLASS
> GUARDIAN
> 
> {{for students in show_students:}}
> 
> {{=A('VIEW', _class="glyphicon glyphicon-user", 
> _href=URL('student_profile', args=students.id))}} | 
>  {{=students.surname}}
> {{=students.name}}
> {{=students.class_name.class_name}}
> {{=students.guardian.guardian}}
> 
> {{pass}}
> 
> 
>
>
> *MY TRACEBACK ERROR*
>  FOREIGN KEY constraint failed 
>
>
>
> Traceback (most recent call last):
>   File "/home/mostwanted/web2py/gluon/restricted.py", line 219, in restricted
> exec(ccode, environment)
>   File "/home/mostwanted/web2py/applications/SRMS/controllers/appadmin.py" 
> , line 
> 696, in 
>   File "/home/mostwanted/web2py/gluon/globals.py", line 409, in 
> self._caller = lambda f: f()
>   File "/home/mostwanted/web2py/applications/SRMS/controllers/appadmin.py" 
> , line 
> 147, in insert
> if form.accepts(request.vars, session):
>   File "/home/mostwanted/web2py/gluon/sqlhtml.py", line 1862, in accepts
> self.vars.id = self.table.insert(**fields)
>   File "/home/mostwanted/web2py/gluon/packages/dal/pydal/objects.py", line 
> 734, in insert
> ret = self._db._adapter.insert(self, row.op_values())
>   File "/home/mostwanted/web2py/gluon/packages/dal/pydal/adapters/base.py", 
> line 486, in insert
> raise e
> IntegrityError: FOREIGN KEY constraint failed
>
> Error snapshot [image: help] 
> 
>  
>
> (FOREIGN KEY constraint failed) 
>
> inspect attributes 
> Frames 
>
>- 
>
>*File /home/mostwanted/web2py/gluon/restricted.py in restricted at 
>line 219* code arguments variables 
>- 
>
>*File 
>/home/mostwanted/web2py/applications/SRMS/controllers/appadmin.py in 
> at line 696* code arguments variables 
>- 
>
>*File /home/mostwanted/web2py/gluon/globals.py in  at line 409* 
>code arguments variables 
>- 
>
>*File 
>/home/mostwanted/web2py/applications/SRMS/controllers/appadmin.py in 
> insert 
>at line 147* code arguments variables 
>- 
>
>*File /home/mostwanted/web2py/gluon/sqlhtml.py in accepts at line 1862* 
>code arguments variables 
>- 
>
>*File /home/mostwanted/web2py/gluon/packages/dal/pydal/objects.py in 
>insert at line 734* code arguments variables 
>- 
>
>*File 
>/home/mostwanted/web2py/gluon/packages/dal/pydal/adapters/base.py in 
> insert 
>at line 486* code arguments variables 
>Function argument list 
>
>(self=, table=surname, name, photo, guardian, class_name, dob)>, 
>fields=[(, 'Leburu'), (object>, 'Percy'), (, '2010-10-05'), 
>(, 5), (, 21), 
>(, 
>'student.photo.a21f46af61cba907.706963322e6a7067.jpg')])
>Code listing 
>
>481.
>482.
>483.
>484.
>485.
>486.
>
>487.
>488.
>489.
>490.
>
>self.execute(query)
>except:
>e = sys.exc_info()[1]
>if hasattr(table, '_on_insert_error'):
>return table._on_insert_error(table, fields, e)
>raise e
>
>if hasattr(table, '_primarykey'):
>pkdict = dict([
>(k[0].name, k[1]) for k in fields
>if k[0].name in 

[web2py] Re: IntegrityError('FOREIGN KEY constraint failed',)

2017-10-25 Thread mostwanted


*PLEASE ALLOW ME TO RECTIFY MYSELF, LOOKING AT THE SCREEN 6HRS STRAIGHT IS 
NOT HEALTHY, ONE ENDS UP MAKING REALLY STUPID MISTAKES AND CALLING ON 
EVERYONE TO ASSIST THEM! LIKE I DIDthis is wrong!!*




*{{=students.guardian.guardian}}this must 
be{{=students.guardian.surname}} thanks for allowing me to figure 
this one out*

On Wednesday, October 25, 2017 at 9:55:28 AM UTC+2, mostwanted wrote:
>
>
>
> *WHEN I TRY ENTERING A STUDENT'S DETAILS AND SELECTING THEIR GUARDIAN AS 
> FROM THE DROP DOWN MENU AS REFERNCED I GET A FOREIGN CONSTRAINT FAILED 
> ERROR MESSAGEMY TABLES*
>
> db.define_table('guardian',
> Field('surname', requires=IS_NOT_EMPTY()),
> Field('name', requires=IS_NOT_EMPTY()),
> Field('contact_number'),
> format='%(surname)s')
> 
> db.define_table('student',
> Field('surname', requires=IS_NOT_EMPTY()),
> Field('name', requires=IS_NOT_EMPTY()),
> Field('photo', 'upload', requires=IS_NOT_EMPTY()),
> Field('guardian', 'reference guardian'),
> Field('class_name', 'reference student_class'),
> Field('dob', 'date', requires=IS_NOT_EMPTY()),
> format='%(surname)s')
>
> *MY CONTROLLER*
>
> def show_students():
> show_students=db(db.student).select(db.student.ALL)
> return locals()
>
>
>
> *MY VIEW*
> SELECT A STUDENT TO VIEW THEIR PROFILE
> 
> 
> SURNAME
> NAME
> CLASS
> GUARDIAN
> 
> {{for students in show_students:}}
> 
> {{=A('VIEW', _class="glyphicon glyphicon-user", 
> _href=URL('student_profile', args=students.id))}} | 
>  {{=students.surname}}
> {{=students.name}}
> {{=students.class_name.class_name}}
> {{=students.guardian.guardian}}
> 
> {{pass}}
> 
> 
>
>
> *MY TRACEBACK ERROR*
>  FOREIGN KEY constraint failed 
>
>
>
> Traceback (most recent call last):
>   File "/home/mostwanted/web2py/gluon/restricted.py", line 219, in restricted
> exec(ccode, environment)
>   File "/home/mostwanted/web2py/applications/SRMS/controllers/appadmin.py" 
> , line 
> 696, in 
>   File "/home/mostwanted/web2py/gluon/globals.py", line 409, in 
> self._caller = lambda f: f()
>   File "/home/mostwanted/web2py/applications/SRMS/controllers/appadmin.py" 
> , line 
> 147, in insert
> if form.accepts(request.vars, session):
>   File "/home/mostwanted/web2py/gluon/sqlhtml.py", line 1862, in accepts
> self.vars.id = self.table.insert(**fields)
>   File "/home/mostwanted/web2py/gluon/packages/dal/pydal/objects.py", line 
> 734, in insert
> ret = self._db._adapter.insert(self, row.op_values())
>   File "/home/mostwanted/web2py/gluon/packages/dal/pydal/adapters/base.py", 
> line 486, in insert
> raise e
> IntegrityError: FOREIGN KEY constraint failed
>
> Error snapshot [image: help] 
> 
>  
>
> (FOREIGN KEY constraint failed) 
>
> inspect attributes 
> Frames 
>
>- 
>
>*File /home/mostwanted/web2py/gluon/restricted.py in restricted at 
>line 219* code arguments variables 
>- 
>
>*File 
>/home/mostwanted/web2py/applications/SRMS/controllers/appadmin.py in 
> at line 696* code arguments variables 
>- 
>
>*File /home/mostwanted/web2py/gluon/globals.py in  at line 409* 
>code arguments variables 
>- 
>
>*File 
>/home/mostwanted/web2py/applications/SRMS/controllers/appadmin.py in 
> insert 
>at line 147* code arguments variables 
>- 
>
>*File /home/mostwanted/web2py/gluon/sqlhtml.py in accepts at line 1862* 
>code arguments variables 
>- 
>
>*File /home/mostwanted/web2py/gluon/packages/dal/pydal/objects.py in 
>insert at line 734* code arguments variables 
>- 
>
>*File 
>/home/mostwanted/web2py/gluon/packages/dal/pydal/adapters/base.py in 
> insert 
>at line 486* code arguments variables 
>Function argument list 
>
>(self=, table=surname, name, photo, guardian, class_name, dob)>, 
>fields=[(, 'Leburu'), (object>, 'Percy'), (, '2010-10-05'), 
>(, 5), (, 21), 
>(, 
>'student.photo.a21f46af61cba907.706963322e6a7067.jpg')])
>Code listing 
>
>481.
>482.
>483.
>484.
>485.
>486.
>
>487.
>488.
>489.
>490.
>
>self.execute(query)
>except:
>e = sys.exc_info()[1]
>if hasattr(table, '_on_insert_error'):
>return table._on_insert_error(table, fields, e)
>raise e
>
>if hasattr(table, '_primarykey'):
>pkdict = dict([
>(k[0].name, k[1]) 

Re: [web2py] Re: migrating database and updating it

2017-10-25 Thread Yebach
So this is the whole procedure I did at the end and it seems to do the trick

   1. create a folder for your new app (WoShiTest)
   2. copy production version there
   3. delete content of sessions, error and DATABASE folders
   4. in 0.py set db connection string
   5. set migrate = True and false migrate = False
   6. create database in postgres with the name you put in 0.py
   7. start web2py (in my case from cmd running web2py.exe -i 
   192.168.100.47 -p 8080 -a 12345 -K WoShiTest -X)
   8. check if db is created and access to the webapp
   9. it works? Good
   10. delete database on postgres
   11. create new with the same name and restore the production db with all 
   your data
   12. no errors or warnings? Good
   13. again run web2py server and check if all the stuff works - now 
   including login stuff
   14. it does? No! You are getting ERROR:web2py.scheduler.ue-ebi#2488:
   error popping tasks --> stop server. delete all scheduler related tables on 
   postgres and files in database folder related to scheduler table
   15. run server again
   16. now it works? Great - almost there
   17. now lets update the current app to the new/develop app
   18. copy the following folders from develop app - controlers, model, 
   modules, static, ...view and all you think you need EXCEPT errors, sessions 
   and of course DATABASE
   19. update 0.py and set new db connection
   20. now start using your brand new updated bugfree app :)

I hope somebody finds this useful



On Tuesday, October 24, 2017 at 10:32:11 PM UTC+2, Alex Glaros wrote:
>
> I'm a beginner but seems like you should create your new version to first 
> be exact duplicate of the original, pg_restore db to the new version, make 
> sure it's working like old one, THEN change DAL tables, then run migrate = 
> True.  (I haven't needed to run fake_migrate in these situations)
>
> Maybe I read it wrong but looks like you changed DAL first on the new 
> instance, then imported Postgres db.
>
> Of course keep your Postgres archive as permanent backup.
>
> Alex Glaros
>

-- 
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] IntegrityError('FOREIGN KEY constraint failed',)

2017-10-25 Thread mostwanted


*WHEN I TRY ENTERING A STUDENT'S DETAILS AND SELECTING THEIR GUARDIAN AS 
FROM THE DROP DOWN MENU AS REFERNCED I GET A FOREIGN CONSTRAINT FAILED 
ERROR MESSAGEMY TABLES*

db.define_table('guardian',
Field('surname', requires=IS_NOT_EMPTY()),
Field('name', requires=IS_NOT_EMPTY()),
Field('contact_number'),
format='%(surname)s')

db.define_table('student',
Field('surname', requires=IS_NOT_EMPTY()),
Field('name', requires=IS_NOT_EMPTY()),
Field('photo', 'upload', requires=IS_NOT_EMPTY()),
Field('guardian', 'reference guardian'),
Field('class_name', 'reference student_class'),
Field('dob', 'date', requires=IS_NOT_EMPTY()),
format='%(surname)s')

*MY CONTROLLER*

def show_students():
show_students=db(db.student).select(db.student.ALL)
return locals()



*MY VIEW*
SELECT A STUDENT TO VIEW THEIR PROFILE


SURNAME
NAME
CLASS
GUARDIAN

{{for students in show_students:}}

{{=A('VIEW', _class="glyphicon glyphicon-user", 
_href=URL('student_profile', args=students.id))}} | 
 {{=students.surname}}
{{=students.name}}
{{=students.class_name.class_name}}
{{=students.guardian.guardian}}

{{pass}}




*MY TRACEBACK ERROR*
 FOREIGN KEY constraint failed 



Traceback (most recent call last):
  File "/home/mostwanted/web2py/gluon/restricted.py", line 219, in restricted
exec(ccode, environment)
  File "/home/mostwanted/web2py/applications/SRMS/controllers/appadmin.py" 
, line 
696, in 
  File "/home/mostwanted/web2py/gluon/globals.py", line 409, in 
self._caller = lambda f: f()
  File "/home/mostwanted/web2py/applications/SRMS/controllers/appadmin.py" 
, line 
147, in insert
if form.accepts(request.vars, session):
  File "/home/mostwanted/web2py/gluon/sqlhtml.py", line 1862, in accepts
self.vars.id = self.table.insert(**fields)
  File "/home/mostwanted/web2py/gluon/packages/dal/pydal/objects.py", line 734, 
in insert
ret = self._db._adapter.insert(self, row.op_values())
  File "/home/mostwanted/web2py/gluon/packages/dal/pydal/adapters/base.py", 
line 486, in insert
raise e
IntegrityError: FOREIGN KEY constraint failed

Error snapshot [image: help] 

 

(FOREIGN KEY constraint failed) 

inspect attributes 
Frames 
   
   - 
   
   *File /home/mostwanted/web2py/gluon/restricted.py in restricted at line 
   219* code arguments variables 
   - 
   
   *File /home/mostwanted/web2py/applications/SRMS/controllers/appadmin.py 
   in  at line 696* code arguments variables 
   - 
   
   *File /home/mostwanted/web2py/gluon/globals.py in  at line 409* 
   code arguments variables 
   - 
   
   *File /home/mostwanted/web2py/applications/SRMS/controllers/appadmin.py 
   in insert at line 147* code arguments variables 
   - 
   
   *File /home/mostwanted/web2py/gluon/sqlhtml.py in accepts at line 1862* 
   code arguments variables 
   - 
   
   *File /home/mostwanted/web2py/gluon/packages/dal/pydal/objects.py in 
   insert at line 734* code arguments variables 
   - 
   
   *File /home/mostwanted/web2py/gluon/packages/dal/pydal/adapters/base.py 
   in insert at line 486* code arguments variables 
   Function argument list 
   
   (self=, table=, 
   fields=[(, 'Leburu'), (, 'Percy'), (, '2010-10-05'), 
   (, 5), (, 21), 
   (, 
   'student.photo.a21f46af61cba907.706963322e6a7067.jpg')])
   Code listing 
   
   481.
   482.
   483.
   484.
   485.
   486.
   
   487.
   488.
   489.
   490.
   
   self.execute(query)
   except:
   e = sys.exc_info()[1]
   if hasattr(table, '_on_insert_error'):
   return table._on_insert_error(table, fields, e)
   raise e
   
   if hasattr(table, '_primarykey'):
   pkdict = dict([
   (k[0].name, k[1]) for k in fields
   if k[0].name in table._primarykey])
   
   Variables 
   e IntegrityError('FOREIGN KEY constraint failed',) 
   
Context 

locals request session response 
In file: /home/mostwanted/web2py/applications/SRMS/controllers/appadmin.py 

1.

 at 0xb6e606e0, file 
"/home/mostwanted/web2py/applications/SRMS/controllers/appadmin.py", line 7>

-- 
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] Re: New syntax error?

2017-10-25 Thread Dave S


On Monday, October 23, 2017 at 3:38:27 PM UTC-7, Dave S wrote:
>
> In  my 2.15.x testing, I've been concentrating on the https interface, but 
> I now tried to do a -M -S that would queue up a Scheduler task.  And I ran 
> into an unexpected problem with syntax errors on print statements.
>
>if when:
>   print "ri_s: when " + when
>
> Even when I shorten the line to remove the concatenation, I get a syntax 
> error:
>
> Traceback (most recent call last):
>   File "web2py.py", line 33, in 
> gluon.widget.start(cron=True)
>   File "/home/ec2-user/web2py/web2py-2.15.4/web2py/gluon/widget.py", line 
> 1152, in start
> cronjob=options.cronjob)
>   File "/home/ec2-user/web2py/web2py-2.15.4/web2py/gluon/shell.py", line 
> 258, in run
> execfile(pyfile, _env)
>   File "applications/updater/controllers/default.py", line 140
> print "ri_s: when "
>   ^
> SyntaxError: invalid syntax
>
> I tried changing the variable name to "pwhen" in case this was an 
> if-statement/keyword issue, but still "invalid syntax".
>
> As you might guess, default.py loads fine for https requests, and this 
> code loads fine with -S under 2.14.6, so I'm not sure what's going on here.
>

Changing the print statements to logger calls allows the  -S load to 
complete, but I don't think anything went to web2py.log from these calls 
(logging calls used when handling http(s) requests seem to be working 
normally).

Plus, when you're running from the command line (as is often the case for 
-S), it's irritating to have to go to the log for what is ordinarily stdout 
material.

/dps

-- 
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: sistemExit during scheduler execution

2017-10-25 Thread Dave S


On Tuesday, October 24, 2017 at 1:06:02 PM UTC-7, Manuele wrote:
>
> Hi *! 
>
> What could be the reason of the subsequant traceback during a scheduler 
> function execution? 
>
> "Traceback (most recent call last):  File 
> "/home/colouree/web2py/gluon/scheduler.py", line 293, in executor
> _env = env(a=a, c=c, import_models=True)  File 
> "/home/colouree/web2py/gluon/shell.py", line 166, in env
> sys.exit(1)SystemExit: 1" 
>
> Cheers 
>
> Manuele 
>
>
Line 166 is the error handler after a try: run_models_in() .  Anything 
unusual about the models for this app?
Do you see an exception printed (on the console -- sys.stderr is used) with 
the stack trace?

/dps

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