[web2py] Re: using before and after update callback simultaneously on the same table

2017-08-18 Thread 黄祥
thanks leonel for the hints, find the solution with update_naive, because 
the logic for the real code is to recalculate the order table when it's 
update
e.g. use update_naive
def __after_update_order(s, f):
if not ('is_active' in f and f['is_active'] == False):
s.update_naive(notes = 'test')

from the book
For this purpose there the Set objects have an update_naive method that 
works like update but ignores before and after callbacks.

is there any side effect for this? tested it works smoothly, perhaps i can 
use compute function for that

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.


[web2py] Re: troubles with scheduler

2017-08-18 Thread Dave S


On Friday, August 18, 2017 at 2:37:46 AM UTC-7, Mirek Zvolský wrote:
[... useful info elided ...] 

> So the evil is to let the pg8000-obsolete in contrib/ in current Web2py 
> release.This should change:
> - or update Web2py release to current pg8000,
> - or remove the pg8000 from Web2py release completely
>
> I made yesterday Issues for updating pg8000 in Web2py release. I still 
> think that this would be a good step.
>

The trick to the contrib directory is making sure that the contributions 
don't get orphaned  :-(

Some things  have been moved out of contrib in gluon proper, in order to 
make sure an important piece is maintained.  I don't remember, though, what 
the recent examples were (other than Niphlod's JWT work, now in tools.py).

/dps



-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [web2py] Re: book help

2017-08-18 Thread Dave S


On Thursday, August 17, 2017 at 6:02:31 AM UTC-7, Richard wrote:
>
> No... Hmm... Use Github oneline, you should have button beside your branch 
> like "Create a PR" or something like that... It weird that you github 
> desktop porpose you to create a PR against you own repo... I guess your 
> setup is not properly done... Is your local copy a clone of you own repo or 
> a clone of the massimo's book repo??
>


I set up my environment following githubs recommendations:  fork the 
official repo [making a repo on gethub] and then checking out local copies 
from that.  Two previous times, the resulting PR went to the right place.  
This time, while trying to get sync'd, I manage to confuse myself, and when 
I pressed the PR button the desktopapp was pointing at my fork.  An 
interesting footnote is that in the description, I mentioned the issue 
number, and the issue tracker in the official repo reports that I did.

/dps


-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


{Disarmed} Re: {Disarmed} [web2py] Re: pytest and controllers protected with auth

2017-08-18 Thread Carlos Cesar Caballero Díaz
I have been facing with that issue too, the error is because there are 
no logged in user, and the redirect is raised, the main problem with 
this approach is that I have been not able to correctly log in a user...


Being honest, I haven't found a satisfactory way for testing web2py 
applications.


Greetings.


El 18/08/17 a las 13:11, António Ramos escribió:

anybody help  please ?
regards

2017-08-18 15:20 GMT+01:00 António Ramos >:


this does not work.
*
*
*@auth.requires(True, requires_login=  request.is_local)*
def execdal():
return dict(ret=1)


my pytest function
def test_execdal(web2py):
result = web2py.run('default', 'execdal', web2py)


i get an error about redirected
Imagem inline 1

2017-08-18 12:46 GMT+01:00 António Ramos >:

Hello i+m testing a controller with pytest

if my controller is protected like

@auth.requires.login or @auth.requires_membership how can i
test it ?


def test_controller(client):


client.get('/default/controller')
...
...


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 *MailScanner ha detectado un intento de fraude 
en la siguiente p�gina web "groups.google.com". /No/ conf�e en esta 
p�gina web:* https://groups.google.com/d/optout 
.


--
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups "web2py-users" group.

To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[web2py] Re: auth_cas redis session_filename + logout issue

2017-08-18 Thread Mark Graves
On deeper inspection, the logout issue is strange, and related to the redis 
sessions.

auth.settings.login_form.cas_logout_url


is the right URL.  If I visit it independently in a browser it works as 
expected. 

However, there are no auth_users created in the cas_consumer app when redis 
sessions are used.  They are created when redis sessions are not used.

Is that expected behavior?  It strikes me as a misconfiguration issue.

On Friday, August 18, 2017 at 12:22:40 AM UTC-5, Mark Graves wrote:
>
> Hey everyone,  
>
> Question / potential bug(s):
>
> I created the following to reproduce:
>
> https://bitbucket.org/MarkGraves/web2py_cas
>
> Basically, when I run that setup.sh, it sets up two apps and installs 
> redis in virtual environments, copies in web2py, and replaces db.py with 
> the one in the main repo.
>
> Its the only file that has changed from a default web2py setup.
>
> The odd thing is that when I run these apps, the consumer app sets 
> response.session_file to None, and has a response.session_filename
>
> The file does not exist after a single request.  It may at some point 
> during the request (easy enough to check).
>
> It does not appear to have the same effect on the cas_provider app, at 
> least via the output (neither is a key in response object)
>
> I think this is around 883 but not sure, in 
> https://github.com/web2py/web2py/blob/master/gluon/globals.py
>
> There are distinctly two times that response.session_filename gets called 
> in that file only for the consumer app. I figured that out by logging to 
> console around every call.
>
> I don't know if thats intentional, or a bug.
>
> The second part however, may be related to setup.
>
> I can logout from the session via the provider app, but attempting to 
> logout via the consumer app gives me a foreign key error. didnt have time 
> to jump into the generation of logout url.
>
> Thoughts?
>

-- 
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: pytest and controllers protected with auth

2017-08-18 Thread António Ramos
anybody help  please ?
regards

2017-08-18 15:20 GMT+01:00 António Ramos :

> this does not work.
>
> *@auth.requires(True, requires_login=  request.is_local)*
> def execdal():
> return dict(ret=1)
>
>
> my pytest function
> def test_execdal(web2py):
> result = web2py.run('default', 'execdal', web2py)
>
>
> i get an error about redirected
> [image: Imagem inline 1]
>
> 2017-08-18 12:46 GMT+01:00 António Ramos :
>
>> Hello i+m testing a controller with pytest
>>
>> if my controller is protected like
>>
>> @auth.requires.login or @auth.requires_membership how can i test it ?
>>
>>
>> def test_controller(client):
>>
>>
>> client.get('/default/controller')
>> ...
>> ...
>>
>>
>> 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: pytest and controllers protected with auth

2017-08-18 Thread António Ramos
this does not work.

*@auth.requires(True, requires_login=  request.is_local)*
def execdal():
return dict(ret=1)


my pytest function
def test_execdal(web2py):
result = web2py.run('default', 'execdal', web2py)


i get an error about redirected
[image: Imagem inline 1]

2017-08-18 12:46 GMT+01:00 António Ramos :

> Hello i+m testing a controller with pytest
>
> if my controller is protected like
>
> @auth.requires.login or @auth.requires_membership how can i test it ?
>
>
> def test_controller(client):
>
>
> client.get('/default/controller')
> ...
> ...
>
>
> 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: Datatables Query String Parsing

2017-08-18 Thread Val K
Hi, I did something  similar that what are looking for  
jq_param2storage_w2p.py 


usage in controller:
paresd_vars = jq_param_w2p(request.body) 



On Thursday, July 27, 2017 at 5:01:13 PM UTC+3, villas wrote:
>
> Is there an simple way to parse this into an easier-to-work-with object.  
> I mean for example 'columns' could be a list.
>
> {'columns[0][data]': 'first_name',
>  'columns[0][name]': '',
>  'columns[0][orderable]': 'true',
>  'columns[0][search][regex]': 'false',
>  'columns[0][search][value]': '',
>  'columns[0][searchable]': 'true',
>  'columns[1][data]': 'last_name',
>  'columns[1][name]': '',
>  'columns[1][orderable]': 'true',
>  'columns[1][search][regex]': 'false',
>  'columns[1][search][value]': '',
>  'columns[1][searchable]': 'true',
>  'draw': '1',
>  'length': '2',
>  'order[0][column]': '0',
>  'order[0][dir]': 'asc',
>  'search[regex]': 'false',
>  'search[value]': '',
>  'start': '0'}
>
> BTW this is from a Datatables post request for creating server-side sql 
> queries.  Maybe someone has already figured this out.  I'm just trying to 
> save time in creating a web2py query.
>
> Many 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] change_password validator

2017-08-18 Thread tomasz bandura
Hello,

For the user registration I use just default validator (IS_STRONG) which
has defined only minimum lenght (4).

The problem is during password changing (form=auth() -->
default/user/change_password) - validator is ignored and I can set password
with length=1

 Should I set a validator separately?

There is also parameter 'auth.settings.change_password_onvalidation' but it
hasn't any impact on changing pass action.


Regards,
Tomasz

-- 
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] pytest and controllers protected with auth

2017-08-18 Thread António Ramos
Hello i+m testing a controller with pytest

if my controller is protected like

@auth.requires.login or @auth.requires_membership how can i test it ?


def test_controller(client):


client.get('/default/controller')
...
...


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: cx_Oracle 6.0

2017-08-18 Thread Вячеслав Анатольевич
Thanks, Leonel! It works!

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

2017-08-18 Thread Leonel Câmara
Nope, that's caused by the new entity quoting in the DAL. Use 
entity_quoting=False in your DAL call.

-- 
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] cx_Oracle 6.0

2017-08-18 Thread Вячеслав Анатольевич
Hi everyone!

Actually the question on the topic! Do you need changes to pydal or we2py 
due to the release of cx_Oracle 6.0? Release web2py 2.15.3 took place a 
week earlier than cx_Oracle 6.0. I ask - because it creates parallel tables 
with already existing only with a small (or large) letter, when I it define.
For example, have a table 'MAIN', in models - define_table('main') after 
ugrate to 6.0 - it creates one more table - 'main'
Previously, this was not.
Maybe stupid question..

-- 
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: troubles with scheduler

2017-08-18 Thread Mirek Zvolský
I have on development machine: psycopg2,pg8000 - psycopg2 accidentally from 
other project.
On production I have the standard Web2py installation only --> and this 
means: pg8000-obsolete.

I run scheduler task for import (about 3 records in central table + 
some smaller related tables).

I can read from 3rd party tests, that pg8000 is 3-times slower than 
psycopg2, however:

With pg8000-obsolete the time of import could be about 30 mins, but the 
import failed always.
With pg8000-current the import works and the time is about 17 mins.
With psycopg2 15 mins.

The times are not exact, because it is not standalone machine, but a VPS in 
Forpsi cloud.
However it looks so, that psycopg2 and pg8000-current works similar well 
here.

So the evil is to let the pg8000-obsolete in contrib/ in current Web2py 
release.
This should change:
- or update Web2py release to current pg8000,
- or remove the pg8000 from Web2py release completely

I made yesterday Issues for updating pg8000 in Web2py release. I still 
think that this would be a good step.





Dne čtvrtek 17. srpna 2017 21:15:25 UTC+2 Dave S napsal(a):
>
>
>
> On Thursday, August 17, 2017 at 4:59:10 AM UTC-7, Mirek Zvolský wrote:
>>
>> I think reason is the too old contrib/pg8000 driver.
>> It is something like listed here (pg8000+web2py): 
>> https://github.com/mfenniak/pg8000/issues/73
>> I have installed the current one pg8000 and it looks well, without or 
>> with scheduler.
>>
>>
> In general, pg8000 is deprecated.
> The recommended driver is psycopg2.
>
> 
>
> /dps
>
>  
>

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[web2py] Re: using before and after update callback simultaneously on the same table

2017-08-18 Thread Leonel Câmara
It's possible, but not if they're doing what yours are.

Namely the problem here is not that you have a before and after update 
callback. The problem is your __after_update_order. Your 
__after_update_order updates table *order* which triggers 
__after_update_order again. This would be ok if you had a condition that 
would terminate the recursion which you don't,  

Lets see what happens when s.update(notes='test') runs. This is an update 
where 'is_active' is not in *f* so it will trigger s.update(notes='test') 
again. And again. And again.  

-- 
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 before and after update callback simultaneously on the same table

2017-08-18 Thread 黄祥
is it possible to using before and after update callback simultaneously on 
the same table? tested before but got an error traceback
*e.g.*
def __before_update_order(s, f):
query = (db.product.id == 1)
db(query).update(quantity = 9)

def __after_update_order(s, f):
if not ('is_active' in f and f['is_active'] == False):
s.update(notes = 'test')

db.order._before_update.append(__before_update_order)
db.order._after_update.append(__after_update_order)

*return an error traceback :*
RuntimeError: maximum recursion depth exceeded while calling a Python object

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.