Re: [web2py] Re: Bootstrap datepicker plugin

2015-05-12 Thread Manuele Pesenti
Il 11/05/15 23:01, villas ha scritto:
> Thanks Leonel.
>
> BTW in your first post you said:   
> Field('birthdate', 'date', widget=bsdatepicker_widget) 
>
> It should be with brackets at the end:
> Field('birthdate', 'date', widget=bsdatepicker_widget()) 
No it shouldn't the widget parameter value sould be a callable.

M.

-- 
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: Init Script in Web2Py

2015-05-12 Thread A36_Marty
I am trying to follow the advice by Massimo and others on this thread but 
am missing something.

Specifically, the follow code is intended to check if a user group exists, 
and if not, create it.  Unfortunately it executes every time until the 
web2py server is restarted and the value is cached.

What do I need to change check/update the cache value correctly to see if a 
user group exists?

My current code:
### Make sure the general user group exist, if not, create them.
if cache.ram('init_generalusers_group', lambda:db(db.auth_group.role == 
'general_users').count() == 0, None):
print "inside general users init fx"
db.auth_group.insert(role = 'general_users',
 description = "A user group for all general 
users.")
cache.ram.clear('init_generalusers_group')

GENUSER_GROUP_ID = cache.ram("init_generalusers_group", 
lambda:db(db.auth_group.role == 'general_users').select().first().id, None)


Thanks in advance.

-- 
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: Bootstrap datepicker plugin

2015-05-12 Thread Leonel Câmara
Villas is right, this function call returns the callable, it's this way so 
you can use bootstrap datepicker options.

-- 
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 there a way to use auth_permission to allow user to access records based upon field value?

2015-05-12 Thread Alex Glaros


is there a way to use auth_permission to allow user to access records based 
upon field value?

 

right now in auth_permission we can only specify one record_id in a table.

 

what about all records in table db.organization whose field matches: 
*organization_name 
= 'IBM'*

 

is there a way to allow user to only access and modify those records?

 

thanks

 

Alex Glaros

-- 
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] Two SQLFORMs side by side?

2015-05-12 Thread Richard Vézina
Almost there... I make it works, but there is something weird going on
related to component... I have to figure it out... But you were doing thing
the wrong way basically...  add_function is for the main_table which
contains the city name...

I will send you back the corrected app when I found the issue with the
repeating load...

Richard

On Mon, May 11, 2015 at 4:39 PM, LoveWeb2py  wrote:

> No rush, Richard. Thank you for your help I really appreciate it.
>
> On Monday, May 11, 2015 at 4:34:14 PM UTC-4, Richard wrote:
>>
>> I will try to review it ASAP...
>>
>> On Mon, May 11, 2015 at 4:30 PM, LoveWeb2py  wrote:
>>
>> Here is my dummy app, Richard.
>>
>>
>> On Monday, May 11, 2015 at 3:50:20 PM UTC-4, Richard wrote:
>>
>> Did you make dummy app for testing it?
>>
>> Please attach it here and I have a look to your code... I can't help much
>> if I don't have a good idea of what you have done...
>>
>> new_exp_num=form.vars.exp_num
>>
>> This is something I left which should be adapted to your app...
>> form.vars.exp_num is the representation of the new inputed record... The
>> same field name you specify in the widget declaration for the field
>> attribute : db.table.representing_field, but that you get from the form
>> of the referenced table.
>>
>> Richard
>>
>>
>> On Mon, May 11, 2015 at 3:28 PM, LoveWeb2py  wrote:
>>
>> Thanks haha. Just checking. Still not having much luck. I'm getting a 500
>> error on the add function and can't figure out why
>>
>> when I try to edit my site I am getting an error for the "add function"
>> specified to add the
>> https://www.mywebsite.com/add_function/second_table_field
>> def add_function():
>> """
>> Modal form for adding element
>> """
>>
>>
>> buttons = [TAG.button((I('', _class='icon-ok icon-large icon-white'),
>> CAT('  '), STRONG(T('Add'))),
>>   _type='submit',
>>   _class='btn btn-small btn-primary',
>>   _id='add_button_id',
>>   _name='add_button',
>>   )]
>> form = SQLFORM(db.table, buttons=buttons, formstyle=formstyle,
>> separator=separator)
>> response.js = '$(document).ready(function(){
>> $(".input_wrapper").has(".error").addClass("inputError"); ' \
>>   '$(".w2p_fw").has(".error").addClass("control-group
>> error"); ' \
>>   '$(".w2p_fw").each(function(){
>> $(this).find(".error_wrapper").appendTo(this); }); });'
>> response.js += '$(document).ready(function(){
>> $("textarea").elastic(); });'
>> response.js += '$(document).ready(function () {
>> $("[rel=tooltip]").tooltip(); });'
>> if form.process(formname='add_form').accepted:
>> response.flash = T("Added")
>> target = request.args(0)
>> # close modal
>> response.js = '$("#{target}_modal-form").modal("hide");'.format(
>> target=target)
>> # update the select options
>> response.js += """$("#{target}").append(
>>"
>>{new_id}
>>");""".format(target=target, new_id=
>> form.vars.id)
>> # select newly added option
>> response.js += """$("#{target}").val("{new_exp_num}");
>>
>>   $('#{target}').keyup(); $('#{target}').blur();
>> """.format(target=target,
>>
>>  new_exp_num=form.vars.exp_num)
>> elif form.errors:
>> response.flash = ''
>> else:
>> response.flash = ''
>> return dict(form=form)
>>
>> Do I need to actually specify the db.table? From the looks of the class I
>> thought it would be defined on its own... am I wrong?
>>
>> Sorry for asking so many questions. I think this will be really helpful
>> when it's all finished.
>>
>>
>>
>>
>> On Monday, May 11, 2015 at 2:59:21 PM UTC-4, Richard wrote:
>>
>> The commented lines in the class was there because I recently refactor it
>> to make it use boostrap modal instead of jquery ui dialog as you may
>> understand carefully reading the code!!
>>
>> :-P
>>
>> Richard
>>
>> On Mon, May 11, 2015 at 2:40 PM, LoveWeb2py  wrote:
>>
>> Are the commented lines necessary or was that for self reference?
>>
>> # js += '$("#%s_option_add_trigger").
>> click(function() {' \
>> #   '$("#%s_dialog-form").dialog("open");' \
>> #   'return false;' \
>> #   '}); ' % (my_select_id, my_select_id)
>>
>>
>>
>> On Thursday, May 7, 2015 at 9:33:28 AM UTC-4, Richard wrote:
>>
>> you need bootstrap 2.3.2 (not tested with BS3, but I am pretty sure it is
>> not working, too differents)...
>>
>> Did you try it with a recent web2py setup? I would suggest you try with
>> web2py 2.9.5 which is what I use actually and it works...
>>
>> Richard
>>
>> On Thu, May 7, 2015 at 9:20 AM, LoveWeb2py  wrote:
>>
>> Another observation:
>>
>> All of this code:
>>
>>
>>
>> js += '$(function() {' \
>>   '$("#%s_option_add_trigger").button({

[web2py] Re: is there a way to use auth_permission to allow user to access records based upon field value?

2015-05-12 Thread Alex Glaros
I deleted same question a few days ago but just noticed Richard replied 
before I deleted:

On Monday, May 11, 2015 at 7:20:27 AM UTC-7, Richard wrote:
>
> You need to enforce it at controller level... What I usually do it to 
> filter the record user can view base on their role... The drawback depends 
> of your exact requirement is that they only see in grid what they are 
> allowed to modify or access...
>
> But nothing prevent you to display all record and only block update, so 
> can see all records in grid and the read form, but can't edit...
>
> This can be achieved at 2 level, you can remove the "modify" button form 
> read form view with a simple if which check for the role of the user and 
> the state of the record and at the controller level where you redirect the 
> user over an unify error page, to make sure that user that tamper with url 
> can't access the record that way...
>
> Here some code sample :
>
> # modify button
>  
> {{if auth.has_permission('update', request.args(0)):}}
> {{=A(I(_class='icon-edit icon-large'), SPAN(' '), STRONG(T('Edit')),
> _href=URL(c='yourcontroller', f='update', 
> args=(request.args(0), request.args(1))),
> _style='text-decoration : none; color: #333;', _class='btn 
> btn-small')}}
> {{pass}}
>
> # controller
> if not auth.has_permission('update', request.args(0)):
> redirect(URL(c='permission', f='not_authorized'))  # This page is 
> the same for each error message of the app when redirecting because 
> permissions issue which contains a details message and a message box that 
> the user can fill and send an email to request permissions changes to the 
> admin of the system.
>
> These 2 lines are the first lines of the controller... Notice the way I 
> use negative if to prevent having if else structure which would polute all 
> the reste of controller with indentation for this simple check...
>
> Richard
>

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


[web2py] Re: is there a way to use auth_permission to allow user to access records based upon field value?

2015-05-12 Thread Alex Glaros
@ Richard, (1) regarding this line {{if auth.has_permission('update', 
request.args(0)):}}, how does user get permissions in the first place (2) 
what would the args look like?  

@ Massimo, column-value-based permission would be very useful in situations 
like a data-mart where different users share same table but should not be 
allowed to see each other's data. Access control in auth_permission would 
only need to be in one place, but if done through the controller it 
introduces more opportunity for programmer error to expose sensitive data 
in many places if there are many controller functions for various purposes 
accessing the table throughout the app.  Think of a police or intelligence 
app where all persons are in one table but only want secret operatives 
revealed to restricted group. Or state licensing boards sharing same data 
but should not be allowed to view each other's licensee SSNs and 
investigative 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.


Re: [web2py] Two SQLFORMs side by side?

2015-05-12 Thread LoveWeb2py
Repeating load might be because I extended the layout in the view for the 
load. 

On Tuesday, May 12, 2015 at 10:22:41 AM UTC-4, Richard wrote:
>
> Almost there... I make it works, but there is something weird going on 
> related to component... I have to figure it out... But you were doing thing 
> the wrong way basically...  add_function is for the main_table which 
> contains the city name...
>
> I will send you back the corrected app when I found the issue with the 
> repeating load...
>
> Richard
>
> On Mon, May 11, 2015 at 4:39 PM, LoveWeb2py  > wrote:
>
> No rush, Richard. Thank you for your help I really appreciate it.
>
> On Monday, May 11, 2015 at 4:34:14 PM UTC-4, Richard wrote:
>
> I will try to review it ASAP...
>
> On Mon, May 11, 2015 at 4:30 PM, LoveWeb2py  wrote:
>
> Here is my dummy app, Richard. 
>
>
> On Monday, May 11, 2015 at 3:50:20 PM UTC-4, Richard wrote:
>
> Did you make dummy app for testing it?
>
> Please attach it here and I have a look to your code... I can't help much 
> if I don't have a good idea of what you have done...
>
> new_exp_num=form.vars.exp_num
>
> This is something I left which should be adapted to your app... 
> form.vars.exp_num is the representation of the new inputed record... The 
> same field name you specify in the widget declaration for the field 
> attribute : db.table.representing_field, but that you get from the form 
> of the referenced table.
>
> Richard
>
>
> On Mon, May 11, 2015 at 3:28 PM, LoveWeb2py  wrote:
>
> Thanks haha. Just checking. Still not having much luck. I'm getting a 500 
> error on the add function and can't figure out why 
>
> when I try to edit my site I am getting an error for the "add function" 
> specified to add the  
> https://www.mywebsite.com/add_function/second_table_field
> def add_function():
> """
> Modal form for adding element
> """
>
>
> buttons = [TAG.button((I('', _class='icon-ok icon-large icon-white'), 
> CAT('  '), STRONG(T('Add'))),
>   _type='submit',
>   _class='btn btn-small btn-primary',
>   _id='add_button_id',
>   _name='add_button',
>   )]
> form = SQLFORM(db.table, buttons=buttons, formstyle=formstyle, 
> separator=separator)
> response.js = '$(document).ready(function(){ 
> $(".input_wrapper").has(".error").addClass("inputError"); ' \
>   '$(".w2p_fw").has(".error").addClass("control-group 
> error"); ' \
>   '$(".w2p_fw").each(function(){ 
> $(this).find(".error_wrapper").appendTo(this); }); });'
> response.js += '$(document).ready(function(){ 
> $("textarea").elastic(); });'
> response.js += '$(document).ready(function () { 
> $("[rel=tooltip]").tooltip(); });'
> if form.process(formname='add_form').accepted:
> response.flash = T("Added")
> target = request.args(0)
> # close modal
> response.js = '$("#{target}_modal-form").modal("hide");'.format(
> target=target)
> # update the select options
> response.js += """$("#{target}").append(
>"
>{new_id}
>");""".format(target=target, new_id=
> form.vars.id)
> # select newly added option
> response.js += """$("#{target}").val("{new_exp_num}");
>
>   $('#{target}').keyup(); $('#{target}').blur();
> """.format(target=target,
>   
>  new_exp_num=form.vars.exp_num)
> elif form.errors:
> response.flash = ''
> else:
> response.flash = ''
> return dict(form=form)
>
> Do I need to actually specify the db.table? From the looks of the class I 
> thought it would be defined on its own... am I wrong?
>
> Sorry for asking so many questions. I think this will be really helpful 
> when it's all finished.
>
>
>
>
> On Monday, May 11, 2015 at 2:59:21 PM UTC-4, Richard wrote:
>
> The commented lines in the class was there because I recently refactor it 
> to make it use boostrap modal instead of jquery ui dialog as you may 
> understand carefully reading the code!!
>
> :-P
>
> Richard
>
> On Mon, May 11, 2015 at 2:40 PM, LoveWeb2py  wrote:
>
> Are the commented lines necessary or was that for self reference?
>
> # js += '$("#%s_option_add_trigger").
> click(function() {' \
> #   '$("#%s_dialog-form").dialog("open");' \
> #   'return false;' \
> #   '}); ' % (my_select_id, my_select_id)
>
>
>
> On Thursday, May 7, 2015 at 9:33:28 AM UTC-4, Richard wrote:
>
> you need bootstrap 2.3.2 (not tested with BS3, but I am pretty sure it is 
> not working, too differents)...
>
> Did you try it with a recent web2py setup? I would suggest you try with 
> web2py 2.9.5 which is what I use actually and it works...
>
> Richard
>
> On Thu, May 7, 2015 at 9:20 AM, LoveWeb2py  wrote:

[web2py] Re: is there a way to use auth_permission to allow user to access records based upon field value?

2015-05-12 Thread Anthony

>
> @ Massimo, column-value-based permission would be very useful in 
> situations like a data-mart where different users share same table but 
> should not be allowed to see each other's data. Access control in 
> auth_permission would only need to be in one place, but if done through the 
> controller it introduces more opportunity for programmer error to expose 
> sensitive data in many places if there are many controller functions for 
> various purposes accessing the table throughout the app.  Think of a police 
> or intelligence app where all persons are in one table but only want secret 
> operatives revealed to restricted group. Or state licensing boards sharing 
> same data but should not be allowed to view each other's licensee SSNs and 
> investigative data.
>

Note, you can handle that with a common filter on the table: 
http://web2py.com/books/default/chapter/29/06/the-database-abstraction-layer#Common-filters.
 
You can define the common filter based on the user's roles and/or 
permissions.

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] IS_IN_DB() multiple tables

2015-05-12 Thread kecajkecaj123
Sure, it's pretty simple:

DB:

db.define_table('ipaddress',
   Field('ip', unique=True, length=200,requires=IS_NOT_EMPTY()),
   Field('status', length=200, default="Free", 
requires=IS_IN_SET(['Free','Used'])),
   format = '%(ip)s')

db.define_table('server',
   Field('servername', length=200),
   Field('ipaddress', unique=True, length=200, 
requires=IS_IN_DB(db(db.ipaddress.status=='Free'),db.ipaddress.ip, 
'%(ip)s')))

def __after_insert_server(f, id):
db(db.ipaddress.ip == f.ipaddress).update(status = T('Used') )


def __before_delete_server(s):
db(db.ipaddress.ip == s.select()[0].ipaddress).update(status = T('Free'))   
 

def __before_update_server(s,f):
db(db.ipaddress.ip == s.select()[0].ipaddress).update(status = 
T('Free'))
db(db.ipaddress.ip == f['ipaddress']).update(status = T('Used') )

db.server._after_insert.append(__after_insert_server)
db.server._before_delete.append(__before_delete_server)
db.server._before_update.append(__before_update_server)


GRID:

def temp():
  
query=(db.server.id>0 )
fields=()
grid = SQLFORM.grid(query=query,fields=fields,user_signature=False)

return dict(grid=grid)




On Monday, 11 May 2015 15:49:10 UTC+2, Richard wrote:
>
> Ok, so the problem is that when you edit your record the dropbox field 
> shouldn't be blank... That is your issue, would you share the code of you 
> form and grid and the exact validators...
>
> There shoud be something that don't work somewhere...
>
> And it you may start here : requires=IS_IN_DB(db(db.ipadd
> ress.status=='Free'),db.ipaddress.ip, '%(ip)s')),
>
> It should read :
>
> requires=IS_IN_DB(db(db.ipaddress.status=='Free'),* 'ipaddr**ess.ip'*, 
> '%(ip)s')),
>
>
>
> Richard
>
> On Mon, May 11, 2015 at 9:14 AM, 黄祥 > 
> wrote:
>
>> why not use conditional requires base on url?
>> e.g.
>> if 'free' in request.controllers:
>>
>>
>>
>> On Monday, May 11, 2015 at 4:19:03 PM UTC+7, kecajk...@gmail.com wrote:
>>>
>>> Richard, 
>>>
>>> Let say that I have two IPs in ipaddress table:
>>>
>>> 10.1.1.1  FREE
>>> 10.2.2.2 FREE
>>>
>>> I add a server into server table, i put name as server1 and chose IP 
>>> from dropdown menu 10.1.1.1.
>>> Then my ipaddress table looks like that
>>> 10.1.1.1 USED
>>> 10.2.2.2 FREE
>>>
>>> But i noticed that i did a typo in server name... in fact server name 
>>> should be server111, so i use grid to display server table and use update 
>>> button next to "server1" record. I change server name to server111 and i 
>>> need to chose an IP again (as IP dropdown field is blank). So now i would 
>>> like to chose same IP as before, but I'm not able to do it, because 
>>> dropdown shows just 10.2.2.2 which make sense as i used 
>>>
>>>  requires=IS_IN_DB(db(db.ipaddress.status=='Free'),db.ipaddress.ip, 
>>> '%(ip)s')),
>>>
>>> So my question is how to make IP 10.1.1.1 visiable on the list when i'm 
>>> updating the record? 
>>>
>>> Regards.
>>>
>>> On Thursday, 7 May 2015 15:52:07 UTC+2, Richard wrote:

 Ok, I don't understand... Can you go back one step and explain what 
 kind of information you want to manage and why you think you have to 
 update 
 the IP address... Is there multiple records with the same server name if 
 so 
 why... It seems to me that you want to manage kind of history of IP 
 attached to a given device... If so, you DB schema is not sufficient, you 
 will need an archive table which will contains the old state of your 
 server 
 record... In your server table there will be only a single record for each 
 of your server and in the history table when you update this single record 
 the old state of the record will be copied there, so you can track all the 
 IP a given server had in the past... An history table is easy achieve in 
 web2py with record versioning...

 Richard

 On Thu, May 7, 2015 at 6:52 AM,  wrote:

> Hi, 
>
> What's the difference between what i wrote and what You wrote? 
> And i believe You didn't get my point. Checking if IP is Free works 
> correctly. Point is that i want do update the one row in Server table and 
> change i.e. server name. I click on update button provided by grid, and i 
> can change the name of the server (withouth changing its IP), but i need 
> to 
> chose an IP as well. Problem is that on the IP list, IP i used for that 
> server before is marked as Used, so i won't see it on the list and i 
> can't 
> chose it again. How to make it available for selection while i'm updating 
> the row.
>
> Thanks
> On Wednesday, 6 May 2015 16:52:05 UTC+2, Richard wrote:
>>
>> A set which you have, but your validator has wrong syntax :
>>
>> IS_IN_DB(db(db.ipaddress.status=='Free'),db.ipaddress.ip, '%(ip)s')
>>
>> free_ip_set = db(db.ipaddress.status=='Free')
>> IS_IN_DB(free_ip_set, 'ipaddress.ip', '%(ip)s')
>>
>> Try this... You define the set be

[web2py] Re: is there a way to use auth_permission to allow user to access records based upon field value?

2015-05-12 Thread Alex Glaros
Anthony,

trying to get basic syntax to work.  What is wrong with below?

auth.settings.extra_fields['auth_group']= [
Field('organizationID','integer'), common_filter = lambda query: 
db.auth_group.organizationID==7)] 

 File "C:/alex/web2py/web2py/web2py/applications/ES1/models/db.py" 
, line 129
Field('organizationID','integer'), common_filter = lambda query: 
db.auth_group.organizationID==7)]
 ^
SyntaxError: invalid syntax

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

2015-05-12 Thread Alan Etkin


> zvolsky also.
>
> On Monday, May 11, 2015 at 10:43:25 AM UTC-7, Derek wrote:
>>
>> Looks okay, needs to be pruned though as I see mirek posted a bunch of 
>> nonsense there.
>>
>
Done

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


[web2py] How to move a set of view,edit,delete buttons from last column to first column on SQLgrid?

2015-05-12 Thread Kenneth
Hello,

Lately, I've started playing with sqlgrid since it saves so much time 
pulling out all data in a page.

The problem is that I have a table with 20 attirbutes saved in it, it's 
hard to scroll to the end of right side and click on view/edit buttons. 

Is there any way to move those buttons to first column?

I don't know if it's possible without editing SQLgrid library code.

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] pack all - internal error - Error 3 - cache/chache

2015-05-12 Thread Tamer Bahget
Hi

I am totally new to Web2py and I was trying to use (Pack all) for the 
(Welcome) app when this error appeared:

internal error: [Error 3] The system cannot find the path specified:
'.../applications/welcome/cache/cache'

I am using Windows 7 , Python 2.7.9

Any ideas, please?

-- 
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] Deadlock in cache.py/CacheOnDisk in R 2.10.4

2015-05-12 Thread Bernard Letourmy
 We  found a blocking issue in our app with some image download after 
upgrading from 2.9.12 to 2.10.4

It turned out to be a deadlock in CacheOnDisk class in case of exception in 
our cache callback function, normally handled in our app
without any issue until now.

the new file_locks introduced in 2.10.1, (3e46e985bf15) acquired before the 
cache app callback ( value = f() )
with self.storage.acquire(CacheAbstract.cache_stats_name) 
Is never released in case of exception in f()
then next call to the CacheOnDisk during same request will block the thread 
indefinitely.

(CacheInRam should not have the same issue as self.locker.release() is 
released before f())

The following patch solves the issue for us.
Hope it could help

Bernard
 

> git diff -w  R-2.10.4 cache.py
>
> *diff --git a/gluon/cache.py b/gluon/cache.py*
> *index f94937d..9729e6b 100644*
> *--- a/gluon/cache.py*
> *+++ b/gluon/cache.py*@@ -473,7 +473,12 @@ class 
> CacheOnDisk(CacheAbstract):
>  if item and ((dt is None) or (item[0] > now - dt)):
>  value = item[1]
>  else:
> +try:
>  value = f()
> +except:
> +self.storage.release(CacheAbstract.cache_stats_name)
> +self.storage.release(key)
> +raise
>  self.storage[key] = (now, value)
>  self.storage.safe_apply(CacheAbstract.cache_stats_name, 
> inc_misses,
>  default_value={'hit_total': 0, 
> 'misses': 0})

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


[web2py] function

2015-05-12 Thread KevC
Hi community!

I want to call a function inside other function, What can I do?


For example:
def function_1():
y = 'This is an example'
(I wanna here my function "function_2")
return locals()

def function_2():
x = 'Hello world'
return locals()


My best regards.



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


[web2py] Export to csv which is not taking label from model file, where Grid takes.

2015-05-12 Thread Sujata Aghor

Hi,
In my model file I have defined table and Label for the fields like this - 
db.define_table('mytable',
Field('fname', 'string', length=12, writable=False,
  notnull=True, label='First Name'),
   Field('lname', 'string', length=12, writable=False,
  notnull=True, label='Last Name'),
...

1. In case of Grids, table headers are coming from  model file (shown 
above) No extra code has been written to show the labels from the model 
file.

2. So I was expecting the same headers would come to CSV file also, but 
surprisingly when I export to CSV we dont get these labels. (I tried by 
doing CSV=true in case of grid and still gets mytable.fname)

3. From documentation, I found Grid has additional parameter. i.e headers I 
tired to use that parameter to see if it works in export. So I defined 
headers as below :
headers = {'db.mytable.fname': 'First Name',
   'db.mytable.lname': 'Last Name'
  }

However export to CSV is still showing headers as db.mytable.fname

Kindly guide!
I suspect this is BUG in web2py export to csv which is not taking label 
from model file.

Thanks in Advance!!!

-- 
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] Why export to csv is not taking label from model file where as Grid does?

2015-05-12 Thread Sujata Aghor

​​Hi,
In my model file I have defined table and Label for the fields like this - 
db.define_table('mytable',
Field('fname', 'string', length=12, writable=False,
  notnull=True, label='First Name'),
   Field('lname', 'string', length=12, writable=False,
  notnull=True, label='Last Name'),
.

1. In case of Grids, table headers are coming from  model file (shown 
above) No extra code has been written to show the labels from the model 
file.

2. So I was expecting the same headers would come to CSV file also, but 
surprisingly when I export to CSV we dont get these labels. (I tried by 
doing CSV=true in case of grid and still gets mytable.fname)

3. From documentation, I found Grid has additional parameter. i.e headers I 
tired to use that parameter to see if it works in export. So I defined 
headers as below :
headers = {'db.mytable.fname': 'First Name',
   'db.mytable.lname': 'Last Name'
  }

However export to CSV is still showing headers as db.mytable.fname

Please guide.
I suspect this is BUG in web2py export to csv which is not taking label 
from model file.
Thanks in Advance!!!

-- 
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 registration fields for linkedin login

2015-05-12 Thread John Costantino
I have my application currently logging in and registering with linkedin. 
But when I register only a select few fields get filled. (first name, last 
name, email). I would like to also get the users public-url on 
registration. I am not sure how to do this. Is it possible for me to custom 
map specific info to the registration form? Anyone have any input on this? 
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] Export to csv is not taking label from model file where as Grid does.

2015-05-12 Thread Sujata Aghor
​
​​
Hi,
In my model file I have defined table and Label for the fields like this - 
db.define_table('mytable',
Field('fname', 'string', length=12, writable=False,
  notnull=True, label='First Name'),
   Field('lname', 'string', length=12, writable=False,
  notnull=True, label='Last Name'),
...

1. In case of Grids, table headers are coming from  model file (shown 
above) No extra code has been written to show the labels from the model 
file.

2. So I was expecting the same headers would come to CSV file also, but 
surprisingly when I export to CSV we dont get these labels. (I tried by 
doing CSV=true in case of grid and still gets mytable.fname)

3. From documentation, I found Grid has additional parameter. i.e headers I 
tired to use that parameter to see if it works in export. So I defined 
headers as below :
headers = {'db.mytable.fname': 'First Name',
   'db.mytable.lname': 'Last Name'
  }

However export to CSV is still showing headers as db.mytable.fname

Please guide.
I suspect this is BUG in web2py export to csv which is not taking label 
from model file.
Thanks in Advance!!!

-- 
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 registration Fields for Linkedin API log in.

2015-05-12 Thread John Costantino
I have gotten the linkedin Log in functioning properly. However when I 
register a use I would like to take in a few extra fields from that user. 
Is it possible to me to perhaps create mappings to specific fields in my DB 
to the attributes I will be pulling from the API call on registration?

-- 
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] Plugins Error

2015-05-12 Thread xmarx
hi!

when i click from design page 
(http://127.0.0.1:8000/admin/default/design/examples) "download plugins 
from repository" button, i get an error like this:

TypeError: list indices must be integers, not str


screenshot is there.

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: Plugins Error

2015-05-12 Thread Alan Etkin
El martes, 12 de mayo de 2015, 14:07:54 (UTC-3), xmarx escribió:
>
> hi!
>
> when i click from design page (
> http://127.0.0.1:8000/admin/default/design/examples) "download plugins 
> from repository" button, i get an error like this:
>
>
With what version? 

Maybe the admin app can't get the list of packages and the error is not 
catched. Mind that there is an issue about web2pyslices site domain
 

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

2015-05-12 Thread Derek
just call it...

function2()

you could even define the second function inside the first if you wanted.

On Tuesday, May 12, 2015 at 10:07:03 AM UTC-7, KevC wrote:
>
> Hi community!
>
> I want to call a function inside other function, What can I do?
>
>
> For example:
> def function_1():
> y = 'This is an example'
> (I wanna here my function "function_2")
> return locals()
>
> def function_2():
> x = 'Hello world'
> return locals()
>
>
> My best regards.
>
>
>
>

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


[web2py] Re: What's the proper way of using scheduler for multiple apps with one only db?

2015-05-12 Thread Dave S


On Monday, May 11, 2015 at 7:42:06 PM UTC-7, Lisandro wrote:
>
> I've figured it out: when using a central db for the scheduler, there is 
> no need (at least in this case) of calling web2py.py -K with all the apps, 
> just with the main app, in my case:
>
> python /home/user/web2py/web2py.py -K masterapp
>
> Sorry I bothered you. Maybe someday someone is having the same problem as 
> me, and ends up here with the solution :)
>

Hey, I appreciate someone working out the solution before I get there!

Thanks for the followup.

/dps

 

>
>
> El lunes, 11 de mayo de 2015, 21:15:03 (UTC-3), Lisandro escribió:
>>
>> I have *one master app* that handles the *main db, in which the 
>> scheduler tables have been created*.
>>
>> This master app has a scheduler.py module that looks like this (for now, 
>> with no function tasks defined):
>>
>> # -*- coding: utf-8 -*-
>> from gluon.scheduler import Scheduler
>> scheduler = Scheduler(db, max_empty_runs=5)
>>
>>
>> In the other hand, I have *multiple secondary apps*, each one with it's 
>> own db. 
>> All this applications *instantiate the scheduler specifying the central 
>> db*, like this:
>>
>> def test():
>> print 'this is just a test task'
>> return True
>>
>> from gluon.scheduler import Scheduler
>> db_scheduler = DAL('postgres://user:password@host/centraldb', 
>> lazy_tables=True, migrate=False)
>> scheduler = Scheduler(db_scheduler, max_empty_runs=5)
>>
>>
>> Then, *the tasks are queued from the master app*, like this:
>>
>> scheduler.queue_task('test', period=60, repeats=0, 
>> application_name='app1')
>> scheduler.queue_task('test', period=60, repeats=0, 
>> application_name='app2')
>> scheduler.queue_task('test', period=60, repeats=0, 
>> application_name='app3')
>>
>>
>> Then, I start the scheduler like this (from unix cron, every 5 minutes or 
>> so):
>>
>> python /home/user/web2py/web2py.py -K app1,app2,app3
>>
>> I can see the task moves to "RUNNING" state, but *the task stucks 
>> running until the configured timeout*.
>>
>> Am I using correctly the "application_name" parameter of the 
>> "queue_task()" function? 
>> I assume that the scheduler will pick up the task and check for that 
>> field, so the task function will be called in the context of the 
>> corresponding application.
>>
>> Notice that the scheduler.py model of the master app doesn't have any 
>> function defined.  Instead, taks functions are defined in the scheduler.py 
>> model of every secondary app. That's why, when I queue a task, I specify 
>> the application_name... However, at the end, the scheduler shows that the 
>> task is running (when it's not actually), and then the timeout.
>>
>> Any help will be really appreciated!
>>
>

-- 
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: Deadlock in cache.py/CacheOnDisk in R 2.10.4

2015-05-12 Thread Paolo Valleri
can you open an issue/pull request on github?

Paolo

On Tuesday, May 12, 2015 at 7:06:47 PM UTC+2, Bernard Letourmy wrote:
>
> We  found a blocking issue in our app with some image download after 
> upgrading from 2.9.12 to 2.10.4
>
> It turned out to be a deadlock in CacheOnDisk class in case of exception 
> in our cache callback function, normally handled in our app
> without any issue until now.
>
> the new file_locks introduced in 2.10.1, (3e46e985bf15) acquired before 
> the cache app callback ( value = f() )
> with self.storage.acquire(CacheAbstract.cache_stats_name) 
> Is never released in case of exception in f()
> then next call to the CacheOnDisk during same request will block the 
> thread indefinitely.
>
> (CacheInRam should not have the same issue as self.locker.release() is 
> released before f())
>
> The following patch solves the issue for us.
> Hope it could help
>
> Bernard
>  
>
>> git diff -w  R-2.10.4 cache.py
>>
>> *diff --git a/gluon/cache.py b/gluon/cache.py*
>> *index f94937d..9729e6b 100644*
>> *--- a/gluon/cache.py*
>> *+++ b/gluon/cache.py*@@ -473,7 +473,12 @@ class 
>> CacheOnDisk(CacheAbstract):
>>  if item and ((dt is None) or (item[0] > now - dt)):
>>  value = item[1]
>>  else:
>> +try:
>>  value = f()
>> +except:
>> +self.storage.release(CacheAbstract.cache_stats_name)
>> +self.storage.release(key)
>> +raise
>>  self.storage[key] = (now, value)
>>  self.storage.safe_apply(CacheAbstract.cache_stats_name, 
>> inc_misses,
>>  default_value={'hit_total': 0, 
>> 'misses': 0})
>
>

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


[web2py] Re: function

2015-05-12 Thread Dave S


On Tuesday, May 12, 2015 at 10:07:03 AM UTC-7, KevC wrote:
>
> Hi community!
>
> I want to call a function inside other function, What can I do?
>
>
> For example:
> def function_1():
> y = 'This is an example'
> (I wanna here my function "function_2")
> return locals()
>
> def function_2():
> x = 'Hello world'
> return locals()
>
>
> My best regards
>

Like Derek says, you just call it.  I did that to wrap a webpage (and form) 
around a call to a function_2() that has an @service decorator
(it's a SOAP provider for the normal clients, but I wanted to get the 
response in a browser as well).

I also have controllers that would be unreadable if I didn't split pieces 
out into supporting routines.  Since these aren't meant to be directly 
visible, they all have parameters (and most of them need the parameters); 
Web2Py will not expose functions with parameters.

I don't think I've done controllers with nested procedures (also mentioned 
by Derek), but it is a common enough Python technique.

/dps


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


[web2py] Re: Current logged in users

2015-05-12 Thread A36_Marty
Along the same lines, is there a way to log any/everyone out / even 
force-expiring cookies for users who have selected the "remember me" login 
option?

I asked due to noticing an auth_user record can be deleted but they can 
still access the system for functions decorated with @auth.requires_login

Thanks in advance

On Wednesday, September 17, 2014 at 8:06:51 PM UTC-5, Anthony wrote:
>
> See 
> http://stackoverflow.com/questions/12218989/get-all-logged-in-users-web2py/12224157#12224157
> .
>
> Anthony
>
> On Wednesday, September 17, 2014 8:48:22 PM UTC-4, Tito Garrido wrote:
>>
>> Hi Folks,
>>
>> Is there a way to list the current logged in users?
>>
>> Regards,
>>
>> Tito
>>
>> -- 
>>
>> Linux User #387870
>> .
>>  _/_õ|__|
>> ..º[ .-.___.-._| . . . .
>> .__( o)__( o).:___ 
>>
>

-- 
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's the proper way of using scheduler for multiple apps with one only db?

2015-05-12 Thread Lisandro
Sorry to say that wasn't completely the solution :/

Don't know exactly why, it ran ok during some minutes, and then I see that 
tasks didn't get executed.

I executed the worker manually with -D 0 option, and this is what I see:
DEBUG:pyDAL:Your database version does not support the JSON data type 
(using TEXT instead)
DEBUG:web2py.scheduler.medios#1905:defining tables (migrate=True)
DEBUG:web2py.scheduler.medios#1905:thread building own DAL object
DEBUG:web2py.scheduler.medios#1905:looping...
DEBUG:pyDAL:Your database version does not support the JSON data type 
(using TEXT instead)
DEBUG:web2py.scheduler.medios#1905:defining tables (migrate=False)
DEBUG:web2py.scheduler.medios#1905:freeing workers that have not sent 
heartbeat
INFO:web2py.scheduler.medios#1905:nothing to do
DEBUG:web2py.scheduler.medios#1905:sleeping...
DEBUG:web2py.scheduler.medios#1905:empty runs 1/5
INFO:web2py.scheduler.medios#1905:TICKER: I'm a ticker
DEBUG:web2py.scheduler.medios#1905:looping...
DEBUG:web2py.scheduler.medios#1905:Assigning tasks...
INFO:web2py.scheduler.medios#1905:TICKER: workers are 1
INFO:web2py.scheduler.medios#1905:TICKER: tasks are 0
DEBUG:web2py.scheduler.medios#1905:Tasks assigned...
DEBUG:web2py.scheduler.medios#1905:sleeping...
DEBUG:web2py.scheduler.medios#1905:empty runs 2/5
DEBUG:web2py.scheduler.medios#1905:recording heartbeat (ACTIVE)
DEBUG:web2py.scheduler.medios#1905:looping...
INFO:web2py.scheduler.medios#1905:nothing to do
DEBUG:web2py.scheduler.medios#1905:sleeping...
DEBUG:web2py.scheduler.medios#1905:empty runs 3/5
DEBUG:web2py.scheduler.medios#1905:recording heartbeat (ACTIVE)
DEBUG:web2py.scheduler.medios#1905:looping...
INFO:web2py.scheduler.medios#1905:nothing to do
DEBUG:web2py.scheduler.medios#1905:sleeping...
DEBUG:web2py.scheduler.medios#1905:empty runs 4/5
DEBUG:web2py.scheduler.medios#1905:recording heartbeat (ACTIVE)
DEBUG:web2py.scheduler.medios#1905:looping...
INFO:web2py.scheduler.medios#1905:nothing to do
DEBUG:web2py.scheduler.medios#1905:sleeping...
DEBUG:web2py.scheduler.medios#1905:empty runs 5/5
INFO:web2py.scheduler.medios#1905:empty runs limit reached, killing myself
INFO:web2py.scheduler.medios#1905:die!

It apperas to be all ok, however there are queued tasks and they aren't 
being executed.
Am I missing something?




El lunes, 11 de mayo de 2015, 21:15:03 (UTC-3), Lisandro escribió:
>
> I have *one master app* that handles the *main db, in which the scheduler 
> tables have been created*.
>
> This master app has a scheduler.py module that looks like this (for now, 
> with no function tasks defined):
>
> # -*- coding: utf-8 -*-
> from gluon.scheduler import Scheduler
> scheduler = Scheduler(db, max_empty_runs=5)
>
>
> In the other hand, I have *multiple secondary apps*, each one with it's 
> own db. 
> All this applications *instantiate the scheduler specifying the central 
> db*, like this:
>
> def test():
> print 'this is just a test task'
> return True
>
> from gluon.scheduler import Scheduler
> db_scheduler = DAL('postgres://user:password@host/centraldb', 
> lazy_tables=True, migrate=False)
> scheduler = Scheduler(db_scheduler, max_empty_runs=5)
>
>
> Then, *the tasks are queued from the master app*, like this:
>
> scheduler.queue_task('test', period=60, repeats=0, application_name='app1')
> scheduler.queue_task('test', period=60, repeats=0, application_name='app2')
> scheduler.queue_task('test', period=60, repeats=0, application_name='app3')
>
>
> Then, I start the scheduler like this (from unix cron, every 5 minutes or 
> so):
>
> python /home/user/web2py/web2py.py -K app1,app2,app3
>
> I can see the task moves to "RUNNING" state, but *the task stucks running 
> until the configured timeout*.
>
> Am I using correctly the "application_name" parameter of the 
> "queue_task()" function? 
> I assume that the scheduler will pick up the task and check for that 
> field, so the task function will be called in the context of the 
> corresponding application.
>
> Notice that the scheduler.py model of the master app doesn't have any 
> function defined.  Instead, taks functions are defined in the scheduler.py 
> model of every secondary app. That's why, when I queue a task, I specify 
> the application_name... However, at the end, the scheduler shows that the 
> task is running (when it's not actually), and then the timeout.
>
> Any help will be really appreciated!
>

-- 
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's the proper way of using scheduler for multiple apps with one only db?

2015-05-12 Thread Niphlod
 seems that there aren't any tasks in the database the scheduler is looking 
in. Sure that there are no misconfigurations ?

BTW: there's nothing wrong with your approach. A worker needs a "-K" 
argument only to inherit initialization options from that app: it's 
perfectly capable of processing tasks coming from different apps (of course 
they must exist in the server where the worker is running)

-- 
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: Export to csv which is not taking label from model file, where Grid takes.

2015-05-12 Thread Niphlod
the export are for raw processing, so they get the same result as you would 
get - for practical purposes - from db(query).select().as_csv()

On Tuesday, May 12, 2015 at 7:07:40 PM UTC+2, Sujata Aghor wrote:
>
>
> Hi,
> In my model file I have defined table and Label for the fields like this - 
> db.define_table('mytable',
> Field('fname', 'string', length=12, writable=False,
>   notnull=True, label='First Name'),
>Field('lname', 'string', length=12, writable=False,
>   notnull=True, label='Last Name'),
> ...
>
> 1. In case of Grids, table headers are coming from  model file (shown 
> above) No extra code has been written to show the labels from the model 
> file.
>
> 2. So I was expecting the same headers would come to CSV file also, but 
> surprisingly when I export to CSV we dont get these labels. (I tried by 
> doing CSV=true in case of grid and still gets mytable.fname)
>
> 3. From documentation, I found Grid has additional parameter. i.e headers 
> I tired to use that parameter to see if it works in export. So I defined 
> headers as below :
> headers = {'db.mytable.fname': 'First Name',
>'db.mytable.lname': 'Last Name'
>   }
>
> However export to CSV is still showing headers as db.mytable.fname
>
> Kindly guide!
> I suspect this is BUG in web2py export to csv which is not taking label 
> from model file.
>
> Thanks in Advance!!!
>

-- 
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: Export to csv is not taking label from model file where as Grid does.

2015-05-12 Thread Niphlod
double. replied in the other thread.

On Tuesday, May 12, 2015 at 7:07:17 PM UTC+2, Sujata Aghor wrote:
>
> ​
> ​​
> Hi,
> In my model file I have defined table and Label for the fields like this - 
> db.define_table('mytable',
> Field('fname', 'string', length=12, writable=False,
>   notnull=True, label='First Name'),
>Field('lname', 'string', length=12, writable=False,
>   notnull=True, label='Last Name'),
> ...
>
> 1. In case of Grids, table headers are coming from  model file (shown 
> above) No extra code has been written to show the labels from the model 
> file.
>
> 2. So I was expecting the same headers would come to CSV file also, but 
> surprisingly when I export to CSV we dont get these labels. (I tried by 
> doing CSV=true in case of grid and still gets mytable.fname)
>
> 3. From documentation, I found Grid has additional parameter. i.e headers 
> I tired to use that parameter to see if it works in export. So I defined 
> headers as below :
> headers = {'db.mytable.fname': 'First Name',
>'db.mytable.lname': 'Last Name'
>   }
>
> However export to CSV is still showing headers as db.mytable.fname
>
> Please guide.
> I suspect this is BUG in web2py export to csv which is not taking label 
> from model file.
> Thanks in Advance!!!
>

-- 
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 to move a set of view,edit,delete buttons from last column to first column on SQLgrid?

2015-05-12 Thread Niphlod
takend straight from the book at 
http://web2py.com/books/default/chapter/29/07/forms-and-validators#SQLFORM-grid-and-SQLFORM-smartgrid


*buttons_placement and links_placement both take a parameter ('right', 
'left', 'both') that will affect where on the row the buttons (or the 
links) will be placed*

On Tuesday, May 12, 2015 at 7:05:32 PM UTC+2, Kenneth wrote:
>
> Hello,
>
> Lately, I've started playing with sqlgrid since it saves so much time 
> pulling out all data in a page.
>
> The problem is that I have a table with 20 attirbutes saved in it, it's 
> hard to scroll to the end of right side and click on view/edit buttons. 
>
> Is there any way to move those buttons to first column?
>
> I don't know if it's possible without editing SQLgrid library code.
>
> 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: What's the proper way of using scheduler for multiple apps with one only db?

2015-05-12 Thread Lisandro
Thanks Niphlod. I double checked, and the tasks are there. 

The main app is called "medios" and has this in its model file:

db = DAL(\
  'postgres://%s:%s@%s/%s' %(DB_USER, DB_USER_PASSWORD, DB_HOST, DB_NAME), \
  lazy_tables=True)

from gluon.scheduler import Scheduler
scheduler = Scheduler(db, max_empty_runs=5)

The I start the worker like this:
 python /var/www/medios/web2py.py -K webmedios -D 0

I checked the scheduler_task table of the configured db and the tasks are 
there.
I tryied removing all content of scheduler tables, and then queuing the 
tasks again. But still the same output log. 

Maybe something wrong in the task data. This is on of the rows fo

Id: 93 
Application Name: demo 
Task Name: always 
Group Name: main 
Status: QUEUED 
Function Name: always 
Uuid: d2017a0a-c688-45f3-b112-cb1b2366dcce 
Args: [] 
Vars: {} 
Enabled: 
Start Time: 2015-05-12 15:55:06 
Next Run Time: 2015-05-12 15:55:06 
Stop Time: None 
Repeats: 0 0=unlimited
Retry Failed: -1 -1=unlimited
Period: 600 seconds
Prevent Drift: False
Timeout: 30 seconds
Sync Output: 0 
Times Run: 0 
Times Failed: 0 
Assigned Worker Name: 

I can see that the workers are created on the scheduler_worker table, but 
tasks are never picked up. 
I'm in production, using uwsgi + nginx. Already restarted uwsgi application.

El martes, 12 de mayo de 2015, 16:50:43 (UTC-3), Niphlod escribió:
>
>  seems that there aren't any tasks in the database the scheduler is 
> looking in. Sure that there are no misconfigurations ?
>
> BTW: there's nothing wrong with your approach. A worker needs a "-K" 
> argument only to inherit initialization options from that app: it's 
> perfectly capable of processing tasks coming from different apps (of course 
> they must exist in the server where the worker is running)
>

-- 
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's the proper way of using scheduler for multiple apps with one only db?

2015-05-12 Thread Niphlod
something is not adding up. if your app is called medios...and the log 
shows DEBUG:web2py.scheduler.medios ... why are you trying to start it with 
"webmedios" ?!?!?!

On Tuesday, May 12, 2015 at 10:05:35 PM UTC+2, Lisandro wrote:
>
> Thanks Niphlod. I double checked, and the tasks are there. 
>
> The main app is called "medios" and has this in its model file:
>
> db = DAL(\
>   'postgres://%s:%s@%s/%s' %(DB_USER, DB_USER_PASSWORD, DB_HOST, DB_NAME), 
> \
>   lazy_tables=True)
>
> from gluon.scheduler import Scheduler
> scheduler = Scheduler(db, max_empty_runs=5)
>
> The I start the worker like this:
>  python /var/www/medios/web2py.py -K webmedios -D 0
>
> I checked the scheduler_task table of the configured db and the tasks are 
> there.
> I tryied removing all content of scheduler tables, and then queuing the 
> tasks again. But still the same output log. 
>
> Maybe something wrong in the task data. This is on of the rows fo
>
> Id: 93 
> Application Name: demo 
> Task Name: always 
> Group Name: main 
> Status: QUEUED 
> Function Name: always 
> Uuid: d2017a0a-c688-45f3-b112-cb1b2366dcce 
> Args: [] 
> Vars: {} 
> Enabled: 
> Start Time: 2015-05-12 15:55:06 
> Next Run Time: 2015-05-12 15:55:06 
> Stop Time: None 
> Repeats: 0 0=unlimited
> Retry Failed: -1 -1=unlimited
> Period: 600 seconds
> Prevent Drift: False
> Timeout: 30 seconds
> Sync Output: 0 
> Times Run: 0 
> Times Failed: 0 
> Assigned Worker Name: 
>
> I can see that the workers are created on the scheduler_worker table, but 
> tasks are never picked up. 
> I'm in production, using uwsgi + nginx. Already restarted uwsgi 
> application.
>
> El martes, 12 de mayo de 2015, 16:50:43 (UTC-3), Niphlod escribió:
>>
>>  seems that there aren't any tasks in the database the scheduler is 
>> looking in. Sure that there are no misconfigurations ?
>>
>> BTW: there's nothing wrong with your approach. A worker needs a "-K" 
>> argument only to inherit initialization options from that app: it's 
>> perfectly capable of processing tasks coming from different apps (of course 
>> they must exist in the server where the worker is running)
>>
>

-- 
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: Current logged in users

2015-05-12 Thread Anthony
To log out all users, you could delete all session files, though you would 
be destroying any active sessions. Unfortunately, when you delete a user, I 
don't think there is a good way to force logout that user. One option is to 
create an _after_delete callback for the auth_user table that creates a 
scheduled task to search through all the session files and delete the one 
that contains the ID of the deleted user.

Anthony

On Tuesday, May 12, 2015 at 3:04:22 PM UTC-4, A36_Marty wrote:
>
> Along the same lines, is there a way to log any/everyone out / even 
> force-expiring cookies for users who have selected the "remember me" login 
> option?
>
> I asked due to noticing an auth_user record can be deleted but they can 
> still access the system for functions decorated with @auth.requires_login
>
> Thanks in advance
>
> On Wednesday, September 17, 2014 at 8:06:51 PM UTC-5, Anthony wrote:
>>
>> See 
>> http://stackoverflow.com/questions/12218989/get-all-logged-in-users-web2py/12224157#12224157
>> .
>>
>> Anthony
>>
>> On Wednesday, September 17, 2014 8:48:22 PM UTC-4, Tito Garrido wrote:
>>>
>>> Hi Folks,
>>>
>>> Is there a way to list the current logged in users?
>>>
>>> Regards,
>>>
>>> Tito
>>>
>>> -- 
>>>
>>> Linux User #387870
>>> .
>>>  _/_õ|__|
>>> ..º[ .-.___.-._| . . . .
>>> .__( o)__( o).:___ 
>>>
>>

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


[web2py] Re: is there a way to use auth_permission to allow user to access records based upon field value?

2015-05-12 Thread Anthony
Read the documentation -- common_filter is a property of the table, it is 
not a Field object and therefore does not go in a list of extra fields (and 
in Python, an element of a list cannot include an assignment, as you are 
doing with the "=" sign).

Anthony

On Tuesday, May 12, 2015 at 12:01:59 PM UTC-4, Alex Glaros wrote:
>
> Anthony,
>
> trying to get basic common filter syntax to work.  What is wrong with 
> below?
>
> auth.settings.extra_fields['auth_group']= [
> Field('organizationID','integer'), common_filter = lambda query: 
> db.auth_group.organizationID==7] 
>
>  File "C:/alex/web2py/web2py/web2py/applications/ES1/models/db.py" 
> , line 129
> Field('organizationID','integer'), common_filter = lambda query: 
> db.auth_group.organizationID==7)]
>  ^
> SyntaxError: invalid syntax
>
>

-- 
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 to move a set of view,edit,delete buttons from last column to first column on SQLgrid?

2015-05-12 Thread kenny c
Thank you for your reply as always, Niphlod! 

On Tuesday, May 12, 2015 at 3:55:20 PM UTC-4, Niphlod wrote:
>
> takend straight from the book at 
> http://web2py.com/books/default/chapter/29/07/forms-and-validators#SQLFORM-grid-and-SQLFORM-smartgrid
>
>
> *buttons_placement and links_placement both take a parameter ('right', 
> 'left', 'both') that will affect where on the row the buttons (or the 
> links) will be placed*
>
> On Tuesday, May 12, 2015 at 7:05:32 PM UTC+2, Kenneth wrote:
>>
>> Hello,
>>
>> Lately, I've started playing with sqlgrid since it saves so much time 
>> pulling out all data in a page.
>>
>> The problem is that I have a table with 20 attirbutes saved in it, it's 
>> hard to scroll to the end of right side and click on view/edit buttons. 
>>
>> Is there any way to move those buttons to first column?
>>
>> I don't know if it's possible without editing SQLgrid library code.
>>
>> 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: What's the proper way of using scheduler for multiple apps with one only db?

2015-05-12 Thread Lisandro
I'm sorry, the master app is called "webmedios", so the call is ok. The log 
shows "web2py.scheduler.medios" because I renamed the folder where web2py 
is installed, I renamed it to "medios". So the log is ok and I think the 
code too.  Sorry for the confusion, my bad :P

Even though, I don't know why tasks aren't being picked up. Is there 
anything else I can check?
I'm using Version 2.10.3-stable+timestamp.2015.04.02.21.42.07


El martes, 12 de mayo de 2015, 17:16:07 (UTC-3), Niphlod escribió:
>
> something is not adding up. if your app is called medios...and the log 
> shows DEBUG:web2py.scheduler.medios ... why are you trying to start it 
> with "webmedios" ?!?!?!
>
> On Tuesday, May 12, 2015 at 10:05:35 PM UTC+2, Lisandro wrote:
>>
>> Thanks Niphlod. I double checked, and the tasks are there. 
>>
>> The main app is called "medios" and has this in its model file:
>>
>> db = DAL(\
>>   'postgres://%s:%s@%s/%s' %(DB_USER, DB_USER_PASSWORD, DB_HOST, DB_NAME
>> ), \
>>   lazy_tables=True)
>>
>> from gluon.scheduler import Scheduler
>> scheduler = Scheduler(db, max_empty_runs=5)
>>
>> The I start the worker like this:
>>  python /var/www/medios/web2py.py -K webmedios -D 0
>>
>> I checked the scheduler_task table of the configured db and the tasks are 
>> there.
>> I tryied removing all content of scheduler tables, and then queuing the 
>> tasks again. But still the same output log. 
>>
>> Maybe something wrong in the task data. This is on of the rows fo
>>
>> Id: 93 
>> Application Name: demo 
>> Task Name: always 
>> Group Name: main 
>> Status: QUEUED 
>> Function Name: always 
>> Uuid: d2017a0a-c688-45f3-b112-cb1b2366dcce 
>> Args: [] 
>> Vars: {} 
>> Enabled: 
>> Start Time: 2015-05-12 15:55:06 
>> Next Run Time: 2015-05-12 15:55:06 
>> Stop Time: None 
>> Repeats: 0 0=unlimited
>> Retry Failed: -1 -1=unlimited
>> Period: 600 seconds
>> Prevent Drift: False
>> Timeout: 30 seconds
>> Sync Output: 0 
>> Times Run: 0 
>> Times Failed: 0 
>> Assigned Worker Name: 
>>
>> I can see that the workers are created on the scheduler_worker table, but 
>> tasks are never picked up. 
>> I'm in production, using uwsgi + nginx. Already restarted uwsgi 
>> application.
>>
>> El martes, 12 de mayo de 2015, 16:50:43 (UTC-3), Niphlod escribió:
>>>
>>>  seems that there aren't any tasks in the database the scheduler is 
>>> looking in. Sure that there are no misconfigurations ?
>>>
>>> BTW: there's nothing wrong with your approach. A worker needs a "-K" 
>>> argument only to inherit initialization options from that app: it's 
>>> perfectly capable of processing tasks coming from different apps (of course 
>>> they must exist in the server where the worker is running)
>>>
>>

-- 
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's the proper way of using scheduler for multiple apps with one only db?

2015-05-12 Thread Niphlod
not really. exceptions are not shown and  "nothing to do" kinda leaves up 
nothing to imagination

you can inspect the worker_stats column on the worker that is also a ticker 
but I assume you won't find anything.

you can run this query to check for available tasks

sw, st, sd = db.scheduler_worker, db.scheduler_task, db.scheduler_task_deps
now = request.now
deps_with_no_deps = db(
(sd.can_visit == False) &
(~sd.task_child.belongs(
db(sd.can_visit == False)._select(sd.task_parent)
)
)
)._select(sd.task_child)
no_deps = db(
(st.status.belongs((QUEUED, ASSIGNED))) &
(
(sd.id == None) | (st.id.belongs(deps_with_no_deps))

)
)._select(st.id, distinct=True, left=sd.on(
(st.id == sd.task_parent) &
(sd.can_visit == False)
)
)

all_available = db(
(st.status.belongs((QUEUED, ASSIGNED))) &
((st.times_run < st.repeats) | (st.repeats == 0)) &
(st.start_time <= now) &
((st.stop_time == None) | (st.stop_time > now)) &
(st.next_run_time <= now) &
(st.enabled == True) &
(st.id.belongs(no_deps))
)

print all_available.select(st.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] Using "for"

2015-05-12 Thread KevC
Hi!

I got a problem, I wanna print a list or string on a 'view' using  a 'for' 
but the view only show me the last number or letter. For example:

My controller...

for i in 'hola':
 print i
 return locals()


My view...

{{=i}}

The view only show me the letter 'a'.
Other example:

a = [1,2,3]
for i in a:
 print i
 return locals()

My view...

{{=i}}

The view only show me the number 3.

I got a mistake? Somebody help me.
I used the console and It's ok, print all list and string.

My best regards.




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


[web2py] Re: What's the proper way of using scheduler for multiple apps with one only db?

2015-05-12 Thread Lisandro
Thanks for the assistance.

That query returned exactly the tasks that need to be (but are not) 
executed. 
I think it could be something about the web2py version. In the  server 
(where tasks aren't executed) I'm running version 2.10.3.
On localhost, I have the exact same configuration (ubuntu, nginx, uwsgi, 
postgres, same web2py apps installed), but web2py version is 2.10.4. Here 
in localhost, the tasks do get picked up and executed.

In the server, that query you suggested returns always the tasks that need 
to be (but are not) executed. On localhost, that query returns empty; if I 
keep runnign the query over and over, sometimes it returns a task, that is, 
a task that needs to be executed, but in the next execution of the query, 
it returns empty again.

So, it's working on web2py 2.10.4 but not in 2.10.3.
Does anybody knows if something change between those two versions regarding 
web2py's scheduler? This changelog is still a little old:
http://www.web2py.com/init/default/changelog


El martes, 12 de mayo de 2015, 18:12:52 (UTC-3), Niphlod escribió:
>
> not really. exceptions are not shown and  "nothing to do" kinda leaves up 
> nothing to imagination
>
> you can inspect the worker_stats column on the worker that is also a 
> ticker but I assume you won't find anything.
>
> you can run this query to check for available tasks
>
> sw, st, sd = db.scheduler_worker, db.scheduler_task, db.
> scheduler_task_deps
> now = request.now
> deps_with_no_deps = db(
> (sd.can_visit == False) &
> (~sd.task_child.belongs(
> db(sd.can_visit == False)._select(sd.task_parent)
> )
> )
> )._select(sd.task_child)
> no_deps = db(
> (st.status.belongs((QUEUED, ASSIGNED))) &
> (
> (sd.id == None) | (st.id.belongs(deps_with_no_deps))
>
> )
> )._select(st.id, distinct=True, left=sd.on(
> (st.id == sd.task_parent) &
> (sd.can_visit == False)
> )
> )
>
> all_available = db(
> (st.status.belongs((QUEUED, ASSIGNED))) &
> ((st.times_run < st.repeats) | (st.repeats == 0)) &
> (st.start_time <= now) &
> ((st.stop_time == None) | (st.stop_time > now)) &
> (st.next_run_time <= now) &
> (st.enabled == True) &
> (st.id.belongs(no_deps))
> )
>
> print all_available.select(st.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: is there a way to use auth_permission to allow user to access records based upon field value?

2015-05-12 Thread Alex Glaros
wow... that is powerful

thanks Anthony, works great!

web2py rocks!

Alex

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


[web2py] Re: Using "for"

2015-05-12 Thread 黄祥
why not put the '*for'* loop in views n your controller just pass the data 
to the view.

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: Customizing registration fields for linkedin login

2015-05-12 Thread 黄祥
had you modified the auth_users table?

ref:
http://web2py.com/books/default/chapter/29/09/access-control#Customizing-Auth

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.


Re: [web2py] Using "for"

2015-05-12 Thread Massimiliano
In your controller:

a = [1,2,3]

return locals()

In your view:

{{for i in a:}}
 {{=i}}
{{pass}}




On Tue, May 12, 2015 at 11:46 PM, KevC  wrote:

> Hi!
>
> I got a problem, I wanna print a list or string on a 'view' using  a 'for'
> but the view only show me the last number or letter. For example:
>
> My controller...
>
> for i in 'hola':
>  print i
>  return locals()
>
>
> My view...
>
> {{=i}}
>
> The view only show me the letter 'a'.
> Other example:
>
> a = [1,2,3]
> for i in a:
>  print i
>  return locals()
>
> My view...
>
> {{=i}}
>
> The view only show me the number 3.
>
> I got a mistake? Somebody help me.
> I used the console and It's ok, print all list and string.
>
> My best regards.
>
>
>
>
>  --
> Resources:
> - http://web2py.com
> - http://web2py.com/book (Documentation)
> - http://github.com/web2py/web2py (Source code)
> - https://code.google.com/p/web2py/issues/list (Report Issues)
> ---
> You received this message because you are subscribed to the Google Groups
> "web2py-users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to web2py+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>



-- 
Massimiliano

-- 
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's the proper way of using scheduler for multiple apps with one only db?

2015-05-12 Thread Niphlod
2.10.3 and 2.10.4 didn't change a single bit about the scheduler. 
Check again. There MUST be some hiccup in your deployment code.

-- 
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: pack all - internal error - Error 3 - cache/chache

2015-05-12 Thread 黄祥
is just welcome app or affect another app too? please try to restart the 
server first if still occured, try to restart your system.

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.


Re: [web2py] Using "for"

2015-05-12 Thread Anthony
Also, note that you don't use "print" in web2py -- printing prints to the 
console and has no effect on the HTML returned by the server to the 
browser. In web2py, a controller action returns a dictionary of data, and 
the view then uses that data in constructing the HTML. Controllers do not 
directly write into the view -- that is why controllers and views are 
separate layers -- they each have their own roles.

Anthony

On Tuesday, May 12, 2015 at 5:56:47 PM UTC-4, Massimiliano wrote:
>
> In your controller:
>
> a = [1,2,3]
>
> return locals()
>
> In your view:
>
> {{for i in a:}}
>  {{=i}}
> {{pass}}
>
>
>
>
> On Tue, May 12, 2015 at 11:46 PM, KevC  
> wrote:
>
>> Hi!
>>
>> I got a problem, I wanna print a list or string on a 'view' using  a 
>> 'for' but the view only show me the last number or letter. For example:
>>
>> My controller...
>>
>> for i in 'hola':
>>  print i
>>  return locals()
>>
>>
>> My view...
>>
>> {{=i}}
>>
>> The view only show me the letter 'a'.
>> Other example:
>>
>> a = [1,2,3]
>> for i in a:
>>  print i
>>  return locals()
>>
>> My view...
>>
>> {{=i}}
>>
>> The view only show me the number 3.
>>
>> I got a mistake? Somebody help me.
>> I used the console and It's ok, print all list and string.
>>
>> My best regards.
>>
>>
>>
>>
>>  -- 
>> Resources:
>> - http://web2py.com
>> - http://web2py.com/book (Documentation)
>> - http://github.com/web2py/web2py (Source code)
>> - https://code.google.com/p/web2py/issues/list (Report Issues)
>> --- 
>> You received this message because you are subscribed to the Google Groups 
>> "web2py-users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to web2py+unsubscr...@googlegroups.com.
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>
>
> -- 
> Massimiliano
>  

-- 
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] Keeping track of connected users (websocket_messaging.py)

2015-05-12 Thread Samuel Sowah
I'll be glad to take a look. I just might be able to help since I'd need it 
myself anyway. Will do my best.

On Wednesday, May 6, 2015 at 6:17:50 PM UTC+1, Richard wrote:
>
> Last year we develop over websocket contrib a tool like that and it turns 
> that we had to create a thread that was doing that, I mean maintain a list 
> of connected user... We create a basic back and forth websocket message 
> format so we can ping every users connected and wait for a response from 
> them if they are still online... This give you the basic idea how to 
> implement something... At start I expect that there were a build solution 
> for this in websocket contrib and toranado, but the person that I mandate 
> for analysing that and found a solution said that wasn't available and 
> implement something... So, I don't know if the path he follow was the right 
> one. But as far as I have been able to go throught that topic, websocket 
> contrib is noting more then a basic connecting tool that allow you to start 
> multiplexing using tornado from web2py...
>
> If you feel you are able to review the code of what we did and improve it, 
> I can share it here, so I know if we take the right path or not... Since 
> the person who develop that is gone, I can't help more than sharing with 
> you her works...
>
> Richard
>
> On Wed, May 6, 2015 at 6:58 AM, Samuel Sowah  > wrote:
>
>> Hello,
>> Please if I'd like to keep track of users who are connected to a 
>> particular group, for example
>> 
>>$(document).ready(function(){
>>   var data;
>>   $.web2py.web2py_websocket('ws://
>> official-notebook.com:/realtime/mygroup
>> ',function(e){data=eval('('+e.data+')')});
>>});
>> 
>>
>> so that I can list the connected users, and then remove them from the 
>> list when they disconnect, how would I achieve that?
>>
>> -- 
>> 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] Re: Deadlock in cache.py/CacheOnDisk in R 2.10.4

2015-05-12 Thread Bernard Letourmy
Ok will do
Bernard

-- 
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's the proper way of using scheduler for multiple apps with one only db?

2015-05-12 Thread Lisandro
I must be missing something really obvious, or something really strange is 
going on.

I've just made a very simple test: 
 - one only application
 - one only db
 - migrations enabled


In models/scheduler.py:
def mytest():
print 'this is my test'
return True


from gluon.scheduler import Scheduler
scheduler = Scheduler(db, max_empty_runs=5)


In controllers/default.py:

@auth.requires_login()
def initialize():
scheduler.queue_task('mytest', period=30, repeats=0, timeout=5, 
retry_failed=-1, application_name='webmedios')
return 'function "mytest" scheduled succesfully'


I called default/initialize to queue the task, then checked that it had 
effectively been queued, then ran this:

python /myhome/medios/web2py.py -K webmedios -D 0
web2py Web Framework
Created by Massimo Di Pierro, Copyright 2007-2015
Version 2.10.3-stable+timestamp.2015.04.02.21.42.07
Database drivers available: sqlite3, psycopg2, pg8000, pymysql, imaplib
starting single-scheduler for "webmedios"...
DEBUG:pyDAL:Your database version does not support the JSON data type 
(using TEXT instead)
DEBUG:web2py.scheduler.medios#9753:defining tables (migrate=True)
DEBUG:web2py.scheduler.medios#9753:thread building own DAL object
DEBUG:web2py.scheduler.medios#9753:looping...
DEBUG:pyDAL:Your database version does not support the JSON data type 
(using TEXT instead)
DEBUG:web2py.scheduler.medios#9753:defining tables (migrate=False)
INFO:web2py.scheduler.medios#9753:nothing to do
DEBUG:web2py.scheduler.medios#9753:sleeping...
DEBUG:web2py.scheduler.medios#9753:empty runs 1/5
DEBUG:web2py.scheduler.medios#9753:freeing workers that have not sent 
heartbeat
INFO:web2py.scheduler.medios#9753:TICKER: I'm a ticker
DEBUG:web2py.scheduler.medios#9753:looping...
DEBUG:web2py.scheduler.medios#9753:Assigning tasks...
INFO:web2py.scheduler.medios#9753:TICKER: workers are 1
INFO:web2py.scheduler.medios#9753:TICKER: tasks are 0
DEBUG:web2py.scheduler.medios#9753:Tasks assigned...
DEBUG:web2py.scheduler.medios#9753:sleeping...
DEBUG:web2py.scheduler.medios#9753:empty runs 2/5
DEBUG:web2py.scheduler.medios#9753:recording heartbeat (ACTIVE)
DEBUG:web2py.scheduler.medios#9753:looping...
INFO:web2py.scheduler.medios#9753:nothing to do
DEBUG:web2py.scheduler.medios#9753:sleeping...
DEBUG:web2py.scheduler.medios#9753:empty runs 3/5
DEBUG:web2py.scheduler.medios#9753:recording heartbeat (ACTIVE)
DEBUG:web2py.scheduler.medios#9753:looping...
INFO:web2py.scheduler.medios#9753:nothing to do
DEBUG:web2py.scheduler.medios#9753:sleeping...
DEBUG:web2py.scheduler.medios#9753:empty runs 4/5
DEBUG:web2py.scheduler.medios#9753:recording heartbeat (ACTIVE)
DEBUG:web2py.scheduler.medios#9753:looping...
INFO:web2py.scheduler.medios#9753:nothing to do
DEBUG:web2py.scheduler.medios#9753:sleeping...
DEBUG:web2py.scheduler.medios#9753:empty runs 5/5
INFO:web2py.scheduler.medios#9753:empty runs limit reached, killing myself
INFO:web2py.scheduler.medios#9753:die!


This very simple test is not working :/ 
I don't know where else to look. I've already touched uwsgi.ini to reload 
the python app. I went even further and stopped all services (nginx, uwsgi, 
pgbouncer, postgres) and started them again (I don't know why I did it, but 
I was tempted to try). I'm pretty lost. My one last only card is to restart 
the server. I know. Awfull. And hopeless.  :/



El martes, 12 de mayo de 2015, 18:58:25 (UTC-3), Niphlod escribió:
>
> 2.10.3 and 2.10.4 didn't change a single bit about the scheduler. 
> Check again. There MUST be some hiccup in your deployment code.
>

-- 
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: Deadlock in cache.py/CacheOnDisk in R 2.10.4

2015-05-12 Thread Bernard Letourmy
created issue #966 - and submitted pull request
Bernard

On Wednesday, 13 May 2015 07:25:25 UTC+8, Bernard Letourmy wrote:
>
> Ok will do 
> Bernard

-- 
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: pack all - internal error - Error 3 - cache/chache

2015-05-12 Thread 黄祥
please try to create folder cache on welcome app, it seems the folder is 
renamed or deleted, if the error still occured, plesae try to restart 
web2py or even your os.

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: pack all - internal error - Error 3 - cache/chache

2015-05-12 Thread 黄祥
please try to create folder cache on welcome app, it seems the folder is 
renamed or deleted, if the error still occured, plesae try to restart 
web2py or even your os.

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: Export to csv which is not taking label from model file, where Grid takes.

2015-05-12 Thread Prasad Muley
Can use colnames parameter of export_to_csv_file ?

I tried to use it But got following error.

 'Row' object has no attribute '_extra'

What is the format for colnames?


On Wednesday, May 13, 2015 at 1:23:33 AM UTC+5:30, Niphlod wrote:
>
> the export are for raw processing, so they get the same result as you 
> would get - for practical purposes - from db(query).select().as_csv()
>
> On Tuesday, May 12, 2015 at 7:07:40 PM UTC+2, Sujata Aghor wrote:
>>
>>
>> Hi,
>> In my model file I have defined table and Label for the fields like this 
>> - 
>> db.define_table('mytable',
>> Field('fname', 'string', length=12, writable=False,
>>   notnull=True, label='First Name'),
>>Field('lname', 'string', length=12, writable=False,
>>   notnull=True, label='Last Name'),
>> ...
>>
>> 1. In case of Grids, table headers are coming from  model file (shown 
>> above) No extra code has been written to show the labels from the model 
>> file.
>>
>> 2. So I was expecting the same headers would come to CSV file also, but 
>> surprisingly when I export to CSV we dont get these labels. (I tried by 
>> doing CSV=true in case of grid and still gets mytable.fname)
>>
>> 3. From documentation, I found Grid has additional parameter. i.e headers 
>> I tired to use that parameter to see if it works in export. So I defined 
>> headers as below :
>> headers = {'db.mytable.fname': 'First Name',
>>'db.mytable.lname': 'Last Name'
>>   }
>>
>> However export to CSV is still showing headers as db.mytable.fname
>>
>> Kindly guide!
>> I suspect this is BUG in web2py export to csv which is not taking label 
>> from model file.
>>
>> Thanks in Advance!!!
>>
>

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