[web2py] Re: Scheduler error: Exception in thread Thread-1 and connection is closed

2015-11-21 Thread kenny c
I think there is timeout issue on the scheduler and I am not sure which one 
it is..

Seems to me that the Scheduler stops if it takes longer than 5 minutes in 
regardless of the value of timeout saved in the task row.

On Saturday, November 21, 2015 at 8:12:05 PM UTC-5, kenny c wrote:
>
> HI, I am not sure what causes this issue..
>
> I am running Web2py with Postgresql, I am getting this exception in thread 
> while running a scheduler. and I get InterfaceError("Connection is closed") 
> .
>
> I am wondering if Postgresql has timeout setting or scheduler timeout? (I 
> made sure that timeout is long enough to handle all the jobs)
>
> Any help would be appreciated. Thank you and please see the log below.
>
> ERROR:web2py.scheduler.example#6580:Error retrieving status
> Exception in thread Thread-1:
> Traceback (most recent call last):
>   File "/usr/lib/python2.7/threading.py", line 810, in __bootstrap_inner
> self.run()
>   File "/home/www-data/web2py/gluon/scheduler.py", line 442, in run
> self.send_heartbeat(counter)
>   File "/home/www-data/web2py/gluon/scheduler.py", line 1041, in 
> send_heartbeat
> db.rollback()
>   File "/home/www-data/web2py/gluon/packages/dal/pydal/base.py", line 937, 
> in rollback
> self._adapter.rollback()
>   File "/home/www-data/web2py/gluon/packages/dal/pydal/adapters/base.py", 
> line 1332, in rollback
> return self.connection.rollback()
>   File "/home/www-data/web2py/gluon/contrib/pg8000/core.py", line 1429, in 
> rollback
> self.execute(self._cursor, "rollback", None)
>   File "/home/www-data/web2py/gluon/contrib/pg8000/core.py", line 1622, in 
> execute
> raise InterfaceError("connection is closed")
> InterfaceError: connection is closed
>
> Traceback (most recent call last):
>   File "/home/www-data/web2py/gluon/shell.py", line 271, in run
> exec(python_code, _env)
>   File "", line 1, in 
>   File "/home/www-data/web2py/gluon/scheduler.py", line 730, in loop
> self.wrapped_report_task(task, self.async(task))
>   File "/home/www-data/web2py/gluon/scheduler.py", line 879, in 
> wrapped_report_task
> db.rollback()
>   File "/home/www-data/web2py/gluon/packages/dal/pydal/base.py", line 937, 
> in rollback
> self._adapter.rollback()
>   File "/home/www-data/web2py/gluon/packages/dal/pydal/adapters/base.py", 
> line 1332, in rollback
> return self.connection.rollback()
>   File "/home/www-data/web2py/gluon/contrib/pg8000/core.py", line 1429, in 
> rollback
> self.execute(self._cursor, "rollback", None)
>   File "/home/www-data/web2py/gluon/contrib/pg8000/core.py", line 1622, in 
> execute
> raise InterfaceError("connection is closed")
> InterfaceError: connection is closed
>

-- 
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] Scheduler, run code first of each month

2015-11-21 Thread Jason Solack
Hello, i'm aware of being able to set the period in seconds we'd like  a 
task executed in the scheduler... but i'm wondering if there's a way to 
have the scheduler fire a task on the 1st of each month or if cron is 
required for that behavior.

Thank you for your input

Jason

-- 
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] Scheduler error: Exception in thread Thread-1 and connection is closed

2015-11-21 Thread kenny c
HI, I am not sure what causes this issue..

I am running Web2py with Postgresql, I am getting this exception in thread 
while running a scheduler. and I get InterfaceError("Connection is closed") 
.

I am wondering if Postgresql has timeout setting or scheduler timeout? (I 
made sure that timeout is long enough to handle all the jobs)

Any help would be appreciated. Thank you and please see the log below.

ERROR:web2py.scheduler.example#6580:Error retrieving status
Exception in thread Thread-1:
Traceback (most recent call last):
  File "/usr/lib/python2.7/threading.py", line 810, in __bootstrap_inner
self.run()
  File "/home/www-data/web2py/gluon/scheduler.py", line 442, in run
self.send_heartbeat(counter)
  File "/home/www-data/web2py/gluon/scheduler.py", line 1041, in 
send_heartbeat
db.rollback()
  File "/home/www-data/web2py/gluon/packages/dal/pydal/base.py", line 937, 
in rollback
self._adapter.rollback()
  File "/home/www-data/web2py/gluon/packages/dal/pydal/adapters/base.py", 
line 1332, in rollback
return self.connection.rollback()
  File "/home/www-data/web2py/gluon/contrib/pg8000/core.py", line 1429, in 
rollback
self.execute(self._cursor, "rollback", None)
  File "/home/www-data/web2py/gluon/contrib/pg8000/core.py", line 1622, in 
execute
raise InterfaceError("connection is closed")
InterfaceError: connection is closed

Traceback (most recent call last):
  File "/home/www-data/web2py/gluon/shell.py", line 271, in run
exec(python_code, _env)
  File "", line 1, in 
  File "/home/www-data/web2py/gluon/scheduler.py", line 730, in loop
self.wrapped_report_task(task, self.async(task))
  File "/home/www-data/web2py/gluon/scheduler.py", line 879, in 
wrapped_report_task
db.rollback()
  File "/home/www-data/web2py/gluon/packages/dal/pydal/base.py", line 937, 
in rollback
self._adapter.rollback()
  File "/home/www-data/web2py/gluon/packages/dal/pydal/adapters/base.py", 
line 1332, in rollback
return self.connection.rollback()
  File "/home/www-data/web2py/gluon/contrib/pg8000/core.py", line 1429, in 
rollback
self.execute(self._cursor, "rollback", None)
  File "/home/www-data/web2py/gluon/contrib/pg8000/core.py", line 1622, in 
execute
raise InterfaceError("connection is closed")
InterfaceError: connection is closed

-- 
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: Using orderby in IS_IN_DB with a foreign key.

2015-11-21 Thread 黄祥
yes you are right, thanks for corrected me

best regards,
stifan

On Sunday, November 22, 2015 at 2:24:53 AM UTC+7, Anthony wrote:
>
> On Saturday, November 21, 2015 at 2:19:02 PM UTC-5, 黄祥 wrote:
>>
>> please try :
>> IS_IN_DB(db, db.auth_user.id, db.auth_user._format, orderby = 
>> db.auth_user.first_name)
>>
>
> I don't think that will help in this case, as the field(s) in questions 
> are references to the db.mentor table, not the db.auth_user table (the 
> db.mentor table itself is linked to db.auth_user).
>
> 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: Using orderby in IS_IN_DB with a foreign key.

2015-11-21 Thread Anthony
On Saturday, November 21, 2015 at 2:19:02 PM UTC-5, 黄祥 wrote:
>
> please try :
> IS_IN_DB(db, db.auth_user.id, db.auth_user._format, orderby = 
> db.auth_user.first_name)
>

I don't think that will help in this case, as the field(s) in questions are 
references to the db.mentor table, not the db.auth_user table (the 
db.mentor table itself is linked to db.auth_user).

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: Using orderby in IS_IN_DB with a foreign key.

2015-11-21 Thread 黄祥
please try :
IS_IN_DB(db, db.auth_user.id, db.auth_user._format, orderby = 
db.auth_user.first_name)

if not work, perhaps you modif your auth_user table (first_name field into 
something else)

best regards,
stifan

-- 
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: Using orderby in IS_IN_DB with a foreign key.

2015-11-21 Thread Anthony
Are you saying you don't want to sort by the labels at all, but by some 
field(s) in auth_user that are otherwise not visible to the user? If so, I 
don't think you'll be able to do that with IS_IN_DB. Instead, build (and 
order) your set of values and labels manually, and then use the IS_IN_SET 
validator. Alternatively, you could use the IS_IN_DB validator to do the 
validation, and then override the "widget" attribute of the field with a 
custom widget that generates the options as you want them.

Anthony

On Saturday, November 21, 2015 at 12:32:13 PM UTC-5, Hilton Shumway wrote:
>
> I'm building a site with a number of different tables linked to the 
> auth_user table, namely mentors, judge, etc. A few different tables link 
> indirectly to auth_user through foreign keys to those tables, for example 
> abstract has a foreign key to mentor, which has a foreign key to auth_user.
>
> Now, it's possible the models should have been designed differently, but 
> considering the site is in production now, changing that is a little 
> difficult.
>
> My challenge is that various forms (including create/edit of abstracts, 
> SQLFORM.grid-based searching of abstracts, etc) provide a select widget 
> filled with available mentors, which is sorted according to mentor.id. 
> I'd like to make that sorting alphabetical according to 
> auth_user.first_name. After a bit of poking around I found 
> http://stackoverflow.com/questions/28238708/how-to-set-default-orderby-in-a-web2py-table
>  
> (which doesn't seem to be documented in the web2py book), but that would 
> only allow me to sort the select widget according to fields in mentor. If I 
> try to pass orderby=db.auth_user.first_name to IS_IN_DB, I get a  'sqlite3.OperationalError'> no such column: auth_user.first_name error. 
>
> Am I missing something obvious? My guess is that when IS_IN_DB makes its 
> query it doesn't select anything from auth_user, and attempts to reference 
> those columns don't work. Is there a way to change this?
>
> I'm happy to provide more information if needed.
>
> Hilton
>

-- 
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: Compile .less files?

2015-11-21 Thread Massimo Di Pierro
web2py does not compile them. You can compile them yourself and the add 
them to import files. All web2py allows you to do is to include them and 
than you have JS compile them clientside with less.js http://lesscss.org/ 
(not included)

On Friday, 20 November 2015 00:52:05 UTC-6, Thee Cherry wrote:
>
> Hi,
>
> I try to import (compile) .less files in web2py.
> I did find in the web2py book that you can import less files with
> response.files
>
> Did try to import a less file with that in the layout.html
> {{response.files.append(URL('static','less/style.less'))}}
>
> But in the source code from the finish page, i find just a 
>
>  type="text/css" />
>
>
> and not a compiled css. There is the failure?
>

-- 
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: cx_oracle web2Py on windows

2015-11-21 Thread Massimo Di Pierro
Are you running web2py from source?

On Friday, 20 November 2015 00:52:05 UTC-6, rochdi hassine wrote:
>
> I tried to connect web2py to my Oracle database.
> I have deployed web2py on a windows environment where python was already 
> installed with cx_oracle.
> But web2py haven't run with Oracle cause it can't see the driver cx_oracle 
> that is installed in Python directory.
> I tried to redeploy cx_oracle to the directory of web2py but it doesn't 
> work.
>
>

-- 
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] Routes on error - 401 redirect to login

2015-11-21 Thread Liam
I am creating a web2py application and I am using Auth for login.

Some of my controllers have functions that should be publicly accessible, 
but may sometimes attempt to access data that requires authorisation, in 
which case I raise HTTP 401. If the user is already logged in, it raises a 
403.

I would like to use routes_onerror to make it so that if a 401 error is 
raised, the user will be redirected to the login page.

The directory structure is
web2py
|_ applications
  |_ APPNAME
|_ controllers, models, views, etc.

In the web2py directory, I have placed routes.py, which is the renamed 
routes.parametric.example.py file that comes in the web2py/examples 
directory.

In the APPNAME directory, I have placed routes.py, with contents:
routes_onerror = [
('*/401', '/APPNAME/default/handle_401')
]

In my default.py controller, this is the handle_401 function:
def handle_401():
redirect(auth.settings.login_url)

I have pressed 'Reload routes' on the web2py admin page.

When there is a 401 error, it still just displays displays the error 
message passed alongside the raise, rather than redirecting.

Have I done something wrong to set it up? Is there anything I can do to 
diagnose why it isn't working?

-- 
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] Using orderby in IS_IN_DB with a foreign key.

2015-11-21 Thread Hilton Shumway
I'm building a site with a number of different tables linked to the 
auth_user table, namely mentors, judge, etc. A few different tables link 
indirectly to auth_user through foreign keys to those tables, for example 
abstract has a foreign key to mentor, which has a foreign key to auth_user.

Now, it's possible the models should have been designed differently, but 
considering the site is in production now, changing that is a little 
difficult.

My challenge is that various forms (including create/edit of abstracts, 
SQLFORM.grid-based searching of abstracts, etc) provide a select widget 
filled with available mentors, which is sorted according to mentor.id. I'd 
like to make that sorting alphabetical according to auth_user.first_name. 
After a bit of poking around I 
found 
http://stackoverflow.com/questions/28238708/how-to-set-default-orderby-in-a-web2py-table
 
(which doesn't seem to be documented in the web2py book), but that would 
only allow me to sort the select widget according to fields in mentor. If I 
try to pass orderby=db.auth_user.first_name to IS_IN_DB, I get a  no such column: auth_user.first_name error. 

Am I missing something obvious? My guess is that when IS_IN_DB makes its 
query it doesn't select anything from auth_user, and attempts to reference 
those columns don't work. Is there a way to change this?

I'm happy to provide more information if needed.

Hilton

-- 
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: web2py 2.0 DAL no longer usable for mysql stored procedures

2015-11-21 Thread Dániel Finta
Hi!

Just want to ask how long this still takes to fix? We like to use stored 
procedures for MySQL queries. After an executesql( "CALL... everything 
gives this error - even commit() and rollback(). This only happens if the 
procedure wants to give back a result. I have tried to fetch it manually 
through the cursor but no luck.

Could you point me to a solution or workaround other than write all queries 
by hand? Maybe it could be implemented as an execute_multiple or 
call_procedure function aside from the normal workings to not mess things 
up in the current DAL?

Thanks,
rawbits



2013. január 25., péntek 19:44:06 UTC+1 időpontban Massimo Di Pierro a 
következőt írta:
>
> True. For now you need to separate calls to db.executesql if you have 
> multiple queries.
>
> On Friday, 25 January 2013 11:54:18 UTC-6, AngeloC wrote:
>>
>> Hi Massimo,
>>
>> I think this is a real problem.
>>
>> In a web2py shell you can do:
>>
>> rows = db.executesql("select * from charts")
>>
>> but you cannot do:
>>
>> rows = db.executesql("select * from charts; select * from charts;")
>>
>> it raises the error above.
>>
>> I think the problem is related to multiple resultsets. That example query 
>> return 2 resultset, as well a stored procedure could return multiple 
>> resultset. I think web2py mess something when a multiquery or a stored 
>> procudere returns more than one resultset.
>>
>>
>> Mysql user guide says here (
>> http://dev.mysql.com/doc/refman/5.0/en/commands-out-of-sync.html):
>>
>> If you get Commands out of sync; you can't run this command now in your 
>> client code, you are calling client functions in the wrong order.
>>
>> This can happen, for example, if you are using mysql_use_result() 
>>  and try 
>> to execute a new query before you have called mysql_free_result() 
>> . It can 
>> also happen if you try to execute two queries that return data without 
>> calling mysql_use_result() 
>>  or 
>> mysql_store_result() 
>>  in 
>> between.
>>
>>
>>
>> 2012/9/28 Yarin 
>>
>>> Done: http://code.google.com/p/web2py/issues/detail?id=1037
>>>
>>>
>>> On Thursday, September 27, 2012 4:33:37 PM UTC-4, Massimo Di Pierro 
>>> wrote:

 Is this issue still open? If so, can you open a ticket about it?

 Massimo

 On Monday, 24 September 2012 14:38:14 UTC-5, Yarin wrote:
>
>
>
> db.py:
> db.define_table('mytable',Field('myfield','string'))
>
> sproc:
> DELIMITER //
> CREATE PROCEDURE TestSproc()
>   BEGIN
>   SELECT COUNT(*) FROM mytable;
>   END //
> DELIMITER;
>
> tests.py
> """NOTE: Tests 1-3 will fail every time in wsgi/linux environments. 
> From the web2py command line, they will work once, until another 
> operation is called on the db, INCLUDING commit().
>
> In web2py 1, you can run these once successfully, but subsequent sql 
> operations on the current connection return None results.
> """
>
> def test_1():
>  ''' RESULT: ProgrammingError: (2014, "Commands out of sync; you cant 
> run this command now") '''
>  
>  sql = '''CALL TestSproc();'''
>  results = db.executesql(sql, as_dict=True)
>  return str(results)
>  
> def test_2():
>  ''' RESULT: ProgrammingError: (2014, "Commands out of sync; you cant 
> run this command now") '''
>  
>  sql = """CALL TestSproc();"""
>  results = db.executesql(sql, as_dict=True)
>  db.commit()
>  return str(results)
>  
> def test_3():
>  ''' RESULT: ProgrammingError: (2014, "Commands out of sync; you cant 
> run this command now") '''
>  
>  sql = """CALL TestSproc();"""
>  db._adapter.execute(sql)
>  results = db._adapter.cursor.fetchall()
>  return str(results)
>  
> def test_4():
>  ''' RESULT: Works '''
>  
>  import contrib.pymysql as pymysql
>  sql = """CALL TestSproc();"""
>  conn = pymysql.connect(host='127.0.0.1', port=3306, user='root', 
> passwd='root', db='test')
>  cur = conn.cursor(pymysql.cursors.DictCursor)
>  cur.execute(sql)
>  results = cur.fetchall()
>  cur.close()
>  conn.close()
>  return str(results)
>
>
>
>
>
> On Monday, September 24, 2012 1:10:14 PM UTC-4, Massimo Di Pierro 
> wrote:
>>
>> can you show us some of your code. This may be a concurrency issues. 
>> I cannot thing anything we change that would affect the behavior.
>>
>> On Sunday, 23 September 2012 22:43:28 UTC-5, Yarin wrote:
>>>
>>> After upgrading to web2py 2.0, we can no longer use the DAL or mysql 
>>> adapters to make MySQL stored procedure calls.
>>>
>>> In web2py 1.x I had reported 
>>> 

[web2py] Catching module exception

2015-11-21 Thread Edward Suárez
Hi, I have a problem trying to catch an exception of this module 
Grokzen/redis-py-cluster 
 this is the code:
from rediscluster.exceptions import RedisClusterException

def getToken(key):
try:
token = redis.get(key)
if token != None:
respuesta = redis.expire(key, 1800)
return token
return False
except RedisClusterException, Error:
return dict(status =  500, error = str(Error))

and this is the ticket i get:

 No startup nodes 
provided
 
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] Re: how come i can't INPUT append?

2015-11-21 Thread Leonel Câmara
To delete you do the same thing you do in a dict you use del

del in_fn['_disabled']

or, does that simply set the attribute to empty string?


Yes that's what your solution does

-- 
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] Nginx Gateway Timeout

2015-11-21 Thread Mark Billion
It takes a while to process certain pdf creation requests and the Nginx 
server is throwing a 504 error.  Its atop ubuntu 14.04 w web2py -- it was 
set up using the included w2p scripts.

I am sure that this is a simple question, but my searching has only located 
answers about some PHP function.

-- 
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: executesql issue

2015-11-21 Thread Pierre
Thanks Richard & Anthony

Now, I understand better what's a sql injection


If YOU read this message : stay away from SQL injection and also from SQL 
intrusion !!!


-- 
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: how come i can't INPUT append?

2015-11-21 Thread lucas
and you would delete the attribute altogether by?

in_fn['_disabled'] = ''

or, does that simply set the attribute to empty string?

lucas

-- 
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: how come i can't INPUT append?

2015-11-21 Thread Leonel Câmara
Append is supposed to "append" HTML elements to the list of children of an 
element, its argument should be an HTML element not a keyword arg. 
Obviously you would not want to append to an Input element anyway.

You can set attributes in web2py HTML helpers like you set keys in a 
dictionary so what you actually want is:

if completed:
in_fn['_disabled'] = 'disabled'




-- 
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] how come i can't INPUT append?

2015-11-21 Thread lucas
hello one and all,

how come i can't?

in_fn = INPUT(_type='text', _name='fn', 
_value=l.followup_notes, _class='text', _style='text-align: left; width: 
100%; height: 16px; padding: 2px;', _rows='1')
if completed:
in_fn.append(_disabled='disabled')

where the error comes in on the last line and is:

TypeError: append() got an unexpected keyword argument '_disabled'

anyway to make this happen and thank you in advance, lucas

-- 
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] how come i can't TD append?

2015-11-21 Thread lucas
hello one and all,

how come i can't?

in_fn = INPUT(_type='text', _name='fn', 
_value=l.followup_notes, _class='text', _style='text-align: left; width: 
100%; height: 16px; padding: 2px;', _rows='1')
if completed:
in_fn.append(_disabled='disabled')

where the error comes in on the last line and is:

TypeError: append() got an unexpected keyword argument '_disabled'

anyway to make this happen and thank you in advance, lucas


-- 
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] REST API POST Return non-dict creates an obscure error message

2015-11-21 Thread James Burke
I recently upgraded an application on Pythonanywhere.com to: Version 
2.12.3-stable+timestamp.2015.08.19.00.18.03

Part of the application uses jQuery to post files to a web2py REST API. 
After the upgrade I noticed that I kept getting this unhelpful error 500 
message:

PythonAnywhere: something went wrong :-(

Looking at the server error log seemed to point to a DAL error...:

2015-11-21 07:11:07,012 :Traceback (most recent call last):
2015-11-21 07:11:07,013 :  File "/bin/user_wsgi_wrapper.py", line 134, in 
__call__
2015-11-21 07:11:07,013 :self.error_log_file.logger.exception("Error 
running WSGI application")
2015-11-21 07:11:07,013 :  File "/usr/lib/python2.7/logging/__init__.py", line 
1185, in exception
2015-11-21 07:11:07,014 :self.error(msg, *args, **kwargs)
2015-11-21 07:11:07,014 :  File "/usr/lib/python2.7/logging/__init__.py", line 
1178, in error
2015-11-21 07:11:07,014 :self._log(ERROR, msg, args, **kwargs)
2015-11-21 07:11:07,014 :  File "/usr/lib/python2.7/logging/__init__.py", line 
1270, in _log
2015-11-21 07:11:07,015 :record = self.makeRecord(self.name, level, fn, 
lno, msg, args, exc_info, func, extra)
2015-11-21 07:11:07,015 :  File "/usr/lib/python2.7/logging/__init__.py", line 
1244, in makeRecord
2015-11-21 07:11:07,015 :rv = LogRecord(name, level, fn, lno, msg, args, 
exc_info, func)
2015-11-21 07:11:07,015 :  File "/usr/lib/python2.7/logging/__init__.py", line 
284, in __init__
2015-11-21 07:11:07,016 :self.threadName = threading.current_thread().name
2015-11-21 07:11:07,016 :  File "/usr/lib/python2.7/threading.py", line 1160, 
in currentThread
2015-11-21 07:11:07,016 :return _active[_get_ident()]
2015-11-21 07:11:07,016 :  File "/bin/user_wsgi_wrapper.py", line 127, in 
__call__
2015-11-21 07:11:07,016 :for response in app_iterator:
2015-11-21 07:11:07,016 :  File 
"/home/web2py2/gluon/packages/dal/pydal/helpers/classes.py", line 133, in 
__getitem__
2015-11-21 07:11:07,020 :self.__allocate()
2015-11-21 07:11:07,020 :  File 
"/home/web2py2/gluon/packages/dal/pydal/helpers/classes.py", line 102, in 
__allocate
2015-11-21 07:11:07,021 :self._record = self._table[long(self)]
2015-11-21 07:11:07,021 :  File 
"/home/web2py2/gluon/packages/dal/pydal/objects.py", line 505, in __getitem__
2015-11-21 07:11:07,022 :orderby_on_limitby=False
2015-11-21 07:11:07,022 :  File 
"/home/web2py2/gluon/packages/dal/pydal/objects.py", line 2002, in select
2015-11-21 07:11:07,023 :return adapter.select(self.query,fields,attributes)
2015-11-21 07:11:07,023 :  File 
"/home/web2py2/gluon/packages/dal/pydal/adapters/base.py", line 1286, in select
2015-11-21 07:11:07,025 :return self._select_aux(sql,fields,attributes)
2015-11-21 07:11:07,025 :  File 
"/home/web2py2/gluon/packages/dal/pydal/adapters/base.py", line 1243, in 
_select_aux
2015-11-21 07:11:07,026 :self.execute(sql)
2015-11-21 07:11:07,026 :  File 
"/home/web2py2/gluon/packages/dal/pydal/adapters/base.py", line 1378, in execute
2015-11-21 07:11:07,027 :return self.log_execute(*a, **b)
2015-11-21 07:11:07,027 :  File 
"/home/web2py2/gluon/packages/dal/pydal/adapters/base.py", line 1363, in 
log_execute
2015-11-21 07:11:07,028 :if not self.connection: raise ValueError(a[0])
2015-11-21 07:11:07,028 :ValueError: SELECT  workspace.id, 
workspace.repository, workspace.name, workspace.file, workspace.created_date, 
workspace.modified_date, workspace.company_id FROM workspace WHERE 
(workspace.id = 17) LIMIT 1 OFFSET 0;


It wasn't until I disabled the return statement in the REST API POST 
function that I identified the cause of the error.

The issue seems to have been that I was returning an integer value, as 
apposed to JSON/dict etc as mentioned in this thread:
https://groups.google.com/forum/#!searchin/web2py/post$20api$20error/web2py/TDPiz6-DMkc/eaNrGoozCgAJ

I also tested on Rocket server - it is a bit more informative:

ERROR:Rocket.Errors.Thread-2:Traceback (most recent call last):

  File "/home/web2py2/gluon/rocket.py", line 1337, in run
self.run_app(conn)

  File "/home/web2py2/gluon/rocket.py", line 1868, in run_app
output.close()

TypeError: 'NoneType' object is not callable

-- 
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: Field set the default value +1 on insert

2015-11-21 Thread Bart van Berkel
Hello my friends,

Thanks for the inspiration.
The answer from Craig, looks to me a good idea how i can do it.

many thanks,

Bart

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