[web2py] Re: scheduler gives and error about datetime

2020-06-29 Thread Pierre
For a temporary solution, i made an external python prg and used cron on my 
pi to sync the databases everynight and works find with sqlite syntax.
It's way more extensive work but seems to be reliable for many days now.
I have read again the doc, and cannot figure out at all my mistake.
At this time i scheduled manualy the task via the admin interface to do 
tests, so i can follow the stage, queued, running, etc.
thanks

Le mercredi 24 juin 2020 23:01:27 UTC-4, Dave S a écrit :
>
>
>
> On Wednesday, June 17, 2020 at 6:41:32 AM UTC-7, Pierre wrote:
>>
>> Gooday,
>> In the controler the function works correctly.  But as a task, it gives 
>> an error about Json not beeing able to deal with datetime.
>> any suggestion would be appreciated :)
>>
>> here is the error :  TypeError: datetime.datetime(2020, 6, 16, 5, 17, 49) 
>> is not JSON serializable
>>
>>
> This does not look right:
>  
>
>> from gluon.scheduler import Scheduler
>>
>> Scheduler(db,dict(sync_data=pump_most_recent,sync_dates=acue_src_dst_update))
>>
>>  
> In a models file called scheduler.py, I have:
>
>
> from gluon.scheduler import Scheduler
>
> scheduler = Scheduler(db)
>
>
> def taskfunc(arg1, arg2):
>   var1 = do_something(arg1)
>   if var1 in arg2:
>return "success"
>
>
> In a controller, I kick off the task with 
>
> chunk1 = dostuff(request.args[0])
> string1 =  targets[rand()]
> tid = scheduler.queue_task('taskfunc', pvars={'arg1': chunk1, 'arg2': 
> string2}, timeout=1200)
>
> (the controller knows scheduler from the models)
>
> Sending a date as an argument would be done by using a pvars dictionary in 
> the same way.   For one of my tasks, I send a datetime via pvars.   The 
> task also has a request.now.  (It has the whole request, but you can tell 
> it's a scheduler request).
>
> Do you find the documentation on Scheduler unclear?
>
> /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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/web2py/38baa4e9-9942-4faf-bc57-4e12d59051beo%40googlegroups.com.


Re: [web2py] scheduler gives and error about datetime

2020-06-23 Thread Pierre
I advance like you by trying tons of things :)
I did the most simple thing with the task  just putting a = 
datetime.datetime.now()  and it gives the exact same error.
Tasks doesn't like datetime period :)
Not yet figured out how to jsonify the task yet based on your suggestion, 
but still bumping my head on it :)


Le lundi 22 juin 2020 23:56:07 UTC-4, AGRogers a écrit :
>
> Yeah, i dont really understand how web2py sends locals() etc back to the 
> view and how that differs from JSON data. I just keep trying random things 
> until it works :)
>
> On Tue, 23 Jun 2020 at 12:15, Pierre > 
> wrote:
>
>> thanks AG  I will look into your suggestion.
>> Fiddling with the error, found out that it's when reading back from 
>> sqlite that the error arise.  It's like something from web2py doesn't like 
>> the format of my date in the field of the table.
>> But at this time, i do not know how to tell "web2py" that the string 
>> representing the datetime in the field is formated like this  '%Y-%m-%d : 
>> %H:%M:%S'
>> wonder if the datetime format used in my sqlite table field is the 
>> problem.   So curius that everything works fine in the controler but not as 
>> a task.
>>
>> Le lundi 22 juin 2020 20:54:34 UTC-4, AGRogers a écrit :
>>>
>>> Hi
>>>
>>> I use this code to solve this problem:
>>>
>>> result = json.dumps(result, indent=4, sort_keys=True, default=str)
>>>
>>> Don't know what it does but it solves my problem.
>>>
>>> I found it here:
>>>
>>> https://stackoverflow.com/questions/11875770/how-to-overcome-datetime-datetime-not-json-serializable
>>>   
>>>
>>>
>>>
>>> On Wed, 17 Jun 2020 at 23:41, Pierre  wrote:
>>>
>>>> Gooday,
>>>> In the controler the function works correctly.  But as a task, it gives 
>>>> an error about Json not beeing able to deal with datetime.
>>>> any suggestion would be appreciated :)
>>>>
>>>> here is the error :  TypeError: datetime.datetime(2020, 6, 16, 5, 17, 
>>>> 49) is not JSON serializable
>>>>
>>>> here is the code:
>>>>
>>>> #reload(sys)
>>>> #sys.setdefaultencoding('utf-8')
>>>> import sys
>>>> import os
>>>> import time
>>>> import datetime
>>>> import sqlite3
>>>> #
>>>>
>>>> #--
>>>> def pump_most_recent():
>>>> state = 'unknown'
>>>> try:
>>>> conn=sqlite3.connect('z:/alarm.sqlite')
>>>> except sqlite3.Error as err:
>>>> state = err # ='connexion impossible'
>>>> else:
>>>> state = 'connection ok'
>>>> #   last entry in the local storage is kept in the acue table, have 
>>>> to get this in order to query the prod databases
>>>> k = db(db.acue).select(db.acue.dstd2) # get the row
>>>> l = k[0].dstd2# get the date of interest
>>>> curs=conn.cursor()
>>>> rows = curs.execute("select * from log_txt where date > ?", 
>>>> (l,)).fetchall()
>>>> curs.close()
>>>> conn.close()
>>>> #
>>>> for row in rows:
>>>> a = datetime.datetime.strptime(row[1],'%Y-%m-%d : 
>>>> %H:%M:%S') # date avec le temps
>>>> b = row[2]
>>>> c = row[3]
>>>> d = row[4]
>>>> e = row[5]
>>>> f = row[6]
>>>> g = row[7]
>>>> h = row[8]
>>>> i = row[9]
>>>> j = row[10]
>>>> #
>>>> 
>>>> db.alogs.insert(quand=a,etat=b,zone1=c,zone2=d,zone3=e,zone4=f,zone5=g,zone6=h,zone7=i,note=j)
>>>> finally:
>>>> return locals()
>>>> #
>>>>
>>>> #---
>>>> #
>>>> def acue_src_dst_update():
>>>> #
>>>> z = acue_src_dst_show()
>>>> a = z.get('a')
>>>> b = z.get('b')
>>>> c = z.get('c')
>>>> d = z.get('d')
>>>> #
>>>> db.acue.truncate()
>>>> db.acu

Re: [web2py] scheduler gives and error about datetime

2020-06-22 Thread Pierre
thanks AG  I will look into your suggestion.
Fiddling with the error, found out that it's when reading back from sqlite 
that the error arise.  It's like something from web2py doesn't like the 
format of my date in the field of the table.
But at this time, i do not know how to tell "web2py" that the string 
representing the datetime in the field is formated like this  '%Y-%m-%d : 
%H:%M:%S'
wonder if the datetime format used in my sqlite table field is the 
problem.   So curius that everything works fine in the controler but not as 
a task.

Le lundi 22 juin 2020 20:54:34 UTC-4, AGRogers a écrit :
>
> Hi
>
> I use this code to solve this problem:
>
> result = json.dumps(result, indent=4, sort_keys=True, default=str)
>
> Don't know what it does but it solves my problem.
>
> I found it here:
>
> https://stackoverflow.com/questions/11875770/how-to-overcome-datetime-datetime-not-json-serializable
>   
>
>
>
> On Wed, 17 Jun 2020 at 23:41, Pierre > 
> wrote:
>
>> Gooday,
>> In the controler the function works correctly.  But as a task, it gives 
>> an error about Json not beeing able to deal with datetime.
>> any suggestion would be appreciated :)
>>
>> here is the error :  TypeError: datetime.datetime(2020, 6, 16, 5, 17, 49) 
>> is not JSON serializable
>>
>> here is the code:
>>
>> #reload(sys)
>> #sys.setdefaultencoding('utf-8')
>> import sys
>> import os
>> import time
>> import datetime
>> import sqlite3
>> #
>>
>> #--
>> def pump_most_recent():
>> state = 'unknown'
>> try:
>> conn=sqlite3.connect('z:/alarm.sqlite')
>> except sqlite3.Error as err:
>> state = err # ='connexion impossible'
>> else:
>> state = 'connection ok'
>> #   last entry in the local storage is kept in the acue table, have 
>> to get this in order to query the prod databases
>> k = db(db.acue).select(db.acue.dstd2) # get the row
>> l = k[0].dstd2# get the date of interest
>> curs=conn.cursor()
>> rows = curs.execute("select * from log_txt where date > ?", 
>> (l,)).fetchall()
>> curs.close()
>> conn.close()
>> #
>> for row in rows:
>> a = datetime.datetime.strptime(row[1],'%Y-%m-%d : %H:%M:%S') 
>> # date avec le temps
>> b = row[2]
>> c = row[3]
>> d = row[4]
>> e = row[5]
>> f = row[6]
>> g = row[7]
>> h = row[8]
>> i = row[9]
>> j = row[10]
>> #
>> 
>> db.alogs.insert(quand=a,etat=b,zone1=c,zone2=d,zone3=e,zone4=f,zone5=g,zone6=h,zone7=i,note=j)
>> finally:
>> return locals()
>> #
>>
>> #---
>> #
>> def acue_src_dst_update():
>> #
>> z = acue_src_dst_show()
>> a = z.get('a')
>> b = z.get('b')
>> c = z.get('c')
>> d = z.get('d')
>> #
>> db.acue.truncate()
>> db.acue.insert(srcd1=a,srcd2=b,dstd1=c, dstd2=d)
>> acue_after_update = db(db.acue).select()
>> #
>> return locals()
>>
>> #--
>> from gluon.scheduler import Scheduler
>>
>> Scheduler(db,dict(sync_data=pump_most_recent,sync_dates=acue_src_dst_update))
>>
>> -- 
>> Resources:
>> - http://web2py.com
>> - http://web2py.com/book (Documentation)
>> - http://github.com/web2py/web2py (Source code)
>> - https://code.google.com/p/web2py/issues/list (Report Issues)
>> --- 
>> You received this message because you are subscribed to the Google Groups 
>> "web2py-users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to web...@googlegroups.com .
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/web2py/ba7a30ef-1e82-430e-8295-8fd4be74c806o%40googlegroups.com
>>  
>> <https://groups.google.com/d/msgid/web2py/ba7a30ef-1e82-430e-8295-8fd4be74c806o%40googlegroups.com?utm_medium=email_source=footer>
>> .
>>
>

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/web2py/b9332712-6352-4a98-a051-71149d83f134o%40googlegroups.com.


[web2py] scheduler gives and error about datetime

2020-06-17 Thread Pierre
Gooday,
In the controler the function works correctly.  But as a task, it gives an 
error about Json not beeing able to deal with datetime.
any suggestion would be appreciated :)

here is the error :  TypeError: datetime.datetime(2020, 6, 16, 5, 17, 49) 
is not JSON serializable

here is the code:

#reload(sys)
#sys.setdefaultencoding('utf-8')
import sys
import os
import time
import datetime
import sqlite3
#
#--
def pump_most_recent():
state = 'unknown'
try:
conn=sqlite3.connect('z:/alarm.sqlite')
except sqlite3.Error as err:
state = err # ='connexion impossible'
else:
state = 'connection ok'
#   last entry in the local storage is kept in the acue table, have to 
get this in order to query the prod databases
k = db(db.acue).select(db.acue.dstd2) # get the row
l = k[0].dstd2# get the date of interest
curs=conn.cursor()
rows = curs.execute("select * from log_txt where date > ?", 
(l,)).fetchall()
curs.close()
conn.close()
#
for row in rows:
a = datetime.datetime.strptime(row[1],'%Y-%m-%d : %H:%M:%S') # 
date avec le temps
b = row[2]
c = row[3]
d = row[4]
e = row[5]
f = row[6]
g = row[7]
h = row[8]
i = row[9]
j = row[10]
#

db.alogs.insert(quand=a,etat=b,zone1=c,zone2=d,zone3=e,zone4=f,zone5=g,zone6=h,zone7=i,note=j)
finally:
return locals()
#
#---
#
def acue_src_dst_update():
#
z = acue_src_dst_show()
a = z.get('a')
b = z.get('b')
c = z.get('c')
d = z.get('d')
#
db.acue.truncate()
db.acue.insert(srcd1=a,srcd2=b,dstd1=c, dstd2=d)
acue_after_update = db(db.acue).select()
#
return locals()
#--
from gluon.scheduler import Scheduler
Scheduler(db,dict(sync_data=pump_most_recent,sync_dates=acue_src_dst_update))

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/web2py/ba7a30ef-1e82-430e-8295-8fd4be74c806o%40googlegroups.com.


[web2py] gevent and web2py

2018-03-01 Thread Pierre
Hi,

Can I use* gevent* to build a homemade redis task queue and to execute 
these tasks?  Does it make sense ? sorry if this is naiv questions i'm new 
to async programming...

http://web2py.com/books/default/chapter/29/08/emails-and-sms?search=homemade


from http://www.gevent.org/intro.html:


The following example shows how to run tasks concurrently:


>>> import gevent>>> from gevent import socket>>> urls = ['www.google.com', 
>>> 'www.example.com', 'www.python.org']>>> jobs = 
>>> [gevent.spawn(socket.gethostbyname, url) for url in urls]>>> 
>>> gevent.joinall(jobs, timeout=2)>>> [job.value for job in 
>>> jobs]['74.125.79.106', '208.77.188.166', '82.94.164.162'

-- 
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.scheduler.hpxyz#2791 - ERROR - we received a task that isn't there (15)

2018-02-27 Thread Pierre
I did the change at line 732 and the error continues to show up 
(immediate=True). Besides there is another problem i forgot to mention 
earlier :
the scheduler_task and scheduler_run tables are not updated properly. what 
i do is run a python script using the requests and threading module to 
perform app stress tests. every time i run this script, it's supposed to 
queue 100 new tasks and delegate work to the workers. first time i run the 
script new tasks are added to the tables as they should but not the 
second,thirdtimes. With the change you suggested script may return HTTP 
errors 500 which is something new


if you or someone else could tell me *how to start a python-rq worker 
within web2py* i'd like to give it a try, otherwise what would be the 
workaround if any?

https://groups.google.com/forum/#!msg/web2py/kAG2Y_tDoUE/ycJAdjj1hsgJ
https://groups.google.com/forum/#!msg/web2py/js0VAKK6Dlw/CJ46I-0wT0wJ

from Bruno Rocha's receipt:  this doesn't seem to work (sh file to start a 
rq worker):

cd /pathTo/web2py
sudo python web2py.py -S myapp -M -R w2p-rqworker.py


-- 
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.scheduler.hpxyz#2791 - ERROR - we received a task that isn't there (15)

2018-02-26 Thread Pierre
yes correct *immediate=False* and errors are gone. setting heartbeat=1 
instead of default and errors are back. I would not say lot's of workers 
since i can hardly run more than 3 workers5 workers == computer 
crash.

i will learn how to walk on eggs, it can be useful...

-- 
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.scheduler.hpxyz#2791 - ERROR - we received a task that isn't there (15)

2018-02-23 Thread Pierre
it's worst than i thought:

i increased tasks volume(100) with 3 up to 5 workers and now i get lot's of 
: *we received a task that isn't ther*e errors and a couple of *dead tasks *( 
queued forever ). bad bad bad
i'll check if *python-rq* can help with this and if it can't i am done with 
'gesticulations'...

http://python-rq.org/

-- 
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: controller with multiprocessing powers. Howto?

2018-02-22 Thread Pierre
i think the entry point to do multiprocessing in web2py is the 
web2py-scheduler. Howewer with this tool you can't share objects betweeen 
processes like you do using the multiprocessing python module so 
synchronization might be an issue. There are other tools like for instance* 
huey* but i am not sure it's easy to integrate with web2py. In case this is 
feasible, i'd be interested in an Howto huey-web2py-integration :

https://huey.readthedocs.io/en/latest/

-- 
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.scheduler.hpxyz#2791 - ERROR - we received a task that isn't there (15)

2018-02-20 Thread Pierre
Hi,

i get the above error from time to time running 3 redis-scheduler processes 
while results look consistent. Is this a serious error or some kind of a 
fake alert ? does it mean something ?

-- 
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] where to issue Redis transactions ?

2018-01-31 Thread Pierre
Hi,

my app requires to execute *redis transactions* using redis-py's *pipeline* 
functionality:

http://redis-py.readthedocs.io/en/latest/

with rconn.pipeline() as transaction:
transaction.mset.
transaction.mget.
...
result = transaction.execute()



where should i run this code so as to maximize speed and not to break 
anything (web2py's logic) ?:  in a controller, in a scheduler task,?

-- 
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: Rendering rows using represent and joint

2018-01-29 Thread Pierre
"a separate select for *each* record"  hum guuulllp
that's not very "cool"

and i've read joint ops are expensive too...

-- 
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: DAL with postgresql regexp_matches function

2018-01-29 Thread Pierre
pure magic

thanks Anthony

if i was a dentist i'd use regexp as well...

-- 
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] Rendering rows using represent and joint

2018-01-29 Thread Pierre
http://web2py.com/books/default/chapter/29/06/the-database-abstraction-layer#Rendering-rows-using-represent

does*  rows.render()  *involve tables *joint operations* in the background ?

-- 
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] DAL with postgresql regexp_matches function

2018-01-29 Thread Pierre

hello everyone,


Is it possible to integrate a postgresql* regexp_matches* to a dal 
expression query ?  

raw SQL working example: 

query = "SELECT tabla.id, tabla.name, regexp_matches(tabla.longstr, '%s', 
'g') FROM tabla WHERE (tabla.longstr ~ '%s');" %(regexp,regexp)


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

2017-12-23 Thread Pierre
just curious about the presence of both* scheduler_task.id* and 
*scheduler_task.uuid* ? what's the latter purpose ? is it a better task 
reference than id ? is it something related to dealing with more than one 
database ?

-- 
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] task time consumption

2017-12-05 Thread Pierre
Hi,

the *scheduler_run_table* automatically stores* run_result* (task returned 
value). I want to do the same with *task duration*(time taken to complete), 
and store it somewhere possibly in the *run_output* field. is there an easy 
way to do 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] scheduler processes synchronization

2017-12-01 Thread Pierre
Hi,

well, i already pulled off my hairs so i'm late..
here is the situation:
i have 3 sched process that can execute the same task function (diffrerent 
params) in parallel:
task function is like that:

def task(params):
try:
call module.functionA
call module.functionB
call module.functionC
except Exception as e:
db.rollback()
raise Exception(type(e).__name__)   #re-raise last 
exception
db.commit()


one module.function call includes a critical section that performs  
repeated validate_and_insert  on a unique key constrained table
this brings about IntegrityErrors so it may take several scheduler rounds 
to complete all tasks (meanwhile site users should wait.)

i tried to remedy this using:
(1) portalocker: doesn't seem to work
(2) redis_lock: no good either ('scheduler goes crazy')
(3)  db.executesql("LOCK TABLE utable IN ACCESS EXCLUSIVE;"): gives a 
ProgrammingError

is there a way to synchronize the 'animal' that's not another 
programming-nightmare ?

-- 
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 can i use incremental addition to add altogether the values using computing fields method

2017-11-27 Thread Pierre
it's better to leave aggregate values (sum,avg etc) outside the marks 
table as every record should reflect an atomic information ( a mark). When 
you need to aggregate the atoms do it in a controlller-function and pass 
results to a view for display

-- 
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 can i use incremental addition to add altogether the values using computing fields method

2017-11-27 Thread Pierre
here:
http://web2py.com/books/default/chapter/29/06/the-database-abstraction-layer#sum--avg--min--max-and-len

and don't be too severe with your students...

-- 
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: threading Lock

2017-11-21 Thread Pierre
well, i am not very religious but i think i'll have to pray anyway or throw 
everything to the 'fire' as a disaster prevention 
policy.just kidding
let's be optimistic and believe in something..i like matplotlib but i 
prefer visual python: it is capable to display content on a website too

-- 
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: threading Lock

2017-11-20 Thread Pierre
 

from recent forum threads elements i assume the following  
'macro-situation':


(0) python libraries selected for a project should be thread-safe

(1) user uses python libaries at his own risk (there 's no mean to verify 
it's thread-safe)

(2) in order to minimize risks user should put a lock around all code using 
the libraries :


def dangerous() :
 with lock_libraryA : 
 do something with libraryA 
 with lock_libraryB : 
 do something with libraryB



(3) in case of application crashes where libraries are involved means 
libraries cannot be used and designers should look for alternatives 


is this correct ?


As regard the dangerous code 'micro-situation': 

I think it' ll be ok to lock between threads. One line of code instantiates 
the main library object (constructor takes 2 files arguments). Is that a 
potential problem at the process level ? (code is readonly nothing is  ever 
written to the files)


As regard processes concurrency :

Doing tests with several scheduler processes and lot's of tasks, i have had 
deadlocks so i wondered if postgreSQL Lock command could help prevent that ?

https://www.tutorialspoint.com/postgresql/postgresql_locks.htm



thanks guys for your support……. 



 @Dave : quote by Nietzsche 

« Partout on entend la voix de ceux qui prêchent la mort : et la terre est 
pleine de ceux à qui il convient de prêcher la mort. »




-- 
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: threading Lock

2017-11-17 Thread Pierre
No this won't work..I don't know how to instantiate a lock that will 
act as a global variable. this is an enigma. tried to read this:
http://martin.kleppmann.com/2016/02/08/how-to-do-distributed-locking.html
but it's too smart for me.what i want is '*a lock for 
humans*'like 
it's said in the publicity

-- 
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 and machine learning - scikit-learn

2017-11-17 Thread Pierre
found this related to locking :
https://redis.io/topics/distlock
topic is very hermetic so if someone successfully implemented a lock in the 
production context of a web application i would really appreciate he shares 
his esoteric knowledge with us: 'the ignorants'

-- 
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: list:string field length

2017-11-17 Thread Pierre
if this is what you want, you can control | limit the length of a 
list:string field using a custom validator. this is documented in the book.

-- 
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 and machine learning - scikit-learn

2017-11-15 Thread Pierre
Is there a reliable way to determine whether or not a library is 
thread-safe ?

what's the web2py method for locking ?(module: thread/threading ? what 
kind of lock with what option: blocking/non-blocking) ?)

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: digitally signed urls

2017-11-12 Thread Pierre
finally i backtracked to decorate everything along the 'chain'. It looks 
safer and i am concerned with security
thanks 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] Re: request.ajax

2017-11-12 Thread Pierre
perfect now 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: forward auth.user record

2017-11-03 Thread Pierre
goodthanks Massimo
I'll try that soon and if the server doesn't respond i'll beat it...

-- 
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: updating to 2.15.4 from 2.9.11, is it possible ?

2017-11-02 Thread Pierre


Le lundi 30 octobre 2017 11:14:32 UTC-4, Pierre a écrit :
>
> Good day,
>
> current environment : python 2.7.6.1  and web2py 2.9.11
> updating to   : python 2.7.6.1  and web2py 2.15.4
>
> Does the older version of python could be creating the following error : 
> "Value error : insecure string pickle"
>
> Here is the traceback.
>
> Traceback (most recent call last):
>   File "P:\web2py_2_15\gluon\restricted.py", line 219, in restricted
> exec(ccode, environment)
>   File "P:/web2py_2_15/applications/Batterie/models/db.py", line 51, in 
> 
> auth.define_tables(username=False, signature=False)
>   File "P:\web2py_2_15\gluon\tools.py", line 2216, in define_tables
> super(Auth, self).define_tables(username, signature, migrate, 
> fake_migrate)._table_signature_list
>   File "P:\web2py_2_15\gluon\authapi.py", line 350, in define_tables
> format='%(first_name)s %(last_name)s (%(id)s)'))
>   File "P:\web2py_2_15\gluon\packages\dal\pydal\base.py", line 587, in 
> define_table
> table = self.lazy_define_table(tablename, *fields, **args)
>   File "P:\web2py_2_15\gluon\packages\dal\pydal\base.py", line 621, in 
> lazy_define_table
> polymodel=polymodel)
>   File "P:\web2py_2_15\gluon\packages\dal\pydal\adapters\base.py", line 
> 797, in create_table
> return self.migrator.create_table(*args, **kwargs)
>   File "P:\web2py_2_15\gluon\packages\dal\pydal\migrator.py", line 295, in 
> create_table
> sql_fields_old = pickle.load(tfile)
>   File "P:\python\PythonDevKey\Portables\Portable Python 
> 2.7.6.1\App\lib\pickle.py", line 1378, in load
> return Unpickler(file).load()
>   File "P:\python\PythonDevKey\Portables\Portable Python 
> 2.7.6.1\App\lib\pickle.py", line 858, in load
> dispatch[key](self)
>   File "P:\python\PythonDevKey\Portables\Portable Python 
> 2.7.6.1\App\lib\pickle.py", line 966, in load_string
> raise ValueError, "insecure string pickle"
> ValueError: insecure string pickle
>

-- 
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: updating to 2.15.4 from 2.9.11, is it possible ?

2017-11-02 Thread Pierre
Problem not realy identified, but the source is in the "auth" requirement 
starting reference in line 51 of db.   It seems to inhibit the migration 
process, and i'm always getting a pickle ticket.
My solution for the moment:
   - emptied the folder "database"
   - run the application and let all the tables be created, brand new an 
empty
   - made sure the definition of all tables are matching sqlite file  (used 
SQlite administrator in order to compare and verify)
   - once all the tables were created, replaced the new "storage.sqlite"  
by the OLD one.
   - once this was done, the application runs and so far doesn't seems to 
complain in anyway so far.


  

Le lundi 30 octobre 2017 14:34:51 UTC-4, Dave S a écrit :
>
>
>
> On Monday, October 30, 2017 at 10:46:57 AM UTC-7, Leonel Câmara wrote:
>>
>> Seems to be just a problem with pickle format for the table files you can 
>> probably solve this by doing a fake migration.
>>
>
> When you get past that, you may need to delete any sessions or errors that 
> you copied over (or that were already there if you did an in-place  
> upgrade).  The format changed somewhere along the way, and there is no more 
> fun than getting a ticket for a ticket.
>
> /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] forward auth.user record

2017-11-01 Thread Pierre
hello everyone,

I have a decorated action | controller  (@auth.requires_login()) making an 
ajax call to perform another action. Some time ago I realized that user 
session might expire while the ajax is being processed so if ajax secondary 
action does something like : *user = auth.user_id* and session has ended i 
get *user=None* and actions won't get through
In such situation is it good practice to forward the auth.user record (at 
list auth.user_id) sothat it's available to use by the ajax ? or should 
both actions be decorated ?

-- 
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] updating to 2.15.4 from 2.9.11, is it possible ?

2017-10-30 Thread Pierre
Good day,

current environment : python 2.7.6.1  and web2py 2.9.11
updating to   : python 2.7.6.1  and web2py 2.15.4

Does the older version of python could be creating the following error : 
"Value error : insecure string pickle"

Here is the traceback.

Traceback (most recent call last):
  File "P:\web2py_2_15\gluon\restricted.py", line 219, in restricted
exec(ccode, environment)
  File "P:/web2py_2_15/applications/Batterie/models/db.py", line 51, in 

auth.define_tables(username=False, signature=False)
  File "P:\web2py_2_15\gluon\tools.py", line 2216, in define_tables
super(Auth, self).define_tables(username, signature, migrate, 
fake_migrate)._table_signature_list
  File "P:\web2py_2_15\gluon\authapi.py", line 350, in define_tables
format='%(first_name)s %(last_name)s (%(id)s)'))
  File "P:\web2py_2_15\gluon\packages\dal\pydal\base.py", line 587, in 
define_table
table = self.lazy_define_table(tablename, *fields, **args)
  File "P:\web2py_2_15\gluon\packages\dal\pydal\base.py", line 621, in 
lazy_define_table
polymodel=polymodel)
  File "P:\web2py_2_15\gluon\packages\dal\pydal\adapters\base.py", line 
797, in create_table
return self.migrator.create_table(*args, **kwargs)
  File "P:\web2py_2_15\gluon\packages\dal\pydal\migrator.py", line 295, in 
create_table
sql_fields_old = pickle.load(tfile)
  File "P:\python\PythonDevKey\Portables\Portable Python 
2.7.6.1\App\lib\pickle.py", line 1378, in load
return Unpickler(file).load()
  File "P:\python\PythonDevKey\Portables\Portable Python 
2.7.6.1\App\lib\pickle.py", line 858, in load
dispatch[key](self)
  File "P:\python\PythonDevKey\Portables\Portable Python 
2.7.6.1\App\lib\pickle.py", line 966, in load_string
raise ValueError, "insecure string pickle"
ValueError: insecure string pickle

-- 
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] cache.redis differs from cache.ram

2017-10-27 Thread Pierre
here book description from
http://web2py.com/books/default/chapter/29/04/the-core#cache :

Note, time_expire is used to compare the current time with the time the 
requested object was last saved in the cache. It does not affect future 
requests. This enables time_expire to be set dynamically when an object is 
requested rather than being fixed when the object is saved. For example:



message = cache.ram('message', lambda: 'Hello', time_expire=5)
 

Now, suppose the following call is made 10 seconds after the above call:



message = cache.ram('message', lambda: 'Goodbye', time_expire=20)
 

*Because time_expire is set to 20 seconds in the second call and only 10 
seconds has elapsed since the message was first saved, the value "Hello" 
will be retrieved from the cache, and it will not be updated with 
"Goodbye". The time_expire value of 5 seconds in the first call has no 
impact on the second call.*

Setting time_expire=0 (or a negative value) forces the cached item to be 
refreshed (because the elapsed time since the last save will always be > 
0), *and setting time_expire=None forces retrieval of the cached value*, 
*regardless 
of the time elapsed since it was saved* (if time_expire is always None, the 
cached item will effectively never expire).


now with cache.redis:


def acache():
cache.redis('message', None)
message = cache.redis('message', lambda: 'Hello', time_expire=5)
sleep(10)
v = cache.redis('message', lambda: 'Goodbye', time_expire=20)
return locals()


result:

v=*'Goodbye'*



using *time_expire=None* to retrieve cached value:


def bcache():
cache.redis('message', None)
message = cache.redis('message', lambda: 'Hello', time_expire=5)
sleep(10)
v = cache.redis('message', lambda: 'Goodbye', time_expire=None)
return locals()

result:

v=*'Goodbye'*


I'd like to cache user specific values for the user session period:


message = cache.redis('avalue', lambda: value, time_expire= 
auth.settings.expiration)


how do I make sure value can be retrieved ?

-- 
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: component rebuild via anchor helper

2017-10-07 Thread Pierre
Yes there are a couple of options to solve this (indeed a minor problem)

(1) jquery POST
(2) jquery LOAD
(3) axios.post for the purists

i am not storing anything into the session.

I picked up (2) and after some 'gymnastics' I got a solid result.

-- 
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] component rebuild via anchor helper

2017-10-02 Thread Pierre
hello all,

I am using the A helper as described in the book to reconstruct a page 
component when user presses a button:

{{=A('linked page', _href=URL('func', vars={'a':a, 'b':b}), cid='myid')}} 


query string I pass can be quite long so I'd like a POST request instead of a 
GET.
Is this possible keeping the same technique ?

-- 
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] form replacing elements

2017-09-29 Thread Pierre
 
well,don't think for too long.that's very unproductive

-- 
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] form replacing elements

2017-09-29 Thread Pierre
well,don't think for too long.that's very unproductive

-- 
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] form replacing elements

2017-09-28 Thread Pierre
worked !!

thanks Dave.

what's next we should try ?

Le mercredi 27 septembre 2017 03:26:56 UTC+2, Dave S a écrit :
>
>
>
> On Tuesday, September 26, 2017 at 2:58:02 PM UTC-7, Pierre wrote:
>>
>> I tried to tame a raccoon and it didn't work. :(
>>
>>
> What's the python signature of a raccoon?  I think you need to provide 
> some of the optional parameters.
>
> /dps
>  
>
>>
>> Le lundi 25 septembre 2017 20:37:10 UTC+2, Dave S a écrit :
>>>
>>>
>>>
>>> On Monday, September 25, 2017 at 9:35:04 AM UTC-7, Richard wrote:
>>>  
>>>
>>>> Instead of asking why you try to use don't work, ask us how to do what 
>>>> you try to achieve, it will be more productive.
>>>>
>>>>
>>> Except when the first response is "well, what did you try?"
>>>
>>> I think it's useful to say "I'm tyring to ... and this didn't work:"
>>>
>>> /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] form replacing elements

2017-09-22 Thread Pierre
Hi everyone,

trying to replace a list:string form data attribute (data-fuu) value

am doing the following:
 
   form = SQLFORM(db.listfoo, record=rec, fields=['foo'], showid=False)
   for i,fe in enumerate(form.elements('input.string')):
fe['_data-fuu'] = form.record.fuu[i]


I noticed the above changes aren't persistent as in case of *form.errors* 
data-fuu values return to their initial values
How to make these persistent whatever happens to the form process ?

-- 
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: caching variable data sample

2017-09-19 Thread Pierre
thanks Anthony...

looks like the cache select puzzle is now complete. :  )


however we still have a 'serious productivity lag here in Bangladesh'...


-- 
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: caching variable data sample

2017-09-18 Thread Pierre
I'd prefer the module option but I need to pass *time_expire* as a variable 
(*db.table.__variableName*), I don't think I can do that in a module can I ?


On Friday, September 15, 2017 at 6:15:44 AM UTC-4, Pierre wrote:
>>
>> actually the real function is a little more complex since it returns rows 
>> plus other datas that don't require caching. I tried to move the cache_this 
>> function to a module (don't know if this is orthodox) but then i get a 
>> decorator error:
>>
>> @current.cache('data_sample',* time_expire=60*, 
>> cache_model=current.cache.redis)
>> attributeError cache object has not attribute redis
>>
>
> You don't necessarily have to put the function in a module -- it can go in 
> a model or even in the controller (if the function takes no arguments, 
> start its name with a double underscore to prevent it from being exposed as 
> an action). You can even define the function inside the controller function 
> that calls it if that's the only place it is needed.
>
> 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: caching variable data sample

2017-09-15 Thread Pierre
the more digging the deeper one gets :

https://groups.google.com/forum/?fromgroups#!searchin/web2py/cache$20in$20module/web2py/AZa5Boj3y3E/_BPMTdXwSaMJ

and here is the *cache_this*  module version :

from gluon.cache import lazy_cache

@lazy_cache('data_sample', time_expire=60, cache_model='redis')
def cache_this():
...
rows = db(db.atable.id > 0).select(limitby=limitby, cacheable=True)
return rows


This seems to do the trick.  Is it 'kosher' ?

-- 
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: caching variable data sample

2017-09-15 Thread Pierre
very True: productivity rules and I am far below modern 
standards(more or less the 'Bangladesh level'):)

Le jeudi 14 septembre 2017 16:55:29 UTC+2, Anthony a écrit :
>
>  
> Maybe you should have asked a week ago. ;-)
>
> 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: caching variable data sample

2017-09-15 Thread Pierre
actually the real function is a little more complex since it returns rows 
plus other datas that don't require caching. I tried to move the cache_this 
function to a module (don't know if this is orthodox) but then i get a 
decorator error:

@current.cache('data_sample', time_expire=60, 
cache_model=current.cache.redis)
attributeError cache object has not attribute redis

Le jeudi 14 septembre 2017 16:49:49 UTC+2, Anthony a écrit :
>
> Looks like you want to cache the results of the entire function -- so why 
> not do that:
>
> @cache(some_key, time_expire=60, cache_model=cache.ram)
> def cache_this():
> ...
> rows = db(db.atable.id > 0).select(..., cacheable=True)
> return dict(rows=rows)
>
> Just be sure to set cacheable=True, which will make the entire Rows object 
> cacheable.
>
> 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: caching variable data sample

2017-09-14 Thread Pierre
the cache select mechanism is full of mystery:

given book example code:

def cache_db_select(): 
logs = db().select(db.log.ALL, cache=(cache.ram, 60)) 
return dict(logs=logs)


what happens to next cache_db_select call after the 60 seconds has elapsed ?
Does it overwrite the previously cached rows ? 

One need to know a key in order to clear a specific cached value associated 
with that key. When performing a cache select no key is being passed so how 
to clear a specific cached select item (for instance logs) ?

this gives me nerve crisesIt should be simple to do a simple thing 
however one week digging this and I didn't move 1 inch ahead

-- 
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] caching variable data sample

2017-09-13 Thread Pierre


purpose is to keep a single renewable pseudo-random data sample live 

the w2p books describes a situation of a constant query :
http://web2py.com/books/default/chapter/29/06/the-database-abstraction-layer?search=caching+selects#Caching-selects
def cache_db_select(): 
logs = db().select(db.log.ALL, cache=(cache.ram, 60)) 
return dict(logs=logs)

now suppose every call a different query like here :

def cache_this():
nget = somevalue
kount = db(db.atable.id > 0).count() 
offset = randint(0, kount - nget)
limitby = (offset, offset + nget)
rows = db(db.atable.id > 0).select(limitby=limitby, cache=(cache.redis, 60))
return dict(rows=rows)



this accumulates cached 'material' and returns a different rows on every call
how do I make *cache_this* behave like the book example ?

I could cache kount and offset variables as well :

kount = db(db.atable.id > 0).count(cache=(cache.redis, 60)) 
offset = cache.redis('offset', lambda: randint(0, kount-nget), time_expire=60) 


but i suppose this would lead to a synchronization problem and thus possible 
duplicate cached select

-- 
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: sql tablesample

2017-09-09 Thread Pierre


got it

9.3 == wrong postgreSQL version. Tablesample is available since ver 9.5
now let's have some 'fun' in 'Guantanamo' :)(

-- 
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] sql tablesample

2017-09-09 Thread Pierre
hello everyone,

I need to cache a data sample extracted from a large table at regular time 
intervals but due to poor performance I don't want to use : 

db().select(db.table_name.ALL, orderby='', limit=)

and the posgreSQL TABLESAMPLE functionality doesn't seem to work:

code:
def rowsampl():
 q = "SELECT * FROM table_name TABLESAMPLE SYSTEM(0.5);"
 result=db.executesql(q)
 return locals()

error:

Ticket ID 

127.0.0.1.2017-09-09.12-58-05.12040b96-266e-477d-aaee-8c0f9fe0755b
 syntax error at or near "SYSTEM" LINE 
1: SELECT * FROM table_name TABLESAMPLE SYSTEM(0.5); ^ Version 
web2py™ Version 2.14.6-stable+timestamp.2016.05.10.00.21.47 Traceback 
Traceback (most recent call last):
 File "/opt/web2py/gluon/restricted.py", line 227, in restricted
 exec ccode in environment
 File "/opt/web2py/applications/myapp/controllers/default.py" 
, 
line 1086, in 
 File "/opt/web2py/gluon/globals.py", line 417, in 
 self._caller = lambda f: f()
 File "/opt/web2py/applications/myapp/controllers/default.py" 
, 
line 693, in rowsampl
 result=db.executesql(q)
 File "/opt/web2py/gluon/packages/dal/pydal/base.py", line 1019, in 
executesql
 adapter.execute(query)
 File "/opt/web2py/gluon/packages/dal/pydal/adapters/postgres.py", line 362, 
in execute
 return BaseAdapter.execute(self, *a, **b)
 File "/opt/web2py/gluon/packages/dal/pydal/adapters/base.py", line 1388, in 
execute
 return self.log_execute(*a, **b)
 File "/opt/web2py/gluon/packages/dal/pydal/adapters/base.py", line 1382, in 
log_execute
 ret = self.get_cursor().execute(command, *a[1:], **b)
ProgrammingError: syntax error at or near "SYSTEM"
LINE 1: SELECT * FROM table_name TABLESAMPLE SYSTEM(0.5);


1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
14.
15.
16.
17.
18.

Is there an economic way to treat 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] Re: to XML() or to JSON.parse() ?

2017-07-31 Thread Pierre
thanks Anthony

I'll use ASSIGNJS. I'd never heard of this helper.too bad it's 
unpublished in the book

-- 
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: to XML() or to JSON.parse() ?

2017-07-28 Thread Pierre
Yes I want to execute a view here is the example code:

Controller:

from json import dumps as jdumps

def abtest():
alist = ["it's ok","I'm late"]
return dict(stra='abcd', obj=jdumps(alist))

View:

{{extend 'layout.html'}}
Ceci est le modèle test/abtest.html 

RESULT


var o= "{{=obj}}";
var po = JSON.parse(o);
console.log(po);
jQuery("#result").html(po); 



JSON decode error:

SyntaxError: JSON.parse: unexpected character at line 1 column 2 of the 
JSON data

-- 
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] to XML() or to JSON.parse() ?

2017-07-28 Thread Pierre
 

Hi everyone,

I'd prefer JSON.parse() but in most case i have to fall back on XML()

for example given a list


alist= ["it's ok","I'm late"]


If an AJAX function returns something of the form: 


 return json.dumps(dict(alist=alist, astring='abcd'))


then JSON.parse() can cope with it


howewer if it returns a 'hybrid' type like:


return dict(astring='abcd', ajson=json.dumps(alist))

then the json part can only be decoded by XML()


Is this what's expected ? Or do i miss something ?





*third option would be 'very deep snorkeling'*

-- 
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: Testing error

2017-07-28 Thread Pierre
looks like the ajax target function is faulty. perhaps it tries to reload 
web2py.js. Or the ajax call might be wrong (the error message says it wants 
asynchronous and you give it synchronous call). who's the boss ? :) 

-- 
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: trigger some js code on successful login

2017-07-07 Thread Pierre
@Leonel : trying to do a *localforage records manager*.it uses 3 js 
libraries localforage, axios and sjcl ; it's not very complicated,  
basically a 3 levels promises chain that encrypts, decrypts , checks data 
integrity and release  data if everything ok

@Anthony: here is the new *user.html* according to your suggestions

def user():
if request.args(0) == 'login' and '_next' in request.get_vars:
request.get_vars['_next'] += '?loadjs=locf_manager.js'
return dict(form=auth())

thanks guys..

*there 's only one thing we can be sure of  though : our "bunker apps" 
cannot be destroyed*

-- 
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] trigger some js code on successful login

2017-07-06 Thread Pierre
can't  find an easy way out of this

so far i have :

auth.settings.login_next = URL('controller','dosomething')


but this works only with direct login via top navbar button, not when login 
occurs via decorated controller function
:
@auth.requires_login()
def func():
pass

-- 
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: Any ideas on how to prepare web2py apps for GDPR

2017-07-06 Thread Pierre
for cryptographists and "bunker" amateurs :

http://bitwiseshiftleft.github.io/sjcl/

-- 
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: change login page layout

2017-07-06 Thread Pierre
very useful thanks !!

*will also use request.env.path_info to conditionally load js files*I had 
forgotten *user.html*silly me( beating myself. )






*« Le désert croît… malheur à qui protège le désert ! »  F.Nietzsche*

-- 
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 login page layout

2017-07-05 Thread Pierre
Hi,

how do i tell web2py to use *mylayout.html* instead of *layout.html*  for 
*login* and other auth related pages ?

-- 
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] user logout before ajax returns

2017-06-30 Thread Pierre
hi everyone,

in the w2p book we are advised to user-signature ajax urls but what's 
happen if user logout  and the ajax hasn't finished its job. Shall this be 
a special error case ? Also shall we  pass *auth.user_id* in the ajax 
request params to make sure task is performed eventhough user would logout 
in between ajax call and  ajax return

-- 
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: fluctuating session data storage

2017-06-10 Thread Pierre
Hello Dave,

yes the data should also be stored to the db. What i am trying to achieve 
is load data on successful login so as to keep it available for session 
duration. Now I load it using the *localForage.js* so it goes somewhere in 
localStorage | indexDB | WebSQL. it's complicated because it's somehow 
dangerous to manipulate *local sensitive data* so i also need 
*data-Integrity-check 
logic*. I want to implement this with *hmac.hexdigest()* stored together 
with the data. not sure  this is clean and secure or even "human" but this 
is all I got right now...perhaps I should also encrypt and decrypt 
data, who knows how far this is going to lead ?





-- 
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] fluctuating session data storage

2017-06-09 Thread Pierre
Hi,

Is it ok to store a small fluctuating* (lot's of updates while user is 
logged-in)* chunk of data into the session or assume db storage is best ?  
what's more efficient  in terms of data accessibility, read-write speed, 
given sessions would use cookie-storage) ?

-- 
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] auth.navbar modification

2017-06-07 Thread Pierre
  this expression in layout.html works for me combined with the login_next 
in db.py

   {{='auth' in globals() and auth.navbar(mode='dropdown',
referrer_actions=['register',
'request_reset_password','retrieve_username']) or ''}}


-- 
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] auth.navbar modification

2017-06-07 Thread Pierre
sorry I deleted the initial post this was caused by a bogue in my code
still what's the* referrer_actions complete list* I should subtract actions 
from. Actions I am aware of are :login, register ,request_reset_password, 
retrieve_username. Any other actions I should know ?

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


[web2py] auth.navbar modification

2017-06-05 Thread Pierre
Hi

I am trying to redirect user after successful login. I do nothing but what 
the book says but i am unable to change default behaviour
here is the code :

in db.py :

auth.settings.registration_requires_verification = False
auth.settings.registration_requires_approval = False
auth.settings.reset_password_requires_verification = True
auth.settings.login_next = URL('default','index')



in layout.html :
{{='auth' in globals() and auth.navbar(mode='dropdown', referrer_actions=
None)}}


book url :
http://web2py.com/books/default/chapter/29/09/access-control#Auth-Settings-and-messages

trying hard to stay calm.GRMBBBLEU   GRRBBBMLEUMBLEU

-- 
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] user data, html5 sessionStorage, session

2017-06-02 Thread Pierre
Hi,

I'd like to dump a small set of user specific data on login (to keep this 
data "alive" during user session) but am not sure about the container ? 
should it be the session ( i also would like to store sessions in cookies), 
html5 sessionStorage, cache to disk..or perhaps this is a bad idea 
since there's little space available in cookies and local storage security 
and/or logic issues. 

i have read this article which seems quite anti-html5-local-storage
https://www.whitehatsec.com/blog/web-storage-security/
I don't understand how local storage could be utilized outside of the scope 
of an application "business logic" ?



-- 
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: Future of web2py

2017-05-31 Thread Pierre
weppy
the web framework for humans


sounds good ?


frigolux
the refrigerator for polar bears

-- 
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: not web2py related but this is free now

2017-05-31 Thread Pierre
nice book Massimo, I'll be studying it during the next holidays. A more 
severe future might arise quickly so better be cautious. 

-- 
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 do I troubleshoot this? (DAL)

2017-05-16 Thread Pierre
http://web2py.com/books/default/chapter/29/06/the-database-abstraction-layer#Exporting-and-importing-data

what i 'd do is backup the data rewrite a clean relational model with new 
tablenames and foreign key constraints then restore data..

-- 
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 do I troubleshoot this? (DAL)

2017-05-16 Thread Pierre

>
> drop the table in question and save your db.py file again. It should 
> recreate the table with a new name
>

http://web2py.com/books/default/chapter/29/06/the-database-abstraction-layer#drop
 

-- 
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 form-horizontal changing default columns width

2017-05-15 Thread Pierre
Hi,

i don't use any formstyle. I looked at the *sqlhtml.py* to try to figure 
out what formstyle function is used by default ? so i can clone it with 
modifications i need:  just replace the *col-sm-3* with *col-sm-2* and the 
*col-sm-9* with *col-sm-10*

i know this can be done 'ex-post' with DOM parsing but it's "ugly". Is 
there a better way ? 

-- 
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: Any easy way to prevent left_sidebar from scrolling down?

2017-05-15 Thread Pierre
i don't know your css classes maybe switching to bootstrap* col-xs-** 
classes will prevent overlapping. otherwise you might find a solution using 
css media-queries

-- 
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: Any easy way to prevent left_sidebar from scrolling down?

2017-05-15 Thread Pierre
this might help:

https://www.w3schools.com/bootstrap/bootstrap_affix.asp

howewer i am not sure this is very responsive-design compatible. It might 
become hazardeous as viewport is shrinked

-- 
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: recurring events from one form

2017-05-14 Thread Pierre
apologies as there might be issues with the callback function (recurrent 
calls...)

here a better receipt based on SQLFACTORY:

(1) in your controller create a list a fields like this :
repeats =  Field('repeats', 'integer', ..add your validators here)
fields = [repeats , db.evento.titolo, db.evento.inizio..add all evento 
fields here...]

note that repeats is a foreign field (doesn't belong to db.evento). it will 
tell the indice of event repetition :

repeats=0 first occurence
repeats=1 first repeats
repeats=2 second repeats  etc

create the corresponding labels dict  and
write the form variable like this :

form = SQLFORM.factory(*fields, labels=..., table_name=...)

(2) in the form processing section write something like :

if form.process(onvalidation=validateMyEvento, dbio=False).accepted:
for i in range(form.vars.repeats):



-- 
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: recurring events from one form

2017-05-13 Thread Pierre
here is the "anonymous guru":
http://web2py.com/books/default/chapter/29/06/the-database-abstraction-layer#callbacks-on-record-insert--delete-and-update

write a callback function that performs after the first record(event) 
insert and repeats it as many times as necessary (number of repeats in the 
first insert). You'll have to do some calculations with datetimes (see 
datetime.timedelta feature)

-- 
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 Postgresql Groupby issue

2017-05-13 Thread Pierre
here: http://web2py.com/books/default/search/29?search=groupby

s = db.table.field_a | db.table.field_b
groupby s




*always obey the computer.*   :)

-- 
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: Html helper module?

2017-05-07 Thread Pierre
I just repeated what's written in the web2py book :


For example a model could do

auth = Auth(db)
from gluon import current
current.auth = auth
current.db = db #not needed in this case but useful

and now all modules imported can access current.auth.

current and import create a powerful mechanism to build extensible and 
reusable modules for your applications.


I'll check without the import..what about the datetime module how do i 
access it without re-importing  ?

-- 
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: Html helper module?

2017-05-05 Thread Pierre
one way to access T from a module :

in db.py:

from gluon import current
current.T=T



in module:

T=current.T


-- 
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: dal

2017-04-29 Thread Pierre
you would have to add a new constraint at the database level like this:

query="ALTER TABLE %s ADD CONSTRAINT %s UNIQUE (amcno,unitid);" 
%(tablename,constraintname)
result=db.executesql(query)


here a postgresql example to set the new constraint in a controller:

def setconstraint():
tablename='public.tablename'
constname='constraintname'
try:
query="ALTER TABLE %s ADD CONSTRAINT %s UNIQUE (amcno,unitid);" 
%(tablename,constname)
result=db.executesql(query)
except:
result="ERROR : constraint already exists"
finally:
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: btw: great job

2017-04-28 Thread Pierre
welcome aboard !!! this is not your captain speaking.we shall take off 
in a few minutes.

*do not fasten your seat belts and stop smoking*

-- 
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: sql COUNT function and DAL

2017-04-28 Thread Pierre
Marlysson :

just in case,  from now on i keep this one under my pillow :))

https://media.readthedocs.org/pdf/pydal/stable/pydal.pdf

-- 
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: sql COUNT function and DAL

2017-04-28 Thread Pierre
wonderful !!

and I can even cache it to prevent waste

thanks 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] sql COUNT function and DAL

2017-04-27 Thread Pierre
Hi,

Is there a way to transform this sql into a valid DAL expression ?

"SELECT csp, COUNT(csp)AS freq FROM table GROUP BY csp ORDER BY COUNT(csp) 
DESC LIMIT %s OFFSET %s;" %(limit,offset)


I want to avoid executesql as much as i can..

-- 
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: conditional block insert

2017-04-24 Thread Pierre
found the bogue.a nasty supernumerary {{pass}}  in the sidebar.html

thank you  guys for your patience and perseverence...



-- 
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] conditional block insert

2017-04-24 Thread Pierre
hello everyone,

{{block left_sidebar}}
{{if auth.has_membership('manager'):}}
   {{include 'manager_sidebar.html'}}
{{else:}}
   {{include 'sidebar.html'}}
{{pass}}
{{end}}

for some reason this doesn't work. It inserts a mixture of the two 
sidebars. If i move blocks inside of the if same problem?? there seems 
to be a conflict between the two includes ?

-- 
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: Making application looks better.

2017-04-14 Thread Pierre
learn the basics of css and the bootstrap grid system and components. As 
for sidebars, there are powerful tools like  -change column ordering-   (a 
sidebar is just a bootstrap column contained in a row)

https://www.w3schools.com/bootstrap/bootstrap_grid_examples.asp

-- 
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] cache.redis in module

2017-03-27 Thread Pierre
Hi everyone,

I have a *cache.redis* defined in a db.py file like so:

from gluon.contrib.redis_utils import RConn
from gluon.contrib.redis_cache import RedisCache

rconn = RConn('localhost', 6379)
cache.redis = RedisCache(redis_conn=rconn, debug=True) 

 now i'd like to perform caching in a module how ?

I tried to pass cache.redis to module function and also the current method 
: current.cache_redis=cache.redis.None of these works..how 
to access *cache.redis* from the module ?

-- 
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: text field input control

2017-02-25 Thread Pierre
thanks for confirmation Massimo

we shouldn't clean so much as is bad for the ecosystem.

-- 
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: missing field in search tab, using smartgrid

2017-02-23 Thread Pierre
Solved
Thank you Antony, that was exactly right :)
The amazing thing is that i had imported all the database content (from 
access to sqlite), and all the code was working, making some math on that 
field without any problem.
Changed it to 'double', and it's now showing on the drop down list.

I just loved web2py and python  (so glad I moved to it)

many thanks Antony.

Le jeudi 23 février 2017 09:40:11 UTC-5, Anthony a écrit :
>
> "float" is not a valid field type -- it should be "double". See 
> http://web2py.com/books/default/chapter/29/06/the-database-abstraction-layer#Field-types
> .
>
> Anthony
>
> On Thursday, February 23, 2017 at 8:27:36 AM UTC-5, Pierre wrote:
>>
>> Any hint on why only one field is missing in the search drop down 
>> smartgrid ?
>> Is there a way to find a "special" attribute about a field that would 
>> prevent it to be visible in the drop down list ?
>>
>> ps: I can search on this field (writing the query manualy )
>>
>> What I've tried so farwithout results
>># add "redefine = True" in the table creation
>>   #  specify readable and writable = True just before the grid = .
>>   #  list all the fields in the smartgrid
>>   #  list of all  searchable fields in smartgrid
>>
>> The table: 
>>
>> db.define_table('achat',
>>   Field('quand' ,'date'  , 
>> label='Date'),
>>   Field('qui'  ,'reference qui', label='Qui' 
>> ),
>>   Field('typ'  ,'reference typ', 
>> label='Type'),
>>   Field('fam_id'   ,'reference fam'   , label='Fam'),
>>   Field('det_id'   ,'reference det' , label='Det'),
>>   Field('montant','float' , 
>> label='Montant'), # this is the field that is not showing in smartgrid 
>> automatic drop down list from smartgrid
>>   Field('famdet_id' ,'reference famdet'  , label='Famdet'),
>>   Field('commun'   ,'boolean'  , label='Commun'),
>>   Field('cash'  ,'boolean'  , 
>> label='Cash'),
>>   Field('dcc','boolean'  , 
>> label='Payer ce mois'),
>>   Field('note'   ,'string'  , 
>> label='Note',length=60))
>>
>>
>> The test controller:
>>
>> def t():   # this is a simple controler to test different solution
>> grid = SQLFORM.smartgrid(db.achat)
>> return dict(grid=grid)
>>
>

-- 
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] text field input control

2017-02-23 Thread Pierre
Hi everyone,

is it useful to clean a form textarea prior to db.insert ? I am asking this 
because of *bleach* :

https://bleach.readthedocs.io/en/latest/clean.html

I have read a recent post which says it's secure enough not to use the XML 
helper when displaying text content...

can't figure out wether* bleach* is necessary or 'overkill'  ?

-- 
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] missing field in search tab, using smartgrid

2017-02-23 Thread Pierre
Any hint on why only one field is missing in the search drop down smartgrid 
?
Is there a way to find a "special" attribute about a field that would 
prevent it to be visible in the drop down list ?

ps: I can search on this field (writing the query manualy )

What I've tried so farwithout results
   # add "redefine = True" in the table creation
  #  specify readable and writable = True just before the grid = .
  #  list all the fields in the smartgrid
  #  list of all  searchable fields in smartgrid

The table: 

db.define_table('achat',
  Field('quand' ,'date'  , 
label='Date'),
  Field('qui'  ,'reference qui', label='Qui' ),
  Field('typ'  ,'reference typ', label='Type'),
  Field('fam_id'   ,'reference fam'   , label='Fam'),
  Field('det_id'   ,'reference det' , label='Det'),
  Field('montant','float' , 
label='Montant'), # this is the field that is not showing in smartgrid 
automatic drop down list from smartgrid
  Field('famdet_id' ,'reference famdet'  , label='Famdet'),
  Field('commun'   ,'boolean'  , label='Commun'),
  Field('cash'  ,'boolean'  , label='Cash'),
  Field('dcc','boolean'  , label='Payer 
ce mois'),
  Field('note'   ,'string'  , 
label='Note',length=60))


The test controller:

def t():   # this is a simple controler to test different solution
grid = SQLFORM.smartgrid(db.achat)
return dict(grid=grid)

-- 
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: reference_field_value = None

2017-02-10 Thread Pierre
thanks guys

for sure a minor problem  :)  i am afraid the most difficult is 
comingan "iceberg" or something equivalent

-- 
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] reference_field_value = None

2017-02-10 Thread Pierre

Hello everyone,

I noticed by accident  i can insert a record with 
reference_field_value=None. Is this the desired behavior ? I thought this 
would trigger an exception especially when NOTNULL=True but None is not 
considered NULL ?

-- 
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] validate_and_insert in task

2017-01-18 Thread Pierre
Hi,

i am trying to validate_and_insert  a record containing a *unique *constraint 
field in a task( to avoid task failure in case of duplicate). But still 
when this occurs (duplicate) task continues to fail (a typeERROR exception 
is raised). When used in a controller validate_and_insert doesn't behave 
like that so i don't get it ?. How am i suppose to prevent task failure in 
case of duplicate record insert( I need to pursue when this occurs instead 
of having a brutal STOP and a dead task).

-- 
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: model define_table select

2017-01-12 Thread Pierre Corbeil
Good day Luca/Massimo,
Can you show me the final code ..i'am trying to do exactly that. 
(unsure of what you have done exactly in db.py)
Thanks

Le lundi 28 mars 2016 05:51:33 UTC-4, lucas a écrit :
>
> yes massimo,
>
> that almost worked.  as suggested, i first changed it under the db.py 
> model and then set the request.vars.state_id to the state_id variable just 
> before creating and assigning the SQLFORM under the controller module.  it 
> threw back an empty set of counties.  so i thought maybe request isn't 
> reaching that deep into the db.py module.  so i changed the request.vars 
> into session, like session.state_id = state_id, and also under db.py and 
> that worked great.
>
> i am always amazed of how fast and efficiently i can get things done using 
> web2py.  it really is a wonder and wonderful.
>
> thanx massimo.  lucas
>
> On Sunday, March 27, 2016 at 11:17:19 AM UTC-4, Massimo Di Pierro wrote:
>>
>> Correction. replace
>>
>> IS_IN_DB(db_region(*db_region.post.state_id==db_region.county.state_id*)
>>
>> with
>>
>> IS_IN_DB(db_region(*db_region.county.state_id == **request.vars.state_id*
>> )
>>
>

-- 
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: Made with web2py

2017-01-06 Thread Pierre
nice design and interesting concept too
may I ask where do you host it ?

i visited *bback.me* this morning and now access is refused...I'll be 
back

-- 
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_IN_SET or IS_IN_DB to create a sublist based on part of a table

2017-01-05 Thread Pierre Corbeil
Trying to migrate my old access environment to web2py.  I have imported all 
data, can be viewed ok.
Trying to get a dropdown list (when using smargrid) that is a subset of a 
table.
been trying for while now,  maybe someone can give me a hint.
Here is the tables :

#
db.define_table('famille' ,
  Field('famille' ,'string' , label='Famille' , length = 
25),format='%(famille)s')
#
db.define_table('detail'  ,
  Field('famille' ,'reference famille'),
  Field('detail'  ,'string' , label='Detail'   , length = 
60),format='%(detail)s')
#
db.define_table('achat',   
   # not showing all the fields to shortens the text a bit
  Field('famille' ,'reference famille' , label='Famille'),   # 
shows as a drop down pick list, works ok
  Field('detail'  ,'reference detail'  , label='Détail' ), 
 # show sall the detail, but I would like to view only the ones related to 
the "famille" that has just been selected
  Field('dcc' ,'boolean'   , label='Payer ce mois'))
#
# The controler, as it is now:
def manage():
db.achat.id.readable=False
db.achat.qui.represent  = lambda v, r: '' if v is None else 
(db.qui(v).prenom)
db.achat.typ.represent  = lambda v, r: '' if v is None else 
(db.typ(v).typ)
db.achat.famille.represent  = lambda v, r: '' if v is None else 
(db.famille(v).famille)
db.achat.detail.represent   = lambda v, r: '' if v is None else 
(db.detail(v).detail)
grid = SQLFORM.smartgrid(db.achat, 
 linked_tables=['qui','typ','famille','detail','famdet'],
fields=[db.achat.quand,
db.achat.montant,
db.achat.cash,
db.achat.qui,
db.achat.commun,
db.achat.typ,
db.achat.note,
db.achat.famille,
db.achat.detail,
db.achat.dcc ],
orderby=~db.achat.quand,
create=False,
exportclasses= dict(csv_with_hidden_cols=False, 
tsv_with_hidden_cols=False, tsv=False, json=False, xml=False, html=False),
paginate=10)
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: dynamic form component

2016-12-28 Thread Pierre
this is a view that should allow users to send messages (submit 
form/messages...and not to reload the actual page) 

trying this from Anthony:
https://groups.google.com/forum/?fromgroups#!searchin/web2py/dynamic$20component/web2py/-_xH0vnfr7I/J05mFfPvW9cJ

form component loads well onclicked button but it cannot find his way back 
to parent view after submission..?

-- 
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] dynamic form component

2016-12-28 Thread Pierre
Hi,

I have a set of buttons displayed in a view. I'd like each  button to 
pass different args to the form component (prepopulate some of the form 
fields). I can probably achieve this via some tricky js/jquery but is there 
a better option like loading the component when necessary with the 
appropriate args (onclick LOAD..) already set ?

-- 
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: table cells truncation

2016-12-21 Thread Pierre

thanks Anthony

my tables look better now. there was a big mistake in my css. almost 
everything is in order :)

-- 
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: table cells truncation

2016-12-20 Thread Pierre
I mean a HTML  whose code lies in a view "as opposed to" a sqltable:

my code looks like this:

{{def truncstr(s,n,dots):}}
.truncate function..
{{pass}}

{{extend layout.html}}
.header...


etc...



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


  1   2   3   4   >