Re: [web2py] getting " [Errno 13] Permission denied" over and over

2014-09-04 Thread Johann Spies
On 3 September 2014 23:31, JorgeH  wrote:

I discovered that by cleaning errors, cache and sessions, its work again.
> But now Im getting the error like every other time I test.
>
> Any hints??
>
>
Which user owns web2py/applications//models?

Regards
Johann

-- 
Because experiencing your loyal love is better than life itself,
my lips will praise you.  (Psalm 63:3)

-- 
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: SQLFORM.smartgrid 'module' object has no attribute 'split'

2014-09-04 Thread Niphlod
what's the table definition of db.cdr ?

On Thursday, September 4, 2014 4:29:17 AM UTC+2, visuallinux wrote:
>
> Hi All.
>
> I am trying to use SQLFORM.smartgrid:
>
> query=(db.cdr.accountcode==form.vars.nombre[0])
>
> grid=SQLFORM.smartgrid(db.cdr,constraints=dict(cdr=query),details=False,create=False,editable=False,deletable=False,csv=False)
>
> But i received the follow exception:
>
>  'module' object has no attribute 'split'
> Versiónweb2py™Version 2.9.5-stable+timestamp.2014.03.16.02.35.39PythonPython 
> 2.6.6: /usr/bin/python (prefix: /usr)Traceback
>
> 1.
> 2.
> 3.
> 4.
> 5.
> 6.
> 7.
> 8.
> 9.
> 10.
> 11.
> 12.
> 13.
> 14.
> 15.
> 16.
> 17.
> 18.
>
> Traceback (most recent call last):
>   File "/home/fvillarroel/www/web2py/gluon/restricted.py", line 220, in 
> restricted
> exec ccode in environment
>   File 
> "/home/fvillarroel/www/web2py/applications/freeswitch/controllers/repocallcltes.py"
>  
> ,
>  line 28, in 
>   File "/home/fvillarroel/www/web2py/gluon/globals.py", line 385, in 
> self._caller = lambda f: f()
>   File "/home/fvillarroel/www/web2py/gluon/tools.py", line 3287, in f
> return action(*a, **b)
>   File 
> "/home/fvillarroel/www/web2py/applications/freeswitch/controllers/repocallcltes.py"
>  
> ,
>  line 12, in repocallcltes
> grid=SQLFORM.smartgrid(db.cdr, 
> constraints=dict(cdr=query),details=False,create=False,editable=False,deletable=False,csv=False)
>   File "/home/fvillarroel/www/web2py/gluon/sqlhtml.py", line 2800, in 
> smartgrid
> user_signature=user_signature, **kwargs)
>   File "/home/fvillarroel/www/web2py/gluon/sqlhtml.py", line 2255, in grid
> search_menu = SQLFORM.search_menu(sfields, prefix=prefix)
>   File "/home/fvillarroel/www/web2py/gluon/sqlhtml.py", line 1709, in 
> search_menu
> ftype = field.type.split(' ')[0]
> AttributeError: 'module' object has no attribute 'split'
>
>
> I do not know what i am doing wrong and if i changed smartgrid for 
> sqlform.grid i reveived the same error.
>
> 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: 2.9.6 broke custom view template delimiters

2014-09-04 Thread Jonathan New
Unfortunately, the latest patch (Version 
2.9.6-stable+timestamp.2014.09.02.01.57.55) doesn't solve the problem.

line 282:
if delimiters is None:
delimiters = context.get('response', {})\
.get('app_settings',{}).get('template_delimiters')

However, delimiters will never be None. It will always have the default 
value of ('{{', '}}')


The pre-2.9.6 code works because line 286 checks for existence of 
response.delimiter:

if delimiters != self.default_delimiters:
escaped_delimiters = (escape(delimiters[0]),
  escape(delimiters[1]))
self.r_tag = compile(r'(%s.*?%s)' % escaped_delimiters, DOTALL)
el*if hasattr(context.get('response', None), 'delimiters')*:
if context['response'].delimiters != self.default_delimiters:
escaped_delimiters = (
escape(context['response'].delimiters[0]),
escape(context['response'].delimiters[1]))
self.r_tag = compile(r'(%s.*?%s)' % escaped_delimiters,
 DOTALL)



On Wednesday, September 3, 2014 9:29:50 PM UTC+8, Massimo Di Pierro wrote:
>
> This will be fixed today with a new emergency release.
>
> On Wednesday, 3 September 2014 05:02:15 UTC-5, Jonathan New wrote:
>>
>> In prior web2py versions, we can change the template delimiters by 
>> response.delimiters 
>> = ('')
>>
>> With 2.9.6, gluon/template.py in lines 282-290 were changed such that 
>> response.delimiters doesn't work. 
>> I tried response.app_settings = {'template_delimiters': ('')}  
>> which the new code seems to refer to, also doesn't work
>>
>> BTW, line 286 also have typo error: escaped_delimiters = (escape(
>> elimiters[0])
>>
>>
>>

-- 
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: 2.9.6 broke custom view template delimiters

2014-09-04 Thread Jonathan New
Hi Massimo,

I propose changing lines 282-290 to 

if delimiters != self.default_delimiters:
escaped_delimiters = (escape(delimiters[0]),
  escape(delimiters[1]))
self.r_tag = compile(r'(%s.*?%s)' % escaped_delimiters, DOTALL)
elif hasattr(context.get('response', None), 'delimiters'):
if context['response'].delimiters != self.default_delimiters:
delimiters = context['response'].delimiters
escaped_delimiters = (
escape(delimiters[0]),
escape(delimiters[1]))
self.r_tag = compile(r'(%s.*?%s)' % escaped_delimiters,
 DOTALL)


On Thursday, September 4, 2014 6:48:13 PM UTC+8, Jonathan New wrote:
>
> Unfortunately, the latest patch (Version 
> 2.9.6-stable+timestamp.2014.09.02.01.57.55) doesn't solve the problem.
>
> line 282:
> if delimiters is None:
> delimiters = context.get('response', {})\
> .get('app_settings',{}).get('template_delimiters')
>
> However, delimiters will never be None. It will always have the default 
> value of ('{{', '}}')
>
>
> The pre-2.9.6 code works because line 286 checks for existence of 
> response.delimiter:
>
> if delimiters != self.default_delimiters:
> escaped_delimiters = (escape(delimiters[0]),
>   escape(delimiters[1]))
> self.r_tag = compile(r'(%s.*?%s)' % escaped_delimiters, DOTALL)
> el*if hasattr(context.get('response', None), 'delimiters')*:
> if context['response'].delimiters != self.default_delimiters:
> escaped_delimiters = (
> escape(context['response'].delimiters[0]),
> escape(context['response'].delimiters[1]))
> self.r_tag = compile(r'(%s.*?%s)' % escaped_delimiters,
>  DOTALL)
>
>
>
> On Wednesday, September 3, 2014 9:29:50 PM UTC+8, Massimo Di Pierro wrote:
>>
>> This will be fixed today with a new emergency release.
>>
>> On Wednesday, 3 September 2014 05:02:15 UTC-5, Jonathan New wrote:
>>>
>>> In prior web2py versions, we can change the template delimiters by 
>>> response.delimiters 
>>> = ('')
>>>
>>> With 2.9.6, gluon/template.py in lines 282-290 were changed such that 
>>> response.delimiters doesn't work. 
>>> I tried response.app_settings = {'template_delimiters': ('')}  
>>> which the new code seems to refer to, also doesn't work
>>>
>>> BTW, line 286 also have typo error: escaped_delimiters = (escape(
>>> elimiters[0])
>>>
>>>
>>>

-- 
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: SQLFORM.smartgrid 'module' object has no attribute 'split'

2014-09-04 Thread 'FERNANDO VILLARROEL' via web2py-users
Hi.

The database definition ;


db.define_table('cdr',
Field('caller_id_name',length=30),
Field('caller_id_number',length=30),
Field('destination_number',length=30),
Field('context',length=20),
Field('start_stamp', datetime),
Field('answer_stamp', datetime),
Field('end_stamp',datetime),
Field('duration','integer'),
Field('billsec','integer'),
Field('hangup_cause',length=50),
Field('accountcode',db.auth_user),
Field('read_codec',length=20),
Field('write_codec',length=20),
Field('cost', 'decimal(20,6)'),
Field('carrier',length=255),
Field('rate','decimal(11,5)'), 
format='%(caller_id_number)s',migrate=False)




On Thursday, September 4, 2014 4:34 AM, Niphlod  wrote:
 


what's the table definition of db.cdr ?

On Thursday, September 4, 2014 4:29:17 AM UTC+2, visuallinux wrote:
Hi All.
>
>
>I am trying to use SQLFORM.smartgrid:
>
>
>query=(db.cdr.accountcode== form.vars.nombre[0])
>grid=SQLFORM.smartgrid(db.cdr, constraints=dict(cdr=query), 
>details=False,create=False, editable=False,deletable= False,csv=False)
>
>
>But i received the follow exception:
>
>
> 'module' object has no attribute 'split'
>Versión
>web2py™Version 2.9.5-stable+timestamp.2014. 03.16.02.35.39 
>PythonPython 2.6.6: /usr/bin/python (prefix: /usr) 
>Traceback
>1.
>2.
>3.
>4.
>5.
>6.
>7.
>8.
>9.
>10.
>11.
>12.
>13.
>14.
>15.
>16.
>17.
>18. Traceback (most recent call last):
>File "/home/fvillarroel/www/web2py/ gluon/restricted.py", line 220, in 
>restricted
>exec ccode in environment
>File "/home/fvillarroel/www/web2py/ applications/freeswitch/ 
>controllers/repocallcltes.py", line 28, in 
>File "/home/fvillarroel/www/web2py/ gluon/globals.py", line 385, in 
>self._caller = lambda f: f()
>File "/home/fvillarroel/www/web2py/ gluon/tools.py", line 3287, in f
>return action(*a, **b)
>File "/home/fvillarroel/www/web2py/ applications/freeswitch/ 
>controllers/repocallcltes.py", line 12, in repocallcltes
>grid=SQLFORM.smartgrid(db.cdr, constraints=dict(cdr=query),de 
>tails=False,create=False,edita ble=False,deletable=False,csv=False)
>File "/home/fvillarroel/www/web2py/ gluon/sqlhtml.py", line 2800, in smartgrid
>user_signature=user_signature, **kwargs)
>File "/home/fvillarroel/www/web2py/ gluon/sqlhtml.py", line 2255, in grid
>search_menu = SQLFORM.search_menu(sfields, prefix=prefix)
>File "/home/fvillarroel/www/web2py/ gluon/sqlhtml.py", line 1709, in 
>search_menu
>ftype = field.type.split(' ')[0]
>AttributeError: 'module' object has no attribute 'split' 
>
>
>I do not know what i am doing wrong and if i changed smartgrid for 
>sqlform.grid i reveived the same error.
>
>
>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: SQLFORM.smartgrid 'module' object has no attribute 'split'

2014-09-04 Thread Niphlod
tat's probabl why replace *datetime* with *'datetime'* (notice the *''*)

On Thursday, September 4, 2014 1:37:51 PM UTC+2, visuallinux wrote:
>
> Hi.
>
> The database definition ;
>
>
> db.define_table('cdr',
> Field('caller_id_name',length=30),
> Field('caller_id_number',length=30),
> Field('destination_number',length=30),
> Field('context',length=20),
> Field('start_stamp', datetime),
> Field('answer_stamp', datetime),
> Field('end_stamp',datetime),
> Field('duration','integer'),
> Field('billsec','integer'),
> Field('hangup_cause',length=50),
> Field('accountcode',db.auth_user),
> Field('read_codec',length=20),
> Field('write_codec',length=20),
> Field('cost', 'decimal(20,6)'),
> Field('carrier',length=255),
> Field('rate','decimal(11,5)'), 
> format='%(caller_id_number)s',migrate=False)
>
>
>
>
>   On Thursday, September 4, 2014 4:34 AM, Niphlod  > wrote:
>  
>
> what's the table definition of db.cdr ?
>
> On Thursday, September 4, 2014 4:29:17 AM UTC+2, visuallinux wrote:
>
> Hi All.
>
> I am trying to use SQLFORM.smartgrid:
>
> query=(db.cdr.accountcode== form.vars.nombre[0])
> grid=SQLFORM.smartgrid(db.cdr, constraints=dict(cdr=query), 
> details=False,create=False, editable=False,deletable= False,csv=False)
>
> But i received the follow exception:
>
>  'module' object has no attribute 'split'
> Versiónweb2py™Version 2.9.5-stable+timestamp.2014. 03.16.02.35.39PythonPython 
> 2.6.6: /usr/bin/python (prefix: /usr)Traceback
>
> 1.
> 2.
> 3.
> 4.
> 5.
> 6.
> 7.
> 8.
> 9.
> 10.
> 11.
> 12.
> 13.
> 14.
> 15.
> 16.
> 17.
> 18.
>
> Traceback (most recent call last):
>   File "/home/fvillarroel/www/web2py/ gluon/restricted.py", line 220, in 
> restricted
> exec ccode in environment
>   File "/home/fvillarroel/www/web2py/ applications/freeswitch/ 
> controllers/repocallcltes.py" 
> ,
>  line 28, in 
>   File "/home/fvillarroel/www/web2py/ gluon/globals.py", line 385, in 
> self._caller = lambda f: f()
>   File "/home/fvillarroel/www/web2py/ gluon/tools.py", line 3287, in f
> return action(*a, **b)
>   File "/home/fvillarroel/www/web2py/ applications/freeswitch/ 
> controllers/repocallcltes.py" 
> ,
>  line 12, in repocallcltes
> grid=SQLFORM.smartgrid(db.cdr, constraints=dict(cdr=query),de 
> tails=False,create=False,edita ble=False,deletable=False,csv= False)
>   File "/home/fvillarroel/www/web2py/ gluon/sqlhtml.py", line 2800, in 
> smartgrid
> user_signature=user_signature, **kwargs)
>   File "/home/fvillarroel/www/web2py/ gluon/sqlhtml.py", line 2255, in grid
> search_menu = SQLFORM.search_menu(sfields, prefix=prefix)
>   File "/home/fvillarroel/www/web2py/ gluon/sqlhtml.py", line 1709, in 
> search_menu
> ftype = field.type.split(' ')[0]
> AttributeError: 'module' object has no attribute 'split'
>
>
> I do not know what i am doing wrong and if i changed smartgrid for 
> sqlform.grid i reveived the same error.
>
> 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] Re: Version 2.9.6 indeed breaks backward compat for some users

2014-09-04 Thread Philip Kilner

Hi Anthony,

On 03/09/14 17:11, Anthony wrote:

I wonder if we should add an option to set that database-wide --
something like DAL(..., case_sensitive_like=False).



+1 from me!


Also, should .startswith and .endswith have a case sensitive option?



+1 again, but much less pressing, at least for me.


--

Regards,

PhilK


'a bell is a cup...until it is struck'

--
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: SQLFORM.smartgrid 'module' object has no attribute 'split'

2014-09-04 Thread 'FERNANDO VILLARROEL' via web2py-users
Dear,

i changed datetime with 'datetime' and now it's works

Thank You


On Thursday, September 4, 2014 8:15 AM, Niphlod  wrote:
 


tat's probabl why replace datetime with 'datetime' (notice the '')

On Thursday, September 4, 2014 1:37:51 PM UTC+2, visuallinux wrote:
Hi.
>
>
>The database definition ;
>
>
>
>
>db.define_table('cdr',
>Field('caller_id_name',length= 30),
>Field('caller_id_number', length=30),
>Field('destination_number', length=30),
>Field('context',length=20),
>Field('start_stamp', datetime),
>Field('answer_stamp', datetime),
>Field('end_stamp',datetime),
>Field('duration','integer'),
>Field('billsec','integer'),
>Field('hangup_cause',length= 50),
>Field('accountcode',db.auth_ user),
>Field('read_codec',length=20),
>Field('write_codec',length=20) ,
>Field('cost', 'decimal(20,6)'),
>Field('carrier',length=255),
>Field('rate','decimal(11,5)'), format='%(caller_id_number)s', 
> migrate=False)
>
>
>
>
>
>
>
>On Thursday, September 4, 2014 4:34 AM, Niphlod  wrote:
>
>
>
>
>
>what's the table definition of db.cdr ?
>
>On Thursday, September 4, 2014 4:29:17 AM UTC+2, visuallinux wrote:
>Hi All.
>>
>>
>>I am trying to use SQLFORM.smartgrid:
>>
>>
>>query=(db.cdr.accountcode== form.vars.nombre[0])
>>grid=SQLFORM.smartgrid(db.cdr, constraints=dict(cdr=query), 
>>details=False,create=False, editable=False,deletable= False,csv=False)
>>
>>
>>But i received the follow exception:
>>
>>
>> 'module' object has no attribute 'split'
>>Versión
>>web2py™Version 2.9.5-stable+timestamp.2014. 03.16.02.35.39 
>>PythonPython 2.6.6: /usr/bin/python (prefix: /usr) 
>>Traceback
>>1.
>>2.
>>3.
>>4.
>>5.
>>6.
>>7.
>>8.
>>9.
>>10.
>>11.
>>12.
>>13.
>>14.
>>15.
>>16.
>>17.
>>18. Traceback (most recent call last):
>>File "/home/fvillarroel/www/web2py/ gluon/restricted.py", line 220, in 
>>restricted
>>exec ccode in environment
>>File "/home/fvillarroel/www/web2py/ applications/freeswitch/ 
>>controllers/repocallcltes.py", line 28, in 
>>File "/home/fvillarroel/www/web2py/ gluon/globals.py", line 385, in 
>>self._caller = lambda f: f()
>>File "/home/fvillarroel/www/web2py/ gluon/tools.py", line 3287, in f
>>return action(*a, **b)
>>File "/home/fvillarroel/www/web2py/ applications/freeswitch/ 
>>controllers/repocallcltes.py", line 12, in repocallcltes
>>grid=SQLFORM.smartgrid(db.cdr, constraints=dict(cdr=query),de 
>>tails=False,create=False,edita ble=False,deletable=False,csv=False)
>>File "/home/fvillarroel/www/web2py/ gluon/sqlhtml.py", line 2800, in smartgrid
>>user_signature=user_signature, **kwargs)
>>File "/home/fvillarroel/www/web2py/ gluon/sqlhtml.py", line 2255, in grid
>>search_menu = SQLFORM.search_menu(sfields, prefix=prefix)
>>File "/home/fvillarroel/www/web2py/ gluon/sqlhtml.py", line 1709, in 
>>search_menu
>>ftype = field.type.split(' ')[0]
>>AttributeError: 'module' object has no attribute 'split' 
>>
>>
>>I do not know what i am doing wrong and if i changed smartgrid for 
>>sqlform.grid i reveived the same error.
>>
>>
>>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
.

-- 
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] getting " [Errno 13] Permission denied" over and over

2014-09-04 Thread JorgeH
It's on Windows. The default user.

On Thursday, September 4, 2014 2:22:47 AM UTC-5, Johann Spies wrote:
>
> On 3 September 2014 23:31, JorgeH > wrote:
>
> I discovered that by cleaning errors, cache and sessions, its work again. 
>> But now Im getting the error like every other time I test.
>>
>> Any hints??
>>
>>
> Which user owns web2py/applications//models?
>
> Regards
> Johann
>
> -- 
> Because experiencing your loyal love is better than life itself, 
> my lips will praise you.  (Psalm 63:3)
>  

-- 
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] JSON response on auth.settings.on_failed_authentication with @request.restful()

2014-09-04 Thread Henry Nguyen
I have a method decorated with the following decorators:

@request.restful()
@auth.requires_login()


On an unauthenticated (non-logged-in) request, I get a 403 response with 
"Not authorized" in the response body, per default settings. I would like 
to be able to modify this response to be JSON. I've tried modifying the 
following auth.settings as follows:

def json_response():
import json
raise HTTP(403, json.dumps(dict(content='Not authorized')))

auth.settings.on_failed_authentication = json_response
auth.settings.on_failed_authorization = json_response


However, I continue to receive the "Not authorized" string in the response 
to the RESTful method instead of the JSON. Upon further digging, I found 
line 3448 in gluon/tools.py with the following:

elif self.settings.allow_basic_login_only or \
basic_accepted or current.request.is_restful:
raise HTTP(403, "Not authorized")


It seems like methods with the @request.restful() decorator simply cannot 
be overridden to return a custom response on unauthenticated requests, at 
least without modifying tools.py. Is this correct?

Thanks ahead of time for any 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.


[web2py] SQLFROM.grid sorting question

2014-09-04 Thread yamauchi shohei
Hello,

I'm new to web2py, and I just recently created a SQLFORM.grid that displays 
a grid very well.  I'm having an issue with Sorting though (out of the box).
My URL to this page contains a parameter (ID) like 
"~/sitename/controllername/id"
But the sorting does not include "id" in the URL so the page errors out.  

Is there a easy way to fix this?

-- 
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] Live preview, with COLT + Sublime Text, server config?

2014-09-04 Thread Jean-Paul McCoy
How can I use CodeOrchestraRPCHttpServer with Web2py? COLT live preview is 
all html and Java so it must be doable. The COLT server opens one port for 
itself then a second for the live coding session. Should I attempt to hack 
the COLT side to proxy through Rocket, or can I just get Web2py to 
recognize COLT?

-- 
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 AJAX to transfer json objects

2014-09-04 Thread Jason Solack

Hello everyone, I'm hoping someone might be able to provide an example of 
how to use the web2py ajax API to transfer json data from the server to the 
client side javascript.  

Any help would be appreciated!

Thank you 

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] Store a file using Crud

2014-09-04 Thread Manu Grandío
Hi!

I want to allow users to store files in my web application by both these 
methods:

   - By uploading the file from their hard drives
   - By providing a URL where the file is located. Then, there's no upload 
   and the controller downloads the file and inserts it in the database.

I know how to accomplish that with a FORM and a db.table.insert, however *I 
would like to use Crud if it's possible*. Here is a simplified version 
(without any error checking) of what I've tried:
# In models/db_documents.py
db.define_table('documents',
Field('name'),
Field('description'),
Field('url'),
Field('file_', 'upload'))

# In controllers/documents.py
import urllib2
from gluon.tools import Crud

def upload_document():
"""
Let users store files either by:
  - uploading the file, or
  - providing a URL where the file is located
"""
def download_document(form):
"""Download the file if the user provided a URL, and store it in
form.vars.file_
"""
if form.vars.url != '':
form.vars.file_ = urllib2.urlopen(form.vars.url) # Doesn't work

crud = Crud(db)
crud.settings.create_onvalidation.documents.append(download_document)
form = crud.create(db.documents, next='document_uploaded')
return {'form': form}


It works well in the first case, 'upload a file', but I don't know how to 
address the second case, 'provide a URL'. Specifically I don't know how to 
insert the file in the database after having downloaded it with urllib2. In 
the code you can see that I tried with:

form.vars.file_ = urllib2.urlopen(form.vars.url)

and it doesn't work. When the file is uploaded by the user (instead of 
providing a URL) I've seen that form.vars.file_ is an instance of 
FieldStorage. Probably that's why assigning a file-like object (the one 
returned by urllib2.urlopen) directly to form.vars.file_ doesn't work. Also 
I haven't found FieldStorage in the web2py documentation so probably it's 
an internal class and cannot create an instance myself. That makes me think 
maybe I cannot solve my problem with Crud.

Surprisingly, assigning a string to form.vars.file_ works in some way. I 
mean, doing:

form.vars.file_ = urllib2.urlopen(form.vars.url).read() # Assign a string

instead of:

form.vars.file_ = urllib2.urlopen(form.vars.url) # Assign a file-like object

web2py creates a text file named 'file.txt' and stores the content of the 
string in it. If there is a way to change the default 'file.txt' name I 
think I will be fine too. I want to preserve the original name and 
extension.

Cheers,

Manu

-- 
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] Extremely slow raw SQL queries on web2py

2014-09-04 Thread Mehmet A.


*db.executesql()* takes 30 seconds to return a result, despite the fact 
that same query takes 0.5-1 second if I try it on the MySQL console or with 
the same code on the web2py debug console or on the web2py shell.


I tried the following cases:

... #Irrelevant part of the code
raw_data = dbs.executesql(query, as_dict=True) #Takes 30 seconds to return a 
resultfrom gluon.debug import dbg
dbg.set_trace() #After this line, I'm on the debug console
raw_data = dbs.executesql(query, as_dict=True) #Takes <1 second to return a 
result
dbs._timings #print

dbs._timings #From the first test above
  [('SELECT 1;', 0.01632424926758), #web2py or driver stuff, I didn't 
execute it.
   ('SET FOREIGN_KEY_CHECKS=1;', 0.00348501586914), #web2py or driver 
stuff, I didn't execute it.
   ("SET sql_mode='NO_BACKSLASH_ESCAPES';", 0.00800013542175293), #web2py or 
driver stuff, I didn't execute it.
   ("SELECT TIMESTAMPDIFF(...) AS 'duration',\n
TIMESTAMPDIFF(...)\n
- INTERVAL 1 HOUR, TIMESTAMP(...)\n
+ INTERVAL CAST(...) AS 'timediff',\n
 ris.ODATE as 'date',\n
 CONCAT(...) as 'service'\n
FROM ... AS ris\n
JOIN ... as sd on ris = sd\n
WHERE ris != '-00-00 00:00:00'\n
  and ris != '-00-00 00:00:00'\n
  and ris >= '2010-8-15'\n
  and ris <= '2014-8-22'", 32.046038147), # Slow 
query/code, executed on page view.
 ("SELECT TIMESTAMPDIFF(...) AS 'duration',\n
 TIMESTAMPDIFF(...)\n
- INTERVAL 1 HOUR, TIMESTAMP(...)\n
+ INTERVAL CAST(...) AS 'timediff',\n
 ris.ODATE as 'date',\n
 CONCAT(...) as 'service'\n
FROM ... AS ris\n
JOIN ... as sd on ris = sd\n
WHERE ris != '-00-00 00:00:00'\n
  and ris != '-00-00 00:00:00'\n
  and ris >= '2010-8-15'\n
  and ris <= '2014-8-22'", 0.6069998741149902) #Same 
query/code, exec. on the debug console]

and

... #Irrelevant part of the codefrom gluon.debug import dbg
dbg.set_trace() #After this line, I'm on the debug console
raw_data = dbs.executesql(query, as_dict=True) #Takes <1 second to return a 
result

Things got interesting when I try to execute more queries consecutively:

... #Irrelevant part of the code
raw_data = dbs.executesql(query, as_dict=True) #Takes 7 seconds to return a 
result
raw_data = dbs.executesql(query, as_dict=True) #Takes 7 seconds to return a 
result
raw_data = dbs.executesql(query, as_dict=True) #Takes 7 seconds to return a 
resultfrom gluon.debug import dbg
dbg.set_trace() #After this line, I'm on the debug console
raw_data = dbs.executesql(query, as_dict=True) #Takes <1 second to return a 
result

on HeidiSQL

/* Affected rows: 0  Found rows: 7,391  Warnings: 0  Duration for 1 query: 
0.000 sec. (+ 0.078 sec. network) */

Also posted on stackoverflow 


-- 
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: JSON response on auth.settings.on_failed_authentication with @request.restful()

2014-09-04 Thread Leonel Câmara
Why? Why don't you simply analyse the HTTP return code where you're calling 
the API?

-- 
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: JSON response on auth.settings.on_failed_authentication with @request.restful()

2014-09-04 Thread Henry Nguyen
Primarily because I would like to display custom messages sent from the 
API, and I want them controllable from the API side. Specifically, our UI 
framework has a feature built in which allows us to display custom messages 
from the API by specifying the message characteristics in the response 
body. These characteristics need to be in JSON.

We can specify the messages on other authenticated requests and have them 
display fine, but we'd prefer to not have to make a custom case for 
handling this non-JSON unauthenticated request.

On Thursday, September 4, 2014 10:38:06 AM UTC-7, Leonel Câmara wrote:
>
> Why? Why don't you simply analyse the HTTP return code where you're 
> calling the API?
>

-- 
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: JSON response on auth.settings.on_failed_authentication with @request.restful()

2014-09-04 Thread Leonel Câmara
Ohh, in this case, instead of modifying tools.py I would drop the 
auth.requires_login() decorator and use auth.is_logged_in to check inside 
the function. Something like:


@request.restful()
def api():
def GET(*args,**vars):
return dict()
def POST(*args,**vars):
return dict()
def PUT(*args,**vars):
return dict()
def DELETE(*args,**vars):
return dict()

if not auth.is_logged_in():
raise HTTP(403, YOUR_JSON_ERROR)
return locals()



-- 
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: JSON response on auth.settings.on_failed_authentication with @request.restful()

2014-09-04 Thread Henry Nguyen
That is definitely a viable option... not as clean as the decorator but 
certainly functional. Thank you Leonel :)

Henry

On Thursday, September 4, 2014 11:17:47 AM UTC-7, Leonel Câmara wrote:
>
> Ohh, in this case, instead of modifying tools.py I would drop the 
> auth.requires_login() decorator and use auth.is_logged_in to check inside 
> the function. Something like:
>
>
> @request.restful()
> def api():
> def GET(*args,**vars):
> return dict()
> def POST(*args,**vars):
> return dict()
> def PUT(*args,**vars):
> return dict()
> def DELETE(*args,**vars):
> return dict()
> 
> if not auth.is_logged_in():
> raise HTTP(403, YOUR_JSON_ERROR)
> return locals()
>
>
>
>

-- 
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: JSON response on auth.settings.on_failed_authentication with @request.restful()

2014-09-04 Thread Henry Nguyen
Just for posterity's sake, I put the check into a custom decorator and used 
that new decorator instead:

def requires_login(function):

def check_is_logged_in(*args, **kwargs):
if not auth.is_logged_in():
raise HTTP(401, json.dumps(dict(content='Unauthorized.')))
return function(*args, **kwargs)

return check_is_logged_in


@request.restful()
@requires_login
def function():
...

Thanks again for the help, Leonel.

Henry


On Thursday, September 4, 2014 11:22:41 AM UTC-7, Henry Nguyen wrote:
>
> That is definitely a viable option... not as clean as the decorator but 
> certainly functional. Thank you Leonel :)
>
> Henry
>
> On Thursday, September 4, 2014 11:17:47 AM UTC-7, Leonel Câmara wrote:
>>
>> Ohh, in this case, instead of modifying tools.py I would drop the 
>> auth.requires_login() decorator and use auth.is_logged_in to check inside 
>> the function. Something like:
>>
>>
>> @request.restful()
>> def api():
>> def GET(*args,**vars):
>> return dict()
>> def POST(*args,**vars):
>> return dict()
>> def PUT(*args,**vars):
>> return dict()
>> def DELETE(*args,**vars):
>> return dict()
>> 
>> if not auth.is_logged_in():
>> raise HTTP(403, YOUR_JSON_ERROR)
>> return locals()
>>
>>
>>
>>

-- 
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 AJAX to transfer json objects

2014-09-04 Thread Niphlod

from gluon.serializers import json
def thebackend():
  thedict = dict(a=1, b=2)
  return json(thedict)



$.getJSON('/appname/default/thebackend', function(data) {console.log(data)})



On Thursday, September 4, 2014 3:52:01 PM UTC+2, Jason Solack wrote:
>
>
> Hello everyone, I'm hoping someone might be able to provide an example of 
> how to use the web2py ajax API to transfer json data from the server to the 
> client side javascript.  
>
> Any help would be appreciated!
>
> Thank you 
>
> 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] Geraldo Report

2014-09-04 Thread 'FERNANDO VILLARROEL' via web2py-users
Dear All.

Does anyone use Geraldo Report?

I am trying to use i follow the how to about web2py and Geraldo 
http://www.geraldoreports.org/docs/tutorial-2.html

But i received a empty pdf.

My code:

controllers/callscltes_pdf.py

def callcltes_pdf():

from reports import ReportPurchase
from geraldo.generators import PDFGenerator
import gluon.contenttype
import StringIO

r=int(request.args[0])
resp = StringIO.StringIO()

cal = db(db.cdr.accountcode==r).select(orderby=db.cdr.id)
report = ReportPurchase(queryset=cal)
report.generate_by(PDFGenerator, filename=resp)

resp.seek(0)
response.headers['Content-Type'] = gluon.contenttype.contenttype('.pdf')
filename = "%s_Purchases.pdf" % (request.env.server_name)
response.headers['Content-disposition'] = "attachment; filename=\"%s\"" 
% filename
return resp.read()

 modules/reports.py

from geraldo import Report

class ReportPurchase(Report):
title = 'Purchases list'
author = 'John Smith Corporation'

The query (db(db.cdr.accountcode==r).select(orderby=db.cdr.id)) returns 50 
tuples.

I appreciate some idea or help.

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] self-reference table IS_IN_DB and set

2014-09-04 Thread Richard
Hello,

I have a weird case where I need to make a self reference on a table but I 
need to filter out the list of table entries present in my drop down.

# Model
dummy_sub_select_set = db(db.dummy_table.field1 == True)  # Not working
dummy_sub_select_set = lambda: db(db.dummy_table.field1 == True)  # Not 
working either


db.define_table('dummy_table',

   Field('represent_field', ...),
   Field('field1', ...),
   Field('field2', 'reference dummy_table',
   requires=IS_IN_DB(dummy_sub_select_set, 
'dummy_table.id', '%(represent_field)s'),
   represent=lambda value, row: A(db.dummy_table
(id).represent_field,
 _href=URL(...))
   if id is not None else T(
'N/A'),
  ),


# This don't work either
db.define_table('dummy_table',

   Field('represent_field', ...),
   Field('field1', ...),
   Field('field2', 'reference dummy_table',
   requires=IS_IN_DB(db(db.dummy_table.field1 == 
True), 'dummy_table.id', '%(represent_field)s'),
   represent=lambda value, row: A(db.dummy_table
(id).represent_field,
 _href=URL(...))
   if id is not None else T(
'N/A'),
  ),


Is there a way to filter up the content of a "not already" define table 
with IS_IN_DB()?

Thanks

Richard

-- 
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] self-reference table IS_IN_DB and set

2014-09-04 Thread Derek
Just set that up after you define the table.

On Thursday, September 4, 2014 1:53:05 PM UTC-7, Richard wrote:
>
> Hello,
>
> I have a weird case where I need to make a self reference on a table but I 
> need to filter out the list of table entries present in my drop down.
>
> # Model
> dummy_sub_select_set = db(db.dummy_table.field1 == True)  # Not working
> dummy_sub_select_set = lambda: db(db.dummy_table.field1 == True)  # Not 
> working either
>
>
> db.define_table('dummy_table',
>
>Field('represent_field', ...),
>Field('field1', ...),
>Field('field2', 'reference dummy_table',
>requires=IS_IN_DB(dummy_sub_select_set, '
> dummy_table.id', '%(represent_field)s'),
>represent=lambda value, row: A(db.
> dummy_table(id).represent_field,
>  _href=URL(...))
>if id is not None else 
> T('N/A'),
>   ),
>
>
> # This don't work either
> db.define_table('dummy_table',
>
>Field('represent_field', ...),
>Field('field1', ...),
>Field('field2', 'reference dummy_table',
>requires=IS_IN_DB(db(db.dummy_table.field1 
> == True), 'dummy_table.id', '%(represent_field)s'),
>represent=lambda value, row: A(db.
> dummy_table(id).represent_field,
>  _href=URL(...))
>if id is not None else 
> T('N/A'),
>   ),
>
>
> Is there a way to filter up the content of a "not already" define table 
> with IS_IN_DB()?
>
> Thanks
>
> Richard
>

-- 
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] Is this still true about keyed tables?

2014-09-04 Thread Anthony
>From the book:


*Currently keyed tables are only supported for DB2, MS-SQL, Ingres and 
Informix, but others engines will be added.*

Aren't other engines supported now as well?

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.


Re: [web2py] getting " [Errno 13] Permission denied" over and over

2014-09-04 Thread JorgeH
It seems to have something to do with 


Traceback (most recent call last):
  File "/home/mdipierro/make_web2py/web2py/gluon/restricted.py", line 220, in 
restricted
  File "C:/web2py/applications/ZenuToolkit/models/zenu.py" 
, line 
133, in 
readable=False, writable =False),
  File "/home/mdipierro/make_web2py/web2py/gluon/dal.py", line 8223, in 
define_table
  File "/home/mdipierro/make_web2py/web2py/gluon/dal.py", line 8260, in 
lazy_define_table
  File "/home/mdipierro/make_web2py/web2py/gluon/dal.py", line 1132, in 
create_table
  File "/home/mdipierro/make_web2py/web2py/gluon/dal.py", line 1257, in 
migrate_table
  File "/home/mdipierro/make_web2py/web2py/gluon/dal.py", line 1265, in save_dbt
  File "/home/mdipierro/make_web2py/web2py/gluon/dal.py", line 793, in file_open
  File "/home/mdipierro/make_web2py/web2py/gluon/portalocker.py", line 122, in 
__init__
IOError: [Errno 13] Permission denied

Error snapshot [image: help] 

 

([Errno 13] Permission denied) 
the writable and readable permissions in the fields.

On Thursday, September 4, 2014 12:11:10 PM UTC-5, JorgeH wrote:
>
> It's on Windows. The default user.
>
> Sometimes it works and sometimes not.
>
>
>
> On Thursday, September 4, 2014 2:22:47 AM UTC-5, Johann Spies wrote:
>>
>> On 3 September 2014 23:31, JorgeH  wrote:
>>
>> I discovered that by cleaning errors, cache and sessions, its work again. 
>>> But now Im getting the error like every other time I test.
>>>
>>> Any hints??
>>>
>>>
>> Which user owns web2py/applications//models?
>>
>> Regards
>> Johann
>>
>> -- 
>> Because experiencing your loyal love is better than life itself, 
>> my lips will praise you.  (Psalm 63:3)
>>  
>

-- 
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 AJAX to transfer json objects

2014-09-04 Thread Jason Solack
That works!  Thank you very much

On Thursday, September 4, 2014 2:59:58 PM UTC-4, Niphlod wrote:
>
>
> from gluon.serializers import json
> def thebackend():
>   thedict = dict(a=1, b=2)
>   return json(thedict)
>
>
>
> $.getJSON('/appname/default/thebackend.json', function(data) 
> {console.log(data)})
>
>
>
> On Thursday, September 4, 2014 3:52:01 PM UTC+2, Jason Solack wrote:
>>
>>
>> Hello everyone, I'm hoping someone might be able to provide an example of 
>> how to use the web2py ajax API to transfer json data from the server to the 
>> client side javascript.  
>>
>> Any help would be appreciated!
>>
>> Thank you 
>>
>> 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] sqlform.grid default search value

2014-09-04 Thread Douglas Campbell
Is it possible to have a default search value in an sqlform.grid? I do not 
see the option in the docs and have not figured out a work around.

What I truly want to do is have the page JUST load the search bar and not 
the database results. Then once a search term is entered it shows the 
results in the sqlform.grid. I was going to just have a default search 
value when the page loads like "Enter_your_search_term_here" that would 
return no results from the database.

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: web2py list of dictionaries

2014-09-04 Thread trr
Thanks for the solution, Joe, Leonel, Stefaan. To continue, why should I 
create a new dictionary. My idea was to use one dictionary and populate it 
with all data. Will that not be more efficient? Thank you once again.

On Wednesday, September 3, 2014 5:15:40 PM UTC+5:30, trr wrote:
>
> In controller I create a list of dictionaries from an uploaded excel file. 
> Then I populate the list to a html table. I use xlrd lib for reading excel 
> file. The problem is the dictionary gets correctly populated from excel but 
> when I append the dictionary to the list and enumerate the list it shows 
> the last appended dictionary values for all the list items. Here is my 
> code. Pl. help. In python shell when i build a dictionary and append it to 
> list and then enumerate the list it is listed correctly.
> d = {}
> l = []
> up = os.path.join(request.folder,'uploads')
> workbook = xlrd.open_workbook(os.path.join(request.folder,'uploads',
> 'meas.xls'))
> worksheet = workbook.sheet_by_name('Sheet1')
> num_rows = worksheet.nrows - 1
> num_cells = worksheet.ncols - 1
> curr_row = -1
> while curr_row < num_rows:
> curr_row += 1
> row = worksheet.row(curr_row)
> #print 'Row:', curr_row
> curr_cell = -1
> while curr_cell < num_cells:
> curr_cell += 1
> # Cell Types: 0=Empty, 1=Text, 2=Number, 3=Date, 4=Boolean, 
> 5=Error, 6=Blank
> cell_type = worksheet.cell_type(curr_row, curr_cell)
> cell_value = worksheet.cell_value(curr_row, curr_cell)
> #print '', cell_type, ':', cell_value
> if curr_cell == 0:
> d['loc_of_work'] = cell_value
> if curr_cell == 1:
> d['n'] = cell_value
> if curr_cell == 2:
> d['t'] = cell_value
> if curr_cell == 3:
> d['l'] = cell_value
> if curr_cell == 4:
> d['b'] = cell_value
> if curr_cell == 5:
> d['d'] = cell_value
> print 'dict'
> print d.items()
> l.append(d)
> print 'len of list:'
> print len(l)
> print 'list:'
> for i,j in enumerate(l):
> print i,j
>
>
>

-- 
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] web2py 2.9.7 is OUT

2014-09-04 Thread Massimo Di Pierro
same as 2.9.6 except:

- a few more bug fixes
- sessions are stores in sessions/XX/YY/ subfolder to avoid proliferation 
of files under the same folder which causes slowdown
- cache.disk has been rewritten by Leonel and it much better.

-- 
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] self-reference table IS_IN_DB and set

2014-09-04 Thread Annet
What about :

def set_requirement(dummy_table): 
db.dummy_table.field2.requires=IS_IN_DB(..)

db.define_table('dummy_table',
Field(...),
Field(...),
on_define = set_requirement)


Kind regards,

Annet

-- 
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: Extremely slow raw SQL queries on web2py

2014-09-04 Thread Massimo Di Pierro
Very strange. What do you think is causing this?

On Wednesday, 3 September 2014 09:44:17 UTC-5, Mehmet A. wrote:
>
> *db.executesql()* takes 30 seconds to return a result, despite the fact 
> that same query takes 0.5-1 second if I try it on the MySQL console or with 
> the same code on the web2py debug console or on the web2py shell.
>
>
> I tried the following cases:
>
> ... #Irrelevant part of the code
> raw_data = dbs.executesql(query, as_dict=True) #Takes 30 seconds to return a 
> resultfrom gluon.debug import dbg
> dbg.set_trace() #After this line, I'm on the debug console
> raw_data = dbs.executesql(query, as_dict=True) #Takes <1 second to return a 
> result
> dbs._timings #print
>
> dbs._timings #From the first test above
>   [('SELECT 1;', 0.01632424926758), #web2py or driver stuff, I didn't 
> execute it.
>('SET FOREIGN_KEY_CHECKS=1;', 0.00348501586914), #web2py or driver 
> stuff, I didn't execute it.
>("SET sql_mode='NO_BACKSLASH_ESCAPES';", 0.00800013542175293), #web2py or 
> driver stuff, I didn't execute it.
>("SELECT TIMESTAMPDIFF(...) AS 'duration',\n
> TIMESTAMPDIFF(...)\n
> - INTERVAL 1 HOUR, TIMESTAMP(...)\n
> + INTERVAL CAST(...) AS 'timediff',\n
>  ris.ODATE as 'date',\n
>  CONCAT(...) as 'service'\n
> FROM ... AS ris\n
> JOIN ... as sd on ris = sd\n
> WHERE ris != '-00-00 00:00:00'\n
>   and ris != '-00-00 00:00:00'\n
>   and ris >= '2010-8-15'\n
>   and ris <= '2014-8-22'", 32.046038147), # Slow 
> query/code, executed on page view.
>  ("SELECT TIMESTAMPDIFF(...) AS 'duration',\n
>  TIMESTAMPDIFF(...)\n
> - INTERVAL 1 HOUR, TIMESTAMP(...)\n
> + INTERVAL CAST(...) AS 'timediff',\n
>  ris.ODATE as 'date',\n
>  CONCAT(...) as 'service'\n
> FROM ... AS ris\n
> JOIN ... as sd on ris = sd\n
> WHERE ris != '-00-00 00:00:00'\n
>   and ris != '-00-00 00:00:00'\n
>   and ris >= '2010-8-15'\n
>   and ris <= '2014-8-22'", 0.6069998741149902) #Same 
> query/code, exec. on the debug console]
>
> and
>
> ... #Irrelevant part of the codefrom gluon.debug import dbg
> dbg.set_trace() #After this line, I'm on the debug console
> raw_data = dbs.executesql(query, as_dict=True) #Takes <1 second to return a 
> result
>
> Things got interesting when I try to execute more queries consecutively:
>
> ... #Irrelevant part of the code
> raw_data = dbs.executesql(query, as_dict=True) #Takes 7 seconds to return a 
> result
> raw_data = dbs.executesql(query, as_dict=True) #Takes 7 seconds to return a 
> result
> raw_data = dbs.executesql(query, as_dict=True) #Takes 7 seconds to return a 
> resultfrom gluon.debug import dbg
> dbg.set_trace() #After this line, I'm on the debug console
> raw_data = dbs.executesql(query, as_dict=True) #Takes <1 second to return a 
> result
>
> on HeidiSQL
>
> /* Affected rows: 0  Found rows: 7,391  Warnings: 0  Duration for 1 query: 
> 0.000 sec. (+ 0.078 sec. network) */
>
> Also posted on stackoverflow 
> 
>
>

-- 
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: 2.9.6 broke custom view template delimiters

2014-09-04 Thread Massimo Di Pierro
posted in 2.9.7. Thank you. :-)

On Thursday, 4 September 2014 06:02:59 UTC-5, Jonathan New wrote:
>
> Hi Massimo,
>
> I had sent a pull request proposing changes to lines 282-290 to 
>
> if delimiters != self.default_delimiters:
> escaped_delimiters = (escape(delimiters[0]),
>   escape(delimiters[1]))
> self.r_tag = compile(r'(%s.*?%s)' % escaped_delimiters, DOTALL)
> elif hasattr(context.get('response', None), 'delimiters'):
> if context['response'].delimiters != self.default_delimiters:
> delimiters = context['response'].delimiters
> escaped_delimiters = (
> escape(delimiters[0]),
> escape(delimiters[1]))
> self.r_tag = compile(r'(%s.*?%s)' % escaped_delimiters,
>  DOTALL)
>
>
> On Thursday, September 4, 2014 6:48:13 PM UTC+8, Jonathan New wrote:
>>
>> Unfortunately, the latest patch (Version 
>> 2.9.6-stable+timestamp.2014.09.02.01.57.55) doesn't solve the problem.
>>
>> line 282:
>> if delimiters is None:
>> delimiters = context.get('response', {})\
>> .get('app_settings',{}).get('template_delimiters')
>>
>> However, delimiters will never be None. It will always have the default 
>> value of ('{{', '}}')
>>
>>
>> The pre-2.9.6 code works because line 286 checks for existence of 
>> response.delimiter:
>>
>> if delimiters != self.default_delimiters:
>> escaped_delimiters = (escape(delimiters[0]),
>>   escape(delimiters[1]))
>> self.r_tag = compile(r'(%s.*?%s)' % escaped_delimiters, 
>> DOTALL)
>> el*if hasattr(context.get('response', None), 'delimiters')*:
>> if context['response'].delimiters != self.default_delimiters:
>> escaped_delimiters = (
>> escape(context['response'].delimiters[0]),
>> escape(context['response'].delimiters[1]))
>> self.r_tag = compile(r'(%s.*?%s)' % escaped_delimiters,
>>  DOTALL)
>>
>>
>>
>> On Wednesday, September 3, 2014 9:29:50 PM UTC+8, Massimo Di Pierro wrote:
>>>
>>> This will be fixed today with a new emergency release.
>>>
>>> On Wednesday, 3 September 2014 05:02:15 UTC-5, Jonathan New wrote:

 In prior web2py versions, we can change the template delimiters by 
 response.delimiters 
 = ('')

 With 2.9.6, gluon/template.py in lines 282-290 were changed such that 
 response.delimiters doesn't work. 
 I tried response.app_settings = {'template_delimiters': ('')}  
 which the new code seems to refer to, also doesn't work

 BTW, line 286 also have typo error: escaped_delimiters = (escape(
 elimiters[0])




-- 
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: Version 2.9.6 indeed breaks backward compat for some users

2014-09-04 Thread Massimo Di Pierro
I do not like this. Should we put to a vote the default behavior of 
db(...).like(...)? the thing is whatever we do will behave differently than 
before on different databases.


On Wednesday, 3 September 2014 11:11:27 UTC-5, Anthony wrote:
>
> On Wednesday, September 3, 2014 9:37:24 AM UTC-4, Massimo Di Pierro wrote:
>>
>> Hello Joe,
>>
>> yes we made this change. The problem is that its previous behavior was 
>> undetermined and was different across databases. So we treated it like a 
>> bug. 
>> LIKE is supposed to be case sensitive so we made sure like(...) is also 
>> case sensitive consistently across supported databases (or so we think). 
>> You can change that behavior:
>>
>> like(..., case_sensitive=False)
>>
> I wonder if we should add an option to set that database-wide -- something 
> like DAL(..., case_sensitive_like=False).
>
> Also, should .startswith and .endswith have a case sensitive option?
>
> 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: Is this still true about keyed tables?

2014-09-04 Thread Massimo Di Pierro
I do not recall adding support for other databases.

On Thursday, 4 September 2014 16:56:02 UTC-5, Anthony wrote:
>
> From the book:
>
>
> *Currently keyed tables are only supported for DB2, MS-SQL, Ingres and 
> Informix, but others engines will be added.*
>
> Aren't other engines supported now as well?
>
> 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: web2py setup scripts for windows

2014-09-04 Thread Massimo Di Pierro
Is your point that we should not use these script or that we should not 
provide scripts for windows at all?
In the first case, what would you change? In the second case, why not?



On Wednesday, 3 September 2014 10:11:29 UTC-5, Niphlod wrote:
>
> hell no. I don't want 7-zip installed by web2py. and an old FIXED build of 
> apache. And a FIXED version of python. Without checks.
> And Apache. On Windows. 
> No, No, No, No to the "setup scripts for windows" archive.
> The configuration is fixed, old, and a poor duplicate of the ones we still 
> have in automated scripts.
>
> On Wednesday, September 3, 2014 3:29:04 PM UTC+2, Massimo Di Pierro wrote:
>>
>> Yes. I will add them. Thank you!
>>
>> On Tuesday, 2 September 2014 19:28:58 UTC-5, 黄祥 wrote:
>>>
>>> dear all,
>>>
>>> just want to share web2py setup scripts for windows (tested on windows 7 
>>> ultimate 64 bit).
>>> hopefully it can be added on web2py/scripts in the future release.
>>>
>>> thanks and 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.