[web2py] Re: Scheduler: Is it possible to assign a task to all workers that are part of a group?

2018-05-08 Thread Francisco Ribeiro
Thank you, that has crossed my mind but I would then have to create another 
abstraction on top of the Scheduler groups to represent, well... groups. I 
even thought of conventions like common prefixes to identify which 
"user-group" belongs to which "group-group". Anyway, I gave up on the idea 
and is it looked to cluttered and implemented this functionality on the 
Scheduler, will submit a PR in case you are interested.

Basically, all you do is to create a task with broadcast=True and it should 
hit all the workers within the assigned worker_group. This should work even 
if new workers join the group later on and it should also work for both 
one-off tasks or tasks with an unlimited number of repeats. Finally, if you 
stop / disable / delete the broadcast task, no more tasks should be 
triggered like it, so you stop broadcasting. Happy to document this better, 
if are you happy to include it.

Kind regards,
Francisco

On Tuesday, 8 May 2018 19:52:29 UTC+1, Niphlod wrote:
>
> hint: if the api doesn't allow it, it's not an envisioned scenario.
>
> That being said, there's no limit on the worker-group configuration. 
> As auth relies on RBAC, workers rely on groups. 
> A particular group is able to process a given task ? Queue the task 
> assigning the correct group.
> Only one worker is able to process tasks of a specific group ? voilà!
> It's perfectly fine to run 10 workers and have 10 groups, even if each 
> group holds just one worker...
>
> On Monday, May 7, 2018 at 8:13:02 PM UTC+2, Francisco Ribeiro wrote:
>>
>> I have been testing my own hypothesis, it didn't work. I was unable to 
>> assign a task to a specific worker, I can only assign tasks to groups. 
>> Please correct me if I am wrong...
>>
>> On Sunday, 6 May 2018 16:16:08 UTC+1, Francisco Ribeiro wrote:
>>>
>>> Thank you for confirming.
>>>
>>> I presume that I still can take a list of workers belonging to a single 
>>> group and assign the same task multiple times (once per worker), which 
>>> would still suit my needs (expect if i want to cancel it for whatever 
>>> reason which becomes harder / less convenient). Do you see any problem 
>>> doing that?
>>>
>>> On Sunday, 6 May 2018 04:16:53 UTC+1, Massimo Di Pierro wrote:
>>>>
>>>> No. I do not believe there is any way to guarantee that every work will 
>>>> execute the same task.
>>>>
>>>>
>>>> On Friday, 4 May 2018 17:36:30 UTC-5, Francisco Ribeiro wrote:
>>>>>
>>>>> The question refers to submitting a task simultaneously to all workers 
>>>>> within a group.
>>>>>
>>>>> Thank you
>>>>>
>>>>

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


[web2py] Re: Scheduler: Is it possible to assign a task to all workers that are part of a group?

2018-05-07 Thread Francisco Ribeiro
I have been testing my own hypothesis, it didn't work. I was unable to 
assign a task to a specific worker, I can only assign tasks to groups. 
Please correct me if I am wrong...

On Sunday, 6 May 2018 16:16:08 UTC+1, Francisco Ribeiro wrote:
>
> Thank you for confirming.
>
> I presume that I still can take a list of workers belonging to a single 
> group and assign the same task multiple times (once per worker), which 
> would still suit my needs (expect if i want to cancel it for whatever 
> reason which becomes harder / less convenient). Do you see any problem 
> doing that?
>
> On Sunday, 6 May 2018 04:16:53 UTC+1, Massimo Di Pierro wrote:
>>
>> No. I do not believe there is any way to guarantee that every work will 
>> execute the same task.
>>
>>
>> On Friday, 4 May 2018 17:36:30 UTC-5, Francisco Ribeiro wrote:
>>>
>>> The question refers to submitting a task simultaneously to all workers 
>>> within a group.
>>>
>>> Thank you
>>>
>>

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


[web2py] Re: Scheduler: Is it possible to assign a task to all workers that are part of a group?

2018-05-06 Thread Francisco Ribeiro
Thank you for confirming.

I presume that I still can take a list of workers belonging to a single 
group and assign the same task multiples times (once per worker), which 
would still suit my needs (expect if i want to cancel it for whatever 
reason which becomes harder / less convenient). Do you see any problem 
doing that?

On Sunday, 6 May 2018 04:16:53 UTC+1, Massimo Di Pierro wrote:
>
> No. I do not believe there is any way to guarantee that every work will 
> execute the same task.
>
>
> On Friday, 4 May 2018 17:36:30 UTC-5, Francisco Ribeiro wrote:
>>
>> The question refers to submitting a task simultaneously to all workers 
>> within a group.
>>
>> Thank you
>>
>

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


[web2py] Scheduler: Is it possible to assign a task to all workers that are part of a group?

2018-05-04 Thread Francisco Ribeiro
The question refers to submitting a task simultaneously to all workers 
within a group.

Thank you

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


[web2py] Re: Run custom code upon error ticket issuance?

2018-02-15 Thread Francisco Ribeiro
That is useful but is it really equivalent to error ticket issuance i.e. do 
all tickets we see as error tickets hit the routes_onerror?  What if the 
error is triggered by a scheduled task running in the background?

Thanks

On Thursday, 15 February 2018 17:43:58 UTC, Leonel Câmara wrote:
>
> I'd say the easiest way would be to use routes_on_error, you can put a 
> controller function of your application there.
>
> On you web2py directory you would make a routes.py with 
>
> routes_onerror = [
>   ('myapp/*', '/myapp/default/error')
> ]
>
>
>
> Then on default.py you could have a function like this:
>
> def error():
> code = request.vars.code
> ticket = request.vars.ticket
> if code == '500':
> # do your websocket stuff
> return locals()  # Make sure you have a error.html for the visitor to 
> get a nice error page
>
>
>
>

-- 
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] Run custom code upon error ticket issuance?

2018-02-15 Thread Francisco Ribeiro
Hi all,

I have created an event viewer web console that uses websockets to keep 
itself up to date. 
I wanted error tickets to show up in here as well, so once a ticket is 
issued it would execute my custom code that keeps my event viewer up to 
date with a link to the ticket itself.
Ideally, the solution should not involve changing web2py source code since 
I could lose my changes once I upgrade web2py but if it comes to that, i'm 
OK with it.

Thanks in advance.

Kind regards,
Francisco

-- 
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: Bug with URL encoding?

2017-10-22 Thread Francisco Ribeiro
Thank you!

On Friday, 20 October 2017 16:32:49 UTC+1, Anthony wrote:
>
> By default, characters in args that do not match the '[^\w/.@=-]' regular 
> expression are replaced with underscores. To override that behavior, there 
> are two options:
>
>1. In routes.py, set routes_apps_raw to a list of applications that 
>will handle their own args parsing. In those apps, the entire args part of 
>the URL (everything in path_info after /app/controller/function) will be 
>available in request.raw_args, and you will have to parse it yourself.
>2. Use the parameter-based rewrite system and specify args_match to 
>suit your needs (the default args_match regex is '([\w@ =-]|(?<=[\w@ 
>-])[.])*$'.
>
> Anthony
>
> On Thursday, October 19, 2017 at 1:30:09 PM UTC-4, Francisco Ribeiro wrote:
>>
>> Hi,
>>
>> I have found that when I do request.args(), colons ':' even when properly 
>> URL encoded become an underscore '_' .
>>
>> def echo():
>> print request.args(0)
>> return dict()
>>
>> A request http://.../echo/%a_ will become :
>> __ 
>>
>> which prevents me from distinguishing one from another.
>>
>> Am I missing something? shouldn't request.args() take care of URL 
>> encoding / decoding for me?
>>
>> Thank you
>> Kind regards,
>> Francisco Ribeiro
>>
>

-- 
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] Bug with URL encoding?

2017-10-19 Thread Francisco Ribeiro
Hi,

I have found that when I do request.args(), colons ':' even when properly 
URL encoded become an underscore '_' .

def echo():
print request.args(0)
return dict()

A request http://.../echo/%a_ will become :
__ 

which prevents me from distinguishing one from another.

Am I missing something? shouldn't request.args() take care of URL encoding 
/ decoding for me?

Thank you
Kind regards,
Francisco Ribeiro

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


[web2py] Re: SQLFORM.smartgrid() custom field representation breaks exporting functions

2017-10-09 Thread Francisco Ribeiro
Well, actually I was able to hide it as well with CSS:
table th:nth-child(7) {display: none;}
table td:nth-child(7) {display: none;}

Not ideal since all this content is there twice but it works :)

On Monday, 9 October 2017 11:28:52 UTC+1, Francisco Ribeiro wrote:
>
> That works, (thanks for the idea btw) but leaves me with a different 
> problem which is that 'myfield' becomes visible and it happens to hold a 
> long string (reason why I came up with the idea to turn it into 
> copy-to-clipboard button). 
>
> On Monday, 9 October 2017 03:22:11 UTC+1, 黄祥 wrote:
>>
>> had you already tried to put the copy function in sqlform.grid(links) ?
>>
>> best regards,
>> stifan
>>
>

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


[web2py] Re: SQLFORM.smartgrid() custom field representation breaks exporting functions

2017-10-09 Thread Francisco Ribeiro
That works, (thanks for the idea btw) but leaves me with a different 
problem which is that 'myfield' becomes visible and it happens to hold a 
long string (reason why I came up with the idea to turn it into 
copy-to-clipboard button). 

On Monday, 9 October 2017 03:22:11 UTC+1, 黄祥 wrote:
>
> had you already tried to put the copy function in sqlform.grid(links) ?
>
> best regards,
> stifan
>

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


[web2py] SQLFORM.smartgrid() custom field representation breaks exporting functions

2017-10-08 Thread Francisco Ribeiro
hi,

I have customized one of the fields of my SQLForm whereby instead of 
displaying its long content, it shows a small button that copies its 
content into the clipboard, as follows:

db.mytable.myfield.represent = lambda value, row: TAG.button(SPAN(DIV(
row.myfield, _id="cp_"+str(row.id),_style="display:none"),_class='glyphicon 
glyphicon-copy'),_type="button",_onClick="copyToClipboard('#cp_%s'); 
$.web2py.flash('myfield copied: %s...');"% (row.id,value[:25]), _class=
"btn-primary")

( copyToClipboard() is a javascript function that pushes contents to the 
clipboard as the name suggests )

This works fine for most purposes until I try to export the table contents 
to CSV, HTML and TSV using the SQLForm.smartgrid() generated buttons with 
an error as follows:

 File ".../gluon/sqlhtml.py", line 3648, in export
self.rows.export_to_csv_file(s, represent=True)
  File "/local/path/site-packages/pydal/objects.py", line 2603, in 
export_to_csv_file
value = field.represent(value, record)
  File ".../controllers/analysis.py" 
, line 
77, in 
db.mytable.myfield.represent = lambda value, row: 
TAG.button(SPAN(DIV(row.myfield, 
_id="cp_"+str(row.id),_style="display:none"),_class='glyphicon 
glyphicon-copy'),_type="button",_onClick="copyToClipboard('#cp_%s'); 
$.web2py.flash('myfield copied: %s...');"% (row.id,value[:25]), 
_class="btn-primary")
  File "/local/path/site-packages/pydal/objects.py", line 99, in __getattr__
raise AttributeError
AttributeError


Exporting to JSON and XML works fine though. Am I doing something wrong? Is 
there a way to have my form customization working without breaking the export 
functionality?

Thank you

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


[web2py] Hiding fields in SQLForm but make them searchable AND usable within "links="

2017-09-25 Thread Francisco Ribeiro
This use case keeps on haunting me... :)

Sometimes i want to hide columns from a smartgrid but I still want to be 
able to search for them AND use it within the SQLFORM links parameter, like 
the 'fingerprint' parameter in the following example:

in model:
db.define_table('mytable',
Field('name'),
Field('score'),
Field('fingerprint'))


in controller I would have a function with:
db.mytable.fingerprint.represent = False # this will hide 'fingerprint' 
column but will also render it unusable from within links= parameter

grid = SQLFORM.smartgrid(db.mytable,links=[lambda row: SPAN(
A(callback=URL('update_fingerprint', args=['fixed', 
*row.fingerprint*])))], # <- row.fingerprint will break
fields=[db.mytable.name, db.mytable.score],
searchable=[db.mytable.tool_id, db.mytable.name, db.mytable.
fingerprint])

Thanks in advance

P.S.: I have actually wrote about this before in this group at 
https://groups.google.com/d/topic/web2py/EPO9RychvF4/discussion but I do 
not like my own solution for obvious reasons. Note that the other reply in 
that thread does not solve the problem since it does nothing to hide a 
column.




-- 
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: Stopping a loaded component

2017-09-15 Thread Francisco Ribeiro
Found a solution for this which is to add the 'w2p_component_stop' class 
onto the div, as follows:

  $('#my_target').addClass('w2p_component_stop');
  $('#my_target').html(''); 

this will break the infinite loop set by the call in my original post and 
then will hide the content left from the last iteration of the loop.

Francisco


On Friday, 15 September 2017 03:35:06 UTC+1, Francisco Ribeiro wrote:
>
> Hi all,
>
> I have a monitoring component in which my app continuously grabs data from 
> the database through a controller which is triggered by a javascript call 
> as follows:
>
> $.web2py.component("{{=URL('controller', 'my_function.load')}}", 
> "my_target", timeout=2000, times='Infinity');
>
> As you can see, this component is calling my controller every 2s for an 
> infinite number of times and it works well.
>
> Now, I would like to add an option to allow the user to arbitrarily stop 
> this monitoring component but I could not find a way to trap and stop the 
> JS call above (nor its reload_check) once the page and the component are 
> loaded. Any ideas?
>
> Thank you
> Kind regards,
> Francisco
>

-- 
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] Stopping a loaded component

2017-09-14 Thread Francisco Ribeiro
Hi all,

I have a monitoring component in which my app continuously grabs data from 
the database through a controller which is triggered by a javascript call 
as follows:

$.web2py.component("{{=URL('controller', 'my_function.load')}}", "my_target"
, timeout=2000, times='Infinity');

As you can see, this component is calling my controller every 2s for an 
infinite number of times and it works well.

Now, I would like to add an option to allow the user to arbitrarily stop 
this monitoring component but I could not find a way to trap and stop the 
JS call above (nor its reload_check) once the page and the component are 
loaded. Any ideas?

Thank you
Kind regards,
Francisco

-- 
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: PyCharm license for web2py dev - who wants?

2015-10-17 Thread Francisco Ribeiro
I think it's now time to close this seat count. Thank you all for coming 
back on this. 

Please note that this license is solely for web2py (the framework) 
development and not for web2py apps development in general or anything 
other thing. 

Finally, I think the number of people that showed interest in here is far 
greater than the number of people who messaged their email addresses. I 
will need your email address to send you the license so if you haven't done 
so please do it.

Kind regards,
Francisco


On Sunday, 11 October 2015 20:21:16 UTC+1, Francisco Ribeiro wrote:
>
> Hello all,
>
> for those who know PyCharm is a great IDE from JetBrains that provides 
> free licenses for Open Source projects like web2py ( 
> https://www.jetbrains.com/buy/opensource/?product=pycharm ). To request 
> such a license, I need to know how many of you would want one of these as 
> well so I can provide them with a number of seats. 
>
> A "+1" response for me is enough but I will also need your email address 
> to send you the license key (which you can send on a private message).
>
> Kind regards,
> Francisco
>

-- 
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] PyCharm license for web2py dev - who wants?

2015-10-17 Thread Francisco Ribeiro
PyCharm Pro supports web2py, yes.
Please note that this license is intended for web2py development as opposed 
to development in web2py.

On Monday, 12 October 2015 11:01:06 UTC+1, Paolo Amboni wrote:
>
> I'm using pycharm community edition, that for what I understand is free.
> Are these licenses for the pro version?
> Is the pro version supporting web2py?
> If yes i'm iterested.
>
> Il giorno domenica 11 ottobre 2015 21:29:54 UTC+2, Encompass solutions ha 
> scritto:
>>
>> I can try it if you want. +1
>>
>> On Sun, Oct 11, 2015, 22:21 Francisco Ribeiro <franci...@gmail.com> 
>> wrote:
>>
>>> Hello all,
>>>
>>> for those who know PyCharm is a great IDE from JetBrains that provides 
>>> free licenses for Open Source projects like web2py ( 
>>> https://www.jetbrains.com/buy/opensource/?product=pycharm ). To request 
>>> such a license, I need to know how many of you would want one of these as 
>>> well so I can provide them with a number of seats. 
>>>
>>> A "+1" response for me is enough but I will also need your email address 
>>> to send you the license key (which you can send on a private message).
>>>
>>> Kind regards,
>>> Francisco
>>>
>>> -- 
>>> 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+un...@googlegroups.com.
>>> For more options, visit https://groups.google.com/d/optout.
>>>
>>

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


[web2py] PyCharm license for web2py dev - who wants?

2015-10-11 Thread Francisco Ribeiro
Hello all,

for those who know PyCharm is a great IDE from JetBrains that provides free 
licenses for Open Source projects like web2py ( 
https://www.jetbrains.com/buy/opensource/?product=pycharm ). To request 
such a license, I need to know how many of you would want one of these as 
well so I can provide them with a number of seats. 

A "+1" response for me is enough but I will also need your email address to 
send you the license key (which you can send on a private message).

Kind regards,
Francisco

-- 
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: What are the usual steps for designing a web2py application?

2015-01-23 Thread Francisco Ribeiro
There is another way of looking at this which I think it's really 
effective. Don't guide your approach by user requirements because customers 
don't know what are their own requirements. Even we, think we do but many 
times, we don't. Guide your approach by something concrete based on rapid 
prototyping.

1) think of the layout (as a prototype). Not so much the details such as 
colours and font sizes but put into a wireframe what is the end result 
you want to achieve, in a very visual and quick manner. This forces you to 
implicitly define user requirements, use cases sequences user access roles 
and, of course, the layout itself. (it's also a good time to make 
assertions that can be used for tests)
2) Now you also now which type of data needs to be displayed and where but 
without a database schema, it may be hard to work on the controllers so 
it's a good time to model your database, if necessary of course.
3) Now you need to do the wiring from 1) and 2) and work on both the 
controllers and views.
4) Test it!

kind regards,
Francisco


On Friday, 23 January 2015 23:56:05 UTC, 黄祥 wrote:

 i think : 
 1. ask more detail about user requirement
 2. analysis and design database to match with user requirement
 3. analysis and design system flow to match with user requirement
 4. design the web layout
 5. testing the system flow, system security and web layout

 best regards,
 stifan


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


[web2py] Re: bug in IS_NOT_EMPTY() validator?

2014-12-05 Thread Francisco Ribeiro
Yes, Anthony you are right, there is no need to for more validators. Was 
just thinking of a different naming convention to clear the ambiguity we 
have now, because for checkboxes IS_NOT_EMPTY() means the same as 
IS_EQUAL_TO(True). Unfortunately, I don't think there is a way to achieve 
the behaviour I am looking for without adding some JavaScript on the client 
side when the form is generated in order to create a distinction between 
value not submitted (which is what the IS_NOT_EMPTY() would use) and False.

Thanks,
Francisco

On Thursday, 4 December 2014 16:23:35 UTC, Anthony wrote:

 I'm not sure I follow. What would an IS_CHECKED validator do? If the 
 purpose is to ensure a box is checked, then you can already use 
 IS_EQUAL_TO(True). But that's not the behavior you were looking for. You 
 wanted the validation to succeed whether or not the box was checked, and 
 the problem there is not with the validator but with the value that is 
 passed to the validator when the box is not checked. It's not clear how a 
 new validator would help here, as such a validator would be completely 
 superfluous.

 Anthony

 On Thursday, December 4, 2014 8:12:17 AM UTC-5, Francisco Ribeiro wrote:

 Anthony,
 this is what I'm doing now. I am aware of that, the problem starts on the 
 interpretation given to the request sent by the browser for checkboxes for 
 these fields which I thought it should be if it is toggled means True, if 
 not it means False. I do understand however that for most scenarios the 
 current interpretation is more useful. The alternative would be to add a 
 validator called IS_CHECKED() to include the distinction missing. 

 Thank you,
 Francisco 

 On Thursday, 4 December 2014 12:30:01 UTC, Anthony wrote:

 Note, the problem is not with the validator -- if you pass it the value 
 False, it will successfully validate. The issue is that when a checkbox is 
 not checked, the browser sends nothing back for that form field (it does 
 not send back a value of False), so the value passed to the validator ends 
 up being None rather than False.

 In your case, just change your code slightly so the validator doesn't 
 get assigned in the case of boolean fields. Assuming you have the field 
 type stored somehow:

 if is_required and type != 'boolean':

 Or better yet, just set is_required to False for boolean fields.

 Anthony

 On Thursday, December 4, 2014 7:00:00 AM UTC-5, Francisco Ribeiro wrote:

 Kiran, 
 I did not assign the default value of False explicitly but implicitly 
 since it's already the default.

 Anthony, 
 I understand the interpretation currently in place but if you think 
 about this, validators are supposed to accept allowed values *first* and 
 reject all others. True and False are the allowed values here and must 
 have 
 precedence to be accepted. Checkboxes are UIs for boolean types, so an 
 unticked box means False, it does not mean NULL.

 On my scenario I have a dynamically generated form using 
 SQLFORM.factory() where one my attributes for each form field is 
 is_required. So these things are stored on the DB, defining how the form 
 should be generated and the way I was handling it was by adding the 
 IS_NOT_EMPTY() validator to the form field if has the parameter 
 is_required 
 == True on its definition. It works fine for all other input fields tested 
 where IS_NOT_EMPTY() makes sense but checkboxes broke it.

 Kind regards,
 Francisco

 On Thursday, 4 December 2014 11:48:04 UTC, Anthony wrote:

 If a boolean widget can only be true or false and never empty, then 
 there is no need for this validator to begin with, so just remove it. Are 
 you suggesting that the validator itself should be changed to always 
 return 
 success for booleans? If so, what would be the point? 

 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] bug in IS_NOT_EMPTY() ?

2014-12-04 Thread Francisco Ribeiro
hi there,
I noticed that when I use the IS_NOT_EMPTY() validator on a boolean field 
(i.e. a form checkbox) that it will not allow me to submit the form with 
this field as not checked / unticked.  In my opinion, this is a wrong 
interpretation of what is an empty value, since a checkbox can only 
represent True or False and therefore it's never empty. The consequence of 
using this behaviour for the IS_NOT_EMPTY*() validator is that we are 
forcing users to choose True on a widget that is meant to provide a boolean 
choice between True OR False, so the whole purpose of this user interface 
widget, is lost. I only tested this with SQLFORM.factory() though.

Am I missing something?

Francisco

-- 
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: bug in IS_NOT_EMPTY() validator?

2014-12-04 Thread Francisco Ribeiro
Kiran, 
I did not assign the default value of False explicitly but implicitly since 
it's already the default.

Anthony, 
I understand the interpretation currently in place but if you think about 
this, validators are supposed to accept allowed values *first* and reject 
all others. True and False are the allowed values here and must have 
precedence to be accepted. Checkboxes are UIs for boolean types, so an 
unticked box means False, it does not mean NULL.

On my scenario I have a dynamically generated form using SQLFORM.factory() 
where one my attributes for each form field is is_required. So these 
things are stored on the DB, defining how the form should be generated and 
the way I was handling it was by adding the IS_NOT_EMPTY() validator to the 
form field if has the is_required parameter = True on its definition. It 
works fine for all other input fields tested where IS_NOT_EMPTY() makes 
sense but chechboxes broke it.

Kind regards,
Francisco

On Thursday, 4 December 2014 11:48:04 UTC, Anthony wrote:

 If a boolean widget can only be true or false and never empty, then there 
 is no need for this validator to begin with, so just remove it. Are you 
 suggesting that the validator itself should be changed to always return 
 success for booleans? If so, what would be the point? 

 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: bug in IS_NOT_EMPTY() validator?

2014-12-04 Thread Francisco Ribeiro
Anthony,
this is what I'm doing now. I am aware of that, the problem starts on the 
interpretation given to the request sent by the browser for checkboxes for 
these fields which I thought it should be if it is toggled means True, if 
not it means False. I do understand however that for most scenarios the 
current interpretation is more useful. The alternative would be to add a 
validator called IS_CHECKED() to include the distinction missing. 

Thank you,
Francisco 

On Thursday, 4 December 2014 12:30:01 UTC, Anthony wrote:

 Note, the problem is not with the validator -- if you pass it the value 
 False, it will successfully validate. The issue is that when a checkbox is 
 not checked, the browser sends nothing back for that form field (it does 
 not send back a value of False), so the value passed to the validator ends 
 up being None rather than False.

 In your case, just change your code slightly so the validator doesn't get 
 assigned in the case of boolean fields. Assuming you have the field type 
 stored somehow:

 if is_required and type != 'boolean':

 Or better yet, just set is_required to False for boolean fields.

 Anthony

 On Thursday, December 4, 2014 7:00:00 AM UTC-5, Francisco Ribeiro wrote:

 Kiran, 
 I did not assign the default value of False explicitly but implicitly 
 since it's already the default.

 Anthony, 
 I understand the interpretation currently in place but if you think about 
 this, validators are supposed to accept allowed values *first* and reject 
 all others. True and False are the allowed values here and must have 
 precedence to be accepted. Checkboxes are UIs for boolean types, so an 
 unticked box means False, it does not mean NULL.

 On my scenario I have a dynamically generated form using 
 SQLFORM.factory() where one my attributes for each form field is 
 is_required. So these things are stored on the DB, defining how the form 
 should be generated and the way I was handling it was by adding the 
 IS_NOT_EMPTY() validator to the form field if has the parameter is_required 
 == True on its definition. It works fine for all other input fields tested 
 where IS_NOT_EMPTY() makes sense but checkboxes broke it.

 Kind regards,
 Francisco

 On Thursday, 4 December 2014 11:48:04 UTC, Anthony wrote:

 If a boolean widget can only be true or false and never empty, then 
 there is no need for this validator to begin with, so just remove it. Are 
 you suggesting that the validator itself should be changed to always return 
 success for booleans? If so, what would be the point? 

 Anthony



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


Re: [web2py] Re: Scheduler misleading DEBUG logging when task reaches timeout

2014-11-24 Thread Francisco Ribeiro
Niphlod,
i have no expectations whatsoever and specially when it comes to undocumented 
features but merely reasonable hopes.

Now, let me be clear here, I also don't expect software to be always properly 
documented and specially Open-Source where talented and busy people like 
yourself generously contribute to.  I just mentioned it to explain my 
reasonable hope :)

Thank you for adding some input validation in there, it is essential.

Francisco

 On 24 Nov 2014, at 09:00, Niphlod niph...@gmail.com wrote:
 
 there's a difference between it's not documented and I expect it to do 
 that . 
 In python standard lib, multiprocessing.Process join() method accepts a 
 timeout, and that timeout argument can - theoretically - be 0. 
 If you try that outside the scheduler, the same thing happens ... 100% cpu 
 and erratic behaviour.
 
 in standard lib, timeout=None means let it run with no timeout, but the 
 scheduler doesn't allow a timeout=None for the reasons explained before. 
 
 summary: I'll send a patch to restrict the timeout value to be = 1 instead 
 of = 0.
  
 
 On Sunday, November 23, 2014 10:29:19 PM UTC+1, Francisco Ribeiro wrote:
 Niphlod, 
  let me tell you that the 0 is very often interpreted as disabled in 
 computing. For example in select()  the famous UNIX system call, uses that 
 convention for the timeout argument and the same happens when you use the 
 snapshop length = 0 argument in tcpdump -s 0 which is allowed but 
 certainly doesn't mean 0 length . It's not spectacularly wrong nor childish, 
 it's just a common and useful convention.
 So, once I did not find this in the documentation, i tried that just as I 
 tried timeout = None hoping to find it in use.
 
 I understand where you are coming from but tbh i think at this stage it's 
 too early for a scheduler engine to enforce that behaviour. There are 
 scenarios where you don't expect applications to block but if that happens 
 you might want to take different measures to analyse and handle what 
 happened (while it is still running) and not necessarily to have them 
 automatically killed. At the end of the day, a large timeout as you suggest, 
 allows me to achieve the same result but actually doing so is what makes me 
 feel a bit silly ;)
 
 Anyway, now I understand how it works, thank you.
 
 Kind regards,
 Francisco
 
 i did not find this on the documentation and 
 
 On Sunday, 23 November 2014 19:20:52 UTC, Niphlod wrote:
 timeout gets passed as it is to the underlying base function. Python with 
 timeout = 0 seems to exhibit a pretty strange behaviour, but I guess that 
 is allowed just because in python we're all consenting adults. 
 Launching something that needs to return in 0 time is clearly something 
 spectacularly wrong. 
 As it is, scheduler is bugged, in the sense that allowing a timeout=0 is 
 not safe. Until now, all consenting adults never used it, and perhaps we 
 should change the field to accept only integer starting from 1 rather than 
 0 (just to discourage consenting childs ;-P ).
 
 As web2py enforces good manners, there's no way to disable the timeout, 
 and I think it's a safe decision to keep. A task queued with no timeout 
 that can potentially block any other outstanding task in a task processor 
 is plain silly.
 That being said, if you don't want any (theoretical) timeout, if you pass, 
 e.g.,  timeout=99, you'll get  ~12 days of timeout. 
 If your task is still running at that time, killing it is something that 
 won't bother your application at all.
 
 -- 
 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 a topic in the Google 
 Groups web2py-users group.
 To unsubscribe from this topic, visit 
 https://groups.google.com/d/topic/web2py/3GyfgbJzAio/unsubscribe.
 To unsubscribe from this group and all its topics, send an email to 
 web2py+unsubscr...@googlegroups.com.
 For more options, visit https://groups.google.com/d/optout.

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


Re: [web2py] Re: Scheduler misleading DEBUG logging when task reaches timeout

2014-11-24 Thread Francisco Ribeiro
Niphlod,
i have no expectations whatsoever and specially when it comes to undocumented 
features but merely reasonable hopes.

Now, let me be clear here, I also don't expect software to be always properly 
documented and specially Open-Source where talented and busy people like 
yourself generously contribute to.  I just mentioned it to explain my 
reasonable hope :)

Thank you for adding some input validation in there, it is essential.

Francisco

 On 24 Nov 2014, at 09:00, Niphlod niph...@gmail.com wrote:
 
 there's a difference between it's not documented and I expect it to do 
 that . 
 In python standard lib, multiprocessing.Process join() method accepts a 
 timeout, and that timeout argument can - theoretically - be 0. 
 If you try that outside the scheduler, the same thing happens ... 100% cpu 
 and erratic behaviour.
 
 in standard lib, timeout=None means let it run with no timeout, but the 
 scheduler doesn't allow a timeout=None for the reasons explained before. 
 
 summary: I'll send a patch to restrict the timeout value to be = 1 instead 
 of = 0.
  
 
 On Sunday, November 23, 2014 10:29:19 PM UTC+1, Francisco Ribeiro wrote:
 Niphlod, 
  let me tell you that the 0 is very often interpreted as disabled in 
 computing. For example in select()  the famous UNIX system call, uses that 
 convention for the timeout argument and the same happens when you use the 
 snapshop length = 0 argument in tcpdump -s 0 which is allowed but 
 certainly doesn't mean 0 length . It's not spectacularly wrong nor childish, 
 it's just a common and useful convention.
 So, once I did not find this in the documentation, i tried that just as I 
 tried timeout = None hoping to find it in use.
 
 I understand where you are coming from but tbh i think at this stage it's 
 too early for a scheduler engine to enforce that behaviour. There are 
 scenarios where you don't expect applications to block but if that happens 
 you might want to take different measures to analyse and handle what 
 happened (while it is still running) and not necessarily to have them 
 automatically killed. At the end of the day, a large timeout as you suggest, 
 allows me to achieve the same result but actually doing so is what makes me 
 feel a bit silly ;)
 
 Anyway, now I understand how it works, thank you.
 
 Kind regards,
 Francisco
 
 i did not find this on the documentation and 
 
 On Sunday, 23 November 2014 19:20:52 UTC, Niphlod wrote:
 timeout gets passed as it is to the underlying base function. Python with 
 timeout = 0 seems to exhibit a pretty strange behaviour, but I guess that 
 is allowed just because in python we're all consenting adults. 
 Launching something that needs to return in 0 time is clearly something 
 spectacularly wrong. 
 As it is, scheduler is bugged, in the sense that allowing a timeout=0 is 
 not safe. Until now, all consenting adults never used it, and perhaps we 
 should change the field to accept only integer starting from 1 rather than 
 0 (just to discourage consenting childs ;-P ).
 
 As web2py enforces good manners, there's no way to disable the timeout, 
 and I think it's a safe decision to keep. A task queued with no timeout 
 that can potentially block any other outstanding task in a task processor 
 is plain silly.
 That being said, if you don't want any (theoretical) timeout, if you pass, 
 e.g.,  timeout=99, you'll get  ~12 days of timeout. 
 If your task is still running at that time, killing it is something that 
 won't bother your application at all.
 
 -- 
 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 a topic in the Google 
 Groups web2py-users group.
 To unsubscribe from this topic, visit 
 https://groups.google.com/d/topic/web2py/3GyfgbJzAio/unsubscribe.
 To unsubscribe from this group and all its topics, send an email to 
 web2py+unsubscr...@googlegroups.com.
 For more options, visit https://groups.google.com/d/optout.

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


[web2py] Re: Scheduler misleading DEBUG logging when task reaches timeout

2014-11-23 Thread Francisco Ribeiro
Niphlod, 
 let me tell you that the 0 is very often interpreted as disabled in 
computing. For example in select()  the famous UNIX system call, uses 
that convention for the timeout argument and the same happens when you 
use the snapshop length = 0 argument in tcpdump -s 0 which is allowed but 
certainly doesn't mean 0 length . It's not spectacularly wrong nor 
childish, it's just a common and useful convention.
So, once I did not find this in the documentation, i tried that just as I 
tried timeout = None hoping to find it in use.

I understand where you are coming from but tbh i think at this stage it's 
too early for a scheduler engine to enforce that behaviour. There are 
scenarios where you don't expect applications to block but if that happens 
you might want to take different measures to analyse and handle what 
happened (while it is still running) and not necessarily to have them 
automatically killed. At the end of the day, a large timeout as you 
suggest, allows me to achieve the same result but actually doing so is what 
makes me feel a bit silly ;)

Anyway, now I understand how it works, thank you.

Kind regards,
Francisco

i did not find this on the documentation and 

On Sunday, 23 November 2014 19:20:52 UTC, Niphlod wrote:

 timeout gets passed as it is to the underlying base function. Python with 
 timeout = 0 seems to exhibit a pretty strange behaviour, but I guess that 
 is allowed just because in python we're all consenting adults. 
 Launching something that needs to return in 0 time is clearly something 
 spectacularly wrong. 
 As it is, scheduler is bugged, in the sense that allowing a timeout=0 is 
 not safe. Until now, all consenting adults never used it, and perhaps we 
 should change the field to accept only integer starting from 1 rather than 
 0 (just to discourage consenting childs ;-P ).

 As web2py enforces good manners, there's no way to disable the timeout, 
 and I think it's a safe decision to keep. A task queued with no timeout 
 that can potentially block any other outstanding task in a task processor 
 is plain silly.
 That being said, if you don't want any (theoretical) timeout, if you pass, 
 e.g.,  timeout=99, you'll get  ~12 days of timeout. 
 If your task is still running at that time, killing it is something that 
 won't bother your application at all.



-- 
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: Scheduler misleading DEBUG logging when task reaches timeout

2014-11-21 Thread Francisco Ribeiro
just create and trigger the following task:
def schedule_call():
import time
time.sleep(3600)
return 'completed'


and queue it like:
myscheduler.queue_task(schedule_call, timeout=0)

once it's triggered check the CPU load of your python scheduler node and 
should be 100%.

If this is not enough to reproduce the issue, please let me know, I will 
see you a full app.

Thank you.

Kind regards,
Francisco

On Thursday, 20 November 2014 19:42:25 UTC, Niphlod wrote:

 if you care to post an app that reproduces the behaviour, I'd be glad to 
 iron out the bug, if there's one.

 On Thursday, November 20, 2014 12:07:50 PM UTC+1, Francisco Ribeiro wrote:

 thank you,

 a different and yet related problem that I found when I was testing the 
 timeout behaviour using a simple task that just does a time.sleep(3000) is 
 that this keeps the CPU load of its process close to 100% during the whole 
 time. This, however it's not a CPU intensive function and you won't find 
 this behaviour if you test it outside of the scheduler. There seems to be 
 room for optimisations since this means that a small number of lightweight 
 tasks that for some reason need more time to complete, will quickly consume 
 CPU.

 Kind regards,
 Francisco 

 On Thursday, 20 November 2014 09:57:05 UTC, Niphlod wrote:

 the new task report line is logged when the status is either COMPLETED 
 or FAILED. 
 These are not the statuses of the task itself, it's the status of the 
 task being returned by the executor process, that knows only if the task 
 ended correctly or raised some exceptions. 
 The finer grained statuses are computed back in the worker process 
 (the report_task() routine, to be exact), that knows, e.g., if a task needs 
 to be queued again, etc etc etc

 On Thursday, November 20, 2014 4:30:36 AM UTC+1, Francisco Ribeiro wrote:

 hi,

 After some debugging, I noticed that when tasks timeout while using the 
 scheduler, I get an output as follows:
 DEBUG:web2py.app.myapp:new task report: FAILED
 DEBUG:web2py.app.myapp:   traceback: Traceback (most recent call last):
   File /../web2py/gluon/scheduler.py, line 303, in executor
 result = dumps(_function(*args, **vars))
   File applications/myapp/models/db.py, line 337, in schedule_call
 time.sleep(3600)
   File /.../web2py/gluon/scheduler.py, line 704, in lambda
 signal.signal(signal.SIGTERM, lambda signum, stack_frame: sys.exit(
 1))
 SystemExit: 1

 Whilst the timeout behaviour happens just as I expect it to be and 
 things get stored correctly on the database (scheduler_run.status = 
 'TIMEOUT'), this debugging output is somewhat misleading since 'FAILED' 
 seems to be an alternative state different than 'TIMEOUT' according to 
 documentation ( 
 http://www.web2py.com/books/default/image/29/ce8edcc3.png ).

 Can someone explain to me why this happens? Is it expectable? 

 Thank you.
 Kind regards,
 Francisco



-- 
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: Scheduler misleading DEBUG logging when task reaches timeout

2014-11-21 Thread Francisco Ribeiro
So, by disabling the timeout, I'm making sure that the scheduler will be 
taken by that process for 3600s rather than being released on its own 
through a term signal triggered by a timeout. This way, you should be able 
to easily verify the high CPU load caused by any task loaded into the 
scheduler.

Kind regards,
Francisco

On Friday, 21 November 2014 13:13:04 UTC, Niphlod wrote:

 will do. in the meantime with timeout=0 what are you trying to achieve 
 ?

 On Friday, November 21, 2014 12:42:54 PM UTC+1, Francisco Ribeiro wrote:

 just create and trigger the following task:
 def schedule_call():
 import time
 time.sleep(3600)
 return 'completed'


 and queue it like:
 myscheduler.queue_task(schedule_call, timeout=0)

 once it's triggered check the CPU load of your python scheduler node and 
 should be 100%.

 If this is not enough to reproduce the issue, please let me know, I will 
 see you a full app.

 Thank you.

 Kind regards,
 Francisco

 On Thursday, 20 November 2014 19:42:25 UTC, Niphlod wrote:

 if you care to post an app that reproduces the behaviour, I'd be glad to 
 iron out the bug, if there's one.

 On Thursday, November 20, 2014 12:07:50 PM UTC+1, Francisco Ribeiro 
 wrote:

 thank you,

 a different and yet related problem that I found when I was testing the 
 timeout behaviour using a simple task that just does a time.sleep(3000) is 
 that this keeps the CPU load of its process close to 100% during the whole 
 time. This, however it's not a CPU intensive function and you won't find 
 this behaviour if you test it outside of the scheduler. There seems to be 
 room for optimisations since this means that a small number of lightweight 
 tasks that for some reason need more time to complete, will quickly 
 consume 
 CPU.

 Kind regards,
 Francisco 

 On Thursday, 20 November 2014 09:57:05 UTC, Niphlod wrote:

 the new task report line is logged when the status is either 
 COMPLETED or FAILED. 
 These are not the statuses of the task itself, it's the status of the 
 task being returned by the executor process, that knows only if the 
 task 
 ended correctly or raised some exceptions. 
 The finer grained statuses are computed back in the worker 
 process (the report_task() routine, to be exact), that knows, e.g., if a 
 task needs to be queued again, etc etc etc

 On Thursday, November 20, 2014 4:30:36 AM UTC+1, Francisco Ribeiro 
 wrote:

 hi,

 After some debugging, I noticed that when tasks timeout while using 
 the scheduler, I get an output as follows:
 DEBUG:web2py.app.myapp:new task report: FAILED
 DEBUG:web2py.app.myapp:   traceback: Traceback (most recent call last
 ):
   File /../web2py/gluon/scheduler.py, line 303, in executor
 result = dumps(_function(*args, **vars))
   File applications/myapp/models/db.py, line 337, in schedule_call
 time.sleep(3600)
   File /.../web2py/gluon/scheduler.py, line 704, in lambda
 signal.signal(signal.SIGTERM, lambda signum, stack_frame: sys.
 exit(1))
 SystemExit: 1

 Whilst the timeout behaviour happens just as I expect it to be and 
 things get stored correctly on the database (scheduler_run.status = 
 'TIMEOUT'), this debugging output is somewhat misleading since 'FAILED' 
 seems to be an alternative state different than 'TIMEOUT' according to 
 documentation ( 
 http://www.web2py.com/books/default/image/29/ce8edcc3.png ).

 Can someone explain to me why this happens? Is it expectable? 

 Thank you.
 Kind regards,
 Francisco



-- 
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: Scheduler misleading DEBUG logging when task reaches timeout

2014-11-21 Thread Francisco Ribeiro
Now, that is amusing :)
that timeout = 0 is triggering an endless loop which actually works as a 
way to prevent the app from timing out! It also explains the problem at 
hands, i.e. the intense CPU load so there is some progress here. Out of 
curiosity, the same behaviour (both disabling timeout and high CPU load) 
happens if I use timeout = None. 

So the question is, what is the appropriate way of disabling the timeout ? 
Could not find that in the docs..

Thank you,
Francisco

On Friday, 21 November 2014 20:02:15 UTC, Niphlod wrote:

 0 doesn't disable the timeout. it sets it to 0. which is kinda the 
 nonsense I was trying to figure it out ;-P

 On Friday, November 21, 2014 4:47:53 PM UTC+1, Francisco Ribeiro wrote:

 So, by disabling the timeout, I'm making sure that the scheduler will be 
 taken by that process for 3600s rather than being released on its own 
 through a term signal triggered by a timeout. This way, you should be able 
 to easily verify the high CPU load caused by any task loaded into the 
 scheduler.

 Kind regards,
 Francisco

 On Friday, 21 November 2014 13:13:04 UTC, Niphlod wrote:

 will do. in the meantime with timeout=0 what are you trying to 
 achieve ?

 On Friday, November 21, 2014 12:42:54 PM UTC+1, Francisco Ribeiro wrote:

 just create and trigger the following task:
 def schedule_call():
 import time
 time.sleep(3600)
 return 'completed'


 and queue it like:
 myscheduler.queue_task(schedule_call, timeout=0)

 once it's triggered check the CPU load of your python scheduler node 
 and should be 100%.

 If this is not enough to reproduce the issue, please let me know, I 
 will see you a full app.

 Thank you.

 Kind regards,
 Francisco

 On Thursday, 20 November 2014 19:42:25 UTC, Niphlod wrote:

 if you care to post an app that reproduces the behaviour, I'd be glad 
 to iron out the bug, if there's one.

 On Thursday, November 20, 2014 12:07:50 PM UTC+1, Francisco Ribeiro 
 wrote:

 thank you,

 a different and yet related problem that I found when I was testing 
 the timeout behaviour using a simple task that just does a 
 time.sleep(3000) 
 is that this keeps the CPU load of its process close to 100% during the 
 whole time. This, however it's not a CPU intensive function and you 
 won't 
 find this behaviour if you test it outside of the scheduler. There seems 
 to 
 be room for optimisations since this means that a small number of 
 lightweight tasks that for some reason need more time to complete, will 
 quickly consume CPU.

 Kind regards,
 Francisco 

 On Thursday, 20 November 2014 09:57:05 UTC, Niphlod wrote:

 the new task report line is logged when the status is either 
 COMPLETED or FAILED. 
 These are not the statuses of the task itself, it's the status of 
 the task being returned by the executor process, that knows only if 
 the 
 task ended correctly or raised some exceptions. 
 The finer grained statuses are computed back in the worker 
 process (the report_task() routine, to be exact), that knows, e.g., if 
 a 
 task needs to be queued again, etc etc etc

 On Thursday, November 20, 2014 4:30:36 AM UTC+1, Francisco Ribeiro 
 wrote:

 hi,

 After some debugging, I noticed that when tasks timeout while using 
 the scheduler, I get an output as follows:
 DEBUG:web2py.app.myapp:new task report: FAILED
 DEBUG:web2py.app.myapp:   traceback: Traceback (most recent call 
 last):
   File /../web2py/gluon/scheduler.py, line 303, in executor
 result = dumps(_function(*args, **vars))
   File applications/myapp/models/db.py, line 337, in 
 schedule_call
 time.sleep(3600)
   File /.../web2py/gluon/scheduler.py, line 704, in lambda
 signal.signal(signal.SIGTERM, lambda signum, stack_frame: sys.
 exit(1))
 SystemExit: 1

 Whilst the timeout behaviour happens just as I expect it to be and 
 things get stored correctly on the database (scheduler_run.status = 
 'TIMEOUT'), this debugging output is somewhat misleading since 
 'FAILED' 
 seems to be an alternative state different than 'TIMEOUT' according to 
 documentation ( 
 http://www.web2py.com/books/default/image/29/ce8edcc3.png ).

 Can someone explain to me why this happens? Is it expectable? 

 Thank you.
 Kind regards,
 Francisco



-- 
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: Scheduler misleading DEBUG logging when task reaches timeout

2014-11-20 Thread Francisco Ribeiro
thank you,

a different and yet related problem that I found when I was testing the 
timeout behaviour using a simple task that just does a time.sleep(3000) is 
that this keeps the CPU load of its process close to 100% during the whole 
time. This, however it's not a CPU intensive function and you won't find 
this behaviour if you test it outside of the scheduler. There seems to be 
room for optimisations since this means that a small number of lightweight 
tasks that for some reason need more time to complete, will quickly consume 
CPU.

Kind regards,
Francisco 

On Thursday, 20 November 2014 09:57:05 UTC, Niphlod wrote:

 the new task report line is logged when the status is either COMPLETED 
 or FAILED. 
 These are not the statuses of the task itself, it's the status of the task 
 being returned by the executor process, that knows only if the task ended 
 correctly or raised some exceptions. 
 The finer grained statuses are computed back in the worker process 
 (the report_task() routine, to be exact), that knows, e.g., if a task needs 
 to be queued again, etc etc etc

 On Thursday, November 20, 2014 4:30:36 AM UTC+1, Francisco Ribeiro wrote:

 hi,

 After some debugging, I noticed that when tasks timeout while using the 
 scheduler, I get an output as follows:
 DEBUG:web2py.app.myapp:new task report: FAILED
 DEBUG:web2py.app.myapp:   traceback: Traceback (most recent call last):
   File /../web2py/gluon/scheduler.py, line 303, in executor
 result = dumps(_function(*args, **vars))
   File applications/myapp/models/db.py, line 337, in schedule_call
 time.sleep(3600)
   File /.../web2py/gluon/scheduler.py, line 704, in lambda
 signal.signal(signal.SIGTERM, lambda signum, stack_frame: sys.exit(1
 ))
 SystemExit: 1

 Whilst the timeout behaviour happens just as I expect it to be and things 
 get stored correctly on the database (scheduler_run.status = 'TIMEOUT'), 
 this debugging output is somewhat misleading since 'FAILED' seems to be an 
 alternative state different than 'TIMEOUT' according to documentation ( 
 http://www.web2py.com/books/default/image/29/ce8edcc3.png ).

 Can someone explain to me why this happens? Is it expectable? 

 Thank you.
 Kind regards,
 Francisco



-- 
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 misleading DEBUG logging when task reaches timeout

2014-11-19 Thread Francisco Ribeiro
hi,

After some debugging, I noticed that when tasks timeout while using the 
scheduler, I get an output as follows:
DEBUG:web2py.app.myapp:new task report: FAILED
DEBUG:web2py.app.myapp:   traceback: Traceback (most recent call last):
  File /../web2py/gluon/scheduler.py, line 303, in executor
result = dumps(_function(*args, **vars))
  File applications/myapp/models/db.py, line 337, in schedule_call
time.sleep(3600)
  File /.../web2py/gluon/scheduler.py, line 704, in lambda
signal.signal(signal.SIGTERM, lambda signum, stack_frame: sys.exit(1))
SystemExit: 1

Whilst the timeout behaviour happens just as I expect it to be and things 
get stored correctly on the database (scheduler_run.status = 'TIMEOUT'), 
this debugging output is somewhat misleading since 'FAILED' seems to be an 
alternative state different than 'TIMEOUT' according to documentation 
( http://www.web2py.com/books/default/image/29/ce8edcc3.png ).

Can someone explain to me why this happens? Is it expectable? 

Thank you.
Kind regards,
Francisco

-- 
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: Customizing generated columns from SQLFROM.grid

2014-10-21 Thread Francisco Ribeiro
child's play!

Answer to my own question:
==

on the db file, add the following:
def get_index(grid, colname):
return grid.rows.colnames.index(colname)


def apply_title_to_column(grid, title_list, column_number):
for cell,title in zip(grid[2][0][0][2], title_list):
if title is not None and str(title) != td/td and str(title) != 
tdNone/td:
cell[column_number]=TD(cell[column_number][0],_title=title)


def get_table_rows(grid):
return grid[2][0][0][2]


def get_column(grid, column_number):
return [row[column_number] for row in get_table_rows(grid)]


def remove_grid_column(grid, column_number):
del grid[2][0][0][0][column_number]
del grid[2][0][0][1][0][column_number]
for row in get_table_rows(grid):
del row[column_number]


def add_titles(grid):
cols_to_delete=[]
for colname in grid.rows.colnames:
if colname.endswith('_msg'):
cols_to_delete.append(get_index(grid, colname))
title_list = get_column(grid, get_index(grid, colname))
apply_title_to_column(grid, title_list,  get_index(grid, colname
[:-4]))


for col_number in reversed(cols_to_delete):
remove_grid_column(grid, col_number)

# then on the controller you can have something like:
def housegrid():

grid=SQLFORM.smartgrid(db.house)
add_titles(grid)
return grid

# view code:
{{=LOAD('default','housegrid.load', ajax=True)}}

Notes:

   - this code is outrageous, egregious, preposterous but it works and it's 
   quite modular if you want to use it for other changes like this.
   - one nice detail about this is that you can still make all your 
   queries, including within the fields that are now only being shown on mouse 
   hovering 
   - an alternative approach would be to use jQuery manipulations in the 
   DOM but this looks a lot more resilient and decoupled from the view side of 
   things
   - obviously, this uses internals that can be modified at any time so 
   backward compatibility can not be assured even though this should be very 
   rare.
   - it would be nice to have an API for grids. I think there is this big 
   jump for database records to generated HTML code ready to be rendered, 
   not so much control over the Application logic on it.
   

Kind regards,
Francisco 


On Saturday, 18 October 2014 15:00:33 UTC+1, Francisco Ribeiro wrote:

 hello everyone,
 I believe I have ran into a dead end but maybe one of you may find a way 
 for what I'm trying to do. So, please consider this model:

 db.define_table('house',
 Field('location_type', requires=IS_IN_SET(['city', 'country', 'sea'])),
 Field('location_type_msg'),
 Field('capacity', requires=IS_IN_SET(['single', 'couple', 'small 
 family', 'big family']),
 Field('capacity_msg'))

 you can see the pattern I used in the field names, fieldname followed by 
 fieldname_msg.

 Now, what I want to do is to generate a grid with only two columns 
 location_type and capacity where location_type_msg and capacity_msg 
 would be accessible once you mouse hover  through their respective fields.

 Example:

 id | location_type | capacity
 ===
 1  | city |   single
 2  | sea | small family

 now if i go over the word 'city' I would see something like New York or 
 London and if I mouse hover small family i would see something like 90 
 square meters
 hope it makes sense.

 Thank you,
 Kind regards
 Francisco


-- 
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] Customizing generated columns from SQLFROM.grid

2014-10-18 Thread Francisco Ribeiro
hello everyone,
I believe I have ran into a dead end but maybe one of you may find a way 
for what I'm trying to do. So, please consider this model:

db.define_table('house',
Field('location_type', requires=IS_IN_SET(['city', 'country', 'sea'])),
Field('location_type_msg'),
Field('capacity', requires=IS_IN_SET(['single', 'couple', 'small 
family', 'big family']),
Field('capacity_msg'))

you can see the pattern I used in the field names, fieldname followed by 
fieldname_msg.

Now, what I want to do is to generate a grid with only two columns 
location_type and capacity where location_type_msg and capacity_msg 
would be accessible once you mouse hover  through their respective fields.

Example:

id | location_type | capacity
===
1  | city |   single
2  | sea | small family

now if i go over the word 'city' I would see something like New York or 
London and if I mouse hover small family i would see something like 90 
square meters
hope it makes sense.

Thank you,
Kind regards
Francisco

-- 
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:36124] Re: Encoding problem (bug?)

2009-11-28 Thread Francisco Ribeiro
hi

Nice! Thank you for the attention. There is a good reason that I'm sure you 
deeply understand for me to be less connected... I've been finishing my mst. 
thesis. Work done, presentation finished more time free. 
Meanwhile, I've been working on some interesting projects including web2py 
based.

I've been digging on this problem and found out the source.
It has to do with the lack of encoding definition in the Translation files.
I added #coding: utf8 and it temporarly worked, until I've added a new T() 
entry in the code which made web2py to rewrite the T files (so it would include 
the new key) and then the first line gone making the proper encoding go away.

this can be considered a fix and it's backward compatible.

A nice solution would be to define somewhere an encoding to apply to an 
application.

--

You received this message because you are subscribed to the Google Groups 
web2py-users group.
To post to this group, send email to web...@googlegroups.com.
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en.




translations_encoding.patch
Description: Binary data