Re: [web2py] Pagination example from book. Make pages start at 1?

2014-02-18 Thread Martin Weissenboeck
What do you mean with "it reports as page 1"?
Do you mean the page number which is part of the URL?
Or do you have a page numberin your view like {{=page}}


2014-02-18 23:18 GMT+01:00 HittingSmoke :

> I followed the pagination tutorial in the web2py book and I have the
> following controller:
>
> def index():
> if len(request.args): page=int(request.args[0])
> else: page=0
> items_per_page=6
> limitby=(page*items_per_page,(page+1)*items_per_page+1)
> posts=db().select(db.post.ALL, orderby=~db.post.date, limitby=limitby)
> return dict(posts=posts, page=page, items_per_page=items_per_page)
>
> ...and this view controlling navigation:
>
> 
>   
> {{if page:}}
> Prev
> {{pass}}
> {{if len(posts)>items_per_page:}}
> Next
> {{pass}}
>   
> 
>
> The only problem I have with it is when you go to the second page it
> reports as page 1. I would like the first page to be page 1. Is that
> possible without completely rewriting the pagination function?
>
> --
> 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/groups/opt_out.
>

-- 
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/groups/opt_out.


[web2py] Re: expand_one not working

2014-02-18 Thread sasogeek
Help please...

On Tuesday, 18 February 2014 16:08:57 UTC, sasogeek wrote:
>
> in db.py, the table status is defined as follows
> db.define_table(
> 'status',
> Field('status', 'text'),
> Field('file', 'upload'),
> Field('userid'),
> )
>
> and in default.py, the download function is defined as
> def download():
> """
> allows downloading of uploaded files
> http:///[app]/default/download/[filename]
> """
> return response.download(request, db)
>
> just like in the tutorial book.
> and in the views, i have this code
>
> {{from gluon.contrib.autolinks import expand_one}}
> ...
> {{updates=db().select(db.status.ALL, orderby=~db.status.id)}}
> {{if updates:}}
> {{for update in updates:}}
> {{=XML(expand_one(URL('download', 
> args=update.file,),cache.ram('mycache',lambda:dict(),3600)))}}
>   {{pass}}
> {{pass}}
>
>
> if update.file is an image, it works fine and the image is rendered just 
> fine, but when it's a pdf, it doesn't work, I get this error 
> Sorry, we were unable to find the document at the original source. Verify 
> that the document still exists. You can also try to download the original 
> document by clicking here
>
> When I click on the link that says "here", it opens a google docs page in 
> a new window with the same error statement in it how do i fix this?
>
>

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


[web2py] Re: Pack on OSX, Import on Windows bug (binary only)

2014-02-18 Thread Massimo Di Pierro
It isn't that. The problem is that when you use py2pp, the latter freezes 
the path of the build machine for the purpose of reporting errors. I hate 
it but I have not fund a solution.
This is not cause of errors. This is case of incorrect paths in reported 
errors.

The error is in your engine5.py

from html import FORM, INPUT, LABEL, OPTION, SELECT, BUTTON

should be

from gluon import FORM, INPUT, LABEL, OPTION, SELECT, BUTTON

or

from gluon.html import FORM, INPUT, LABEL, OPTION, SELECT, BUTTON

because html is not in path. gluon is.

On Tuesday, 18 February 2014 20:08:09 UTC-6, Brando wrote:
>
> Ticket ID
> 127.0.0.1.2014-02-18.20-21-14.5e42032d-3fa0-4fc5-8a93-9ca1ef22e89f
>
>  No module named html
>
> Version
> web2py™ Version 2.8.2-stable+timestamp.2013.11.28.13.54.07
> Python Python 2.7.5: \\vmware-host\Shared 
> Folders\Desktop\web2py\web2py.exe (prefix: C:\Python27)
> Traceback
> 1.
> 2.
> 3.
> 4.
> 5.
> 6.
> 7.
> 8.
> 9.
> 10.
> 11.
> 12.
> Traceback (most recent call last):
>   File "/home/mdipierro/make_web2py/web2py/gluon/restricted.py", line 217, 
> in restricted
>   File "//vmware-host/Shared 
> Folders/Desktop/web2py/applications/c2/controllers/devices2.py", line 3, in 
> 
> from engine5 import  Formulator, Uploader, maketable
>   File "/home/mdipierro/make_web2py/web2py/gluon/custom_import.py", line 
> 86, in custom_importer
>   File "/home/mdipierro/make_web2py/web2py/gluon/custom_import.py", line 
> 125, in __call__
>   File "applications\c2\modules\engine5.py", line 4, in 
> from html import FORM, INPUT, LABEL, OPTION, SELECT, BUTTON
>   File "/home/mdipierro/make_web2py/web2py/gluon/custom_import.py", line 
> 86, in custom_importer
>   File "/home/mdipierro/make_web2py/web2py/gluon/custom_import.py", line 
> 125, in __call__
> ImportError: No module named html
>
> OSX version is Mavericks.  Pack all and import it into Windows 7 binary 
> version of Web2py (latest).
>
> This bug is not present in the Windows source version.  Massimo, it looks 
> like it's trying to load modules from your personal computer.
>

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


[web2py] Re: SQLFORM.grid buttons as text

2014-02-18 Thread horridohobbyist
Solved! I made a small modification to the "row_buttons" class:

.web2py_grid .row_buttons a {
line-height:20px;
*margin-left:2px;* margin-right:2px; display:inline-block;
padding:3px 5px 3px 5px;
}

On Tuesday, 18 February 2014 07:31:34 UTC-5, horridohobbyist wrote:
>
> I've applied a layout that I downloaded from web2py.com. The layout turns 
> the Edit and Delete buttons of SQLFORM.grid into textual links (anchors): 
>  "Edit" and "Delete". However, the two text labels run together like so: 
> "EditDelete". I'd like to put some space between them, ie "Edit   Delete".
>
> I tried doing this in the CSS:
>
> .buttontext {
> padding: 5 px;
> }
>
> And it does give me the spacer. *But* this causes a scroll bar to appear 
> to the right of the grid!
>
> What's the right way to do what I'm trying to do?
>
> 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/groups/opt_out.


[web2py] Pack on OSX, Import on Windows bug (binary only)

2014-02-18 Thread Brando
Ticket ID
127.0.0.1.2014-02-18.20-21-14.5e42032d-3fa0-4fc5-8a93-9ca1ef22e89f

 No module named html

Version
web2py™ Version 2.8.2-stable+timestamp.2013.11.28.13.54.07
Python Python 2.7.5: \\vmware-host\Shared Folders\Desktop\web2py\web2py.exe 
(prefix: C:\Python27)
Traceback
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
Traceback (most recent call last):
  File "/home/mdipierro/make_web2py/web2py/gluon/restricted.py", line 217, 
in restricted
  File "//vmware-host/Shared 
Folders/Desktop/web2py/applications/c2/controllers/devices2.py", line 3, in 

from engine5 import  Formulator, Uploader, maketable
  File "/home/mdipierro/make_web2py/web2py/gluon/custom_import.py", line 
86, in custom_importer
  File "/home/mdipierro/make_web2py/web2py/gluon/custom_import.py", line 
125, in __call__
  File "applications\c2\modules\engine5.py", line 4, in 
from html import FORM, INPUT, LABEL, OPTION, SELECT, BUTTON
  File "/home/mdipierro/make_web2py/web2py/gluon/custom_import.py", line 
86, in custom_importer
  File "/home/mdipierro/make_web2py/web2py/gluon/custom_import.py", line 
125, in __call__
ImportError: No module named html

OSX version is Mavericks.  Pack all and import it into Windows 7 binary 
version of Web2py (latest).

This bug is not present in the Windows source version.  Massimo, it looks 
like it's trying to load modules from your personal computer.

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


[web2py] Re: Version Control advice

2014-02-18 Thread 黄祥
mine, just the some of web2py apps that i modify, put it on the sub folder 
of the environment and push it using management configuration (like puppet, 
cfengine, chef, etc)
e.g.
Web2py
├───Development
│   ├───Application1
│   │   ├───controllers
│   │   ├───languages
│   │   ├───models
│   │   ├───modules
│   │   ├───static
│   │   └───views
│   └───Application2
│   ├───controllers
│   ├───languages
│   ├───models
│   ├───modules
│   ├───static
│   └───views
├───Production
│   ├───Application1
│   │   ├───controllers
│   │   ├───languages
│   │   ├───models
│   │   ├───modules
│   │   ├───static
│   │   └───views
│   └───Application2
│   ├───controllers
│   ├───languages
│   ├───models
│   ├───modules
│   ├───static
│   └───views
├───Staging
│   ├───Application1
│   │   ├───controllers
│   │   ├───languages
│   │   ├───models
│   │   ├───modules
│   │   ├───static
│   │   └───views
│   └───Application2
│   ├───controllers
│   ├───languages
│   ├───models
│   ├───modules
│   ├───static
│   └───views
└───Testing
├───Application1
│   ├───controllers
│   ├───languages
│   ├───models
│   ├───modules
│   ├───static
│   └───views
└───Application2
├───controllers
├───languages
├───models
├───modules
├───static
└───views

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/groups/opt_out.


Re: [web2py] Eliminating Submit Button

2014-02-18 Thread horridohobbyist
Solved! I had to give the form an id, and then I could do a 
$("#form_id").submit().

Thanks.

On Tuesday, 18 February 2014 19:47:46 UTC-5, horridohobbyist wrote:
>
> Well, we're *almost* there! The submit() isn't submitting; at least, I'm 
> not getting through form.accepts().
>
>
> On Tuesday, 18 February 2014 15:20:52 UTC-5, Richard wrote:
>>
>> So remove button[type=submit] in 
>>
>> $("button[type=submit]#ButtonSubmitId").hide();
>>
>> $("#ButtonSubmitId").hide();
>>
>> Should work with only the tag id
>>
>> Richard
>>
>>
>> On Tue, Feb 18, 2014 at 3:05 PM, horridohobbyist wrote:
>>
>>> It's not working. I get the alert() messages, but the button methods 
>>> aren't doing anything.
>>>
>>> I inserted "_id='fred'" in the INPUT(_type='submit',...) call. I presume 
>>> "button[type=submit]#fred" should correctly reference the object?
>>>
>>>
>>> On Tuesday, 18 February 2014 10:19:54 UTC-5, Richard wrote:
>>>
 
 $(document).ready(function() {
 $("input#YourSelectFieldId").focus(); // not required
 $("button[type=submit]#ButtonSubmitId").hide();
 $('form select[name=YourSelectFieldId]').on('change', 
 function() {
 //alert($('select[name=YourSelectFieldId] 
 option:selected').val()); // For testing
 $("button[type=submit]#ButtonSubmitId").submit();
 });
 });
 


 On Tue, Feb 18, 2014 at 7:24 AM, horridohobbyist 
 wrote:

> I have a SQLFORM.grid that allows the user to select a query from a 
> selection of queries. The user selects the query using this form:
>
> FORM(TABLE(TR(T("Choose Category:"),SELECT([my_list],_
> name='category',value=current)),
>TR("",INPUT(_type='submit'
>
> The grid is:
>
> SQLFORM.grid(query,
> orderby=db.products.category,
> csv=False)
>
> I would like the user to not have to click on a submit button. I just 
> want to have some action that will modify the grid query as soon as the 
> selection is made. What's the best way to do this? (I can think of a 
> very, 
> very messy way, but I'd like to avoid that.)
>
> 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+un...@googlegroups.com.
>
> For more options, visit https://groups.google.com/groups/opt_out.
>

  -- 
>>> 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/groups/opt_out.
>>>
>>
>>

-- 
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/groups/opt_out.


[web2py] Re: hostmonster, pythonanywhere, or gae for my current situation

2014-02-18 Thread Carlos Zenteno
The new link for the above Bruno Rocha instructions is: 
http://brunorocha.org/python/web2py/web2py-on-pythonanywhere.html

-- 
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/groups/opt_out.


Re: [web2py] Re: Angular.js And other js lib

2014-02-18 Thread Arvind Gupta
@derek and @richard if we have to create generic support of other
javascript libraries, what are the efforts one have to make?


On Wed, Feb 19, 2014 at 2:48 AM, Richard Vézina  wrote:

> Good point Derek, I saw it in angular.js file when I test the slice (that
> at least work), as you say it is a cleaner approach...
>
> :)
>
> Richard
>
>
> On Tue, Feb 18, 2014 at 4:01 PM, Derek  wrote:
>
>> no, no, no, do not use that slice, it's a waste of time to edit the
>> angular.js file itself. you want to do that every time a new version is
>> released? also why not just use a cdn for angular.js?
>>
>> http://docs.angularjs.org/api/ng/provider/$interpolateProvider#
>> startSymbol
>> The above link shows how to do it properly.
>>
>> Here's a snippet from their 'sample' code...
>>
>>   var customInterpolationApp = angular.module('customInterpolationApp',
>> []);
>>customInterpolationApp.config(function($interpolateProvider) {
>> $interpolateProvider.startSymbol('//');
>> $interpolateProvider.endSymbol('//');
>>
>> That changes the start and end symbols to '//' but you could just as
>> easily change them to '[[' and ']]' or '||' and '||' or whatever you want.
>>
>> On Tuesday, February 18, 2014 1:19:14 PM UTC-7, Richard wrote:
>>
>>> http://www.web2pyslices.com/slice/show/1922/web2py-angularjs
>>>
>>> Change angular {{ }} for {! !}
>>>
>>> Having to type to different character bug me though, but you need a
>>> closing tag...
>>>
>>> :(
>>>
>>> Richard
>>>
>>>
>>> On Tue, Feb 18, 2014 at 3:05 PM, Derek  wrote:
>>>
 and to note you can change the brackets in angular to use something
 else...

 see here:

 http://docs.angularjs.org/api/ng/service/$interpolate

 by default it uses {{ and }} as starting and ending brackets.


 On Tuesday, February 18, 2014 12:59:48 PM UTC-7, Derek wrote:
>
> Well, the problem you have is that if you put angular tags in your
> views, they will be parsed with the template parser of web2py and error.
> The way to avoid that is to use the angular classes instead. For example,
> all the 'ng-app' and 'ng-controller' and 'ng-repeat' attributes (
> http://docs.angularjs.org/tutorial/step_02). Keep in mind that the
> python template language will get parsed first, and only after that will
> the angular template parser be used.
>
> On Tuesday, February 18, 2014 12:49:42 PM UTC-7, Arvind Gupta wrote:
>>
>> Can we use angular.js with web2py, if yes can u point me to
>> appropriate resources?
>>
>  --
 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/groups/opt_out.

>>>
>>>  --
>> 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/groups/opt_out.
>>
>
>  --
> 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/groups/opt_out.
>

-- 
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/groups/opt_out.


[web2py] Version Control advice

2014-02-18 Thread Carlos Zenteno
Do you guys version control just the /applications directory or the whole 
web2py tree?

What is better for auto-deployment when pushing to the production repo?

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/groups/opt_out.


Re: [web2py] Eliminating Submit Button

2014-02-18 Thread horridohobbyist
Well, we're *almost* there! The submit() isn't submitting; at least, I'm 
not getting through form.accepts().


On Tuesday, 18 February 2014 15:20:52 UTC-5, Richard wrote:
>
> So remove button[type=submit] in 
>
> $("button[type=submit]#ButtonSubmitId").hide();
>
> $("#ButtonSubmitId").hide();
>
> Should work with only the tag id
>
> Richard
>
>
> On Tue, Feb 18, 2014 at 3:05 PM, horridohobbyist 
> 
> > wrote:
>
>> It's not working. I get the alert() messages, but the button methods 
>> aren't doing anything.
>>
>> I inserted "_id='fred'" in the INPUT(_type='submit',...) call. I presume 
>> "button[type=submit]#fred" should correctly reference the object?
>>
>>
>> On Tuesday, 18 February 2014 10:19:54 UTC-5, Richard wrote:
>>
>>> 
>>> $(document).ready(function() {
>>> $("input#YourSelectFieldId").focus(); // not required
>>> $("button[type=submit]#ButtonSubmitId").hide();
>>> $('form select[name=YourSelectFieldId]').on('change', 
>>> function() {
>>> //alert($('select[name=YourSelectFieldId] 
>>> option:selected').val()); // For testing
>>> $("button[type=submit]#ButtonSubmitId").submit();
>>> });
>>> });
>>> 
>>>
>>>
>>> On Tue, Feb 18, 2014 at 7:24 AM, horridohobbyist 
>>> wrote:
>>>
 I have a SQLFORM.grid that allows the user to select a query from a 
 selection of queries. The user selects the query using this form:

 FORM(TABLE(TR(T("Choose Category:"),SELECT([my_list],_
 name='category',value=current)),
TR("",INPUT(_type='submit'

 The grid is:

 SQLFORM.grid(query,
 orderby=db.products.category,
 csv=False)

 I would like the user to not have to click on a submit button. I just 
 want to have some action that will modify the grid query as soon as the 
 selection is made. What's the best way to do this? (I can think of a very, 
 very messy way, but I'd like to avoid that.)

 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+un...@googlegroups.com.

 For more options, visit https://groups.google.com/groups/opt_out.

>>>
>>>  -- 
>> 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/groups/opt_out.
>>
>
>

-- 
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/groups/opt_out.


[web2py] Web2py Integration with Multiple Oauth Logins

2014-02-18 Thread James Q
I have a feeling that this topic comes up often, but I cannot seem to 
Google a good solution to this. Essentially, I want users to be able to 
login using either the built in Auth, or login via some Oauth provider, 
like Twitter and Facebook. I have seen previous solutions using 
ExtendedLoginForm and custom Twitter classes that inherit from 
OAuthProvider, but they no longer seem to work. The Twitter code I find no 
longer supports the newest Twitter API; the linkedin code from the web2py 
book also  does not work.

Here is sample code I have now, which only seems to constantly redirect me 
to the logout page:

1) Created new web2py application by copying the welcome one to a folder 
named 'oauth'
2) Added this code to db.py (taken from multiple examples online):

from gluon.contrib.login_methods.oauth10a_account import OAuthAccount
from oauth2 import Client, Consumer, Token

class TwitterAccount(OAuthAccount):
AUTH_URL = "http://twitter.com/oauth/authorize";
TOKEN_URL = "https://twitter.com/oauth/request_token";
ACCESS_TOKEN_URL = "http://twitter.com/oauth/access_token";
CLIENT_ID = "..."
CLIENT_SECRET = "..."

def __init__(self, g):
OAuthAccount.__init__(self, g, self.CLIENT_ID, self.CLIENT_SECRET, 
self.AUTH_URL, self.TOKEN_URL, self.ACCESS_TOKEN_URL)

def get_user(self):
if self.accessToken() is not None:
consumer = Consumer(key=self.CLIENT_ID, 
secret=self.CLIENT_SECRET)
client = Client(consumer, self.accessToken())
resp, content = 
client.request('http://api.twitter.com/1/account/verify_credentials.json')
if resp['status'] != '200':
# cannot get user info. should check status
#redirect("http://google.com";)
return None
u = json.loads(content)
return dict(first_name = u['name'], username=u['screen_name'], 
name=u['name'], registration_id=u['id'])

auth.settings.login_form=TwitterAccount(g=globals())

3) Going to 127.0.0.1/oauth/user/login redirects me to user/logout.


Besides my frustration in trying to find timely information about this, is 
there working code out there that is *recent*, in that it works with latest 
web2py and the latest Oauth implementations? I'd really appreciate any tips 
or hints anyone has.


-- 
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/groups/opt_out.


[web2py] Re: Pagination example from book. Make pages start at 1?

2014-02-18 Thread Derek
Well, this is really trivial isn't it?

On Tuesday, February 18, 2014 3:18:14 PM UTC-7, HittingSmoke wrote:
>
> I followed the pagination tutorial in the web2py book and I have the 
> following controller:
>
> def index():
> if len(request.args): page=int(request.args[0])
> else: page=1
> items_per_page=6
> limitby=((page-1)*items_per_page,(page)*items_per_page+1)
> posts=db().select(db.post.ALL, orderby=~db.post.date, limitby=limitby)
> return dict(posts=posts, page=page, items_per_page=items_per_page)
>
> ...and this view controlling navigation:
>
> 
>   
> {{if page>1:}}
> Prev
> {{pass}}
> {{if len(posts)>items_per_page:}}
> Next
> {{pass}}
>   
> 
>
> The only problem I have with it is when you go to the second page it 
> reports as page 1. I would like the first page to be page 1. Is that 
> possible without completely rewriting the pagination function?
>

-- 
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/groups/opt_out.


[web2py] Virtual Field Problem

2014-02-18 Thread Leandro E . Colombo Viña
Hi Guys!

I've got a little problem trying to use Virtual Fields. I can't make them
work. I follow the example in the book and nothing, I don't have a clue of
what I'm doing wrong...
The idea is to have a virtual field that calculates the age of the person
based on his day of birth...

Here is the model:
db.define_table('personal_data',
., # another fields
Field('dob', 'date', requires=IS_DATE()),
., # more fields
auth.signature
)
db.personal_data.age = Field.Virtual('age', lambda row:
diff_in_years(row.dob))

Where the auxiliary function is:
from dateutil import relativedelta as rdelta
def diff_in_years(date):
try:
return rdelta.relativedelta(datetime.datetime.today().date(),
date).years
except:
return None

And here is my test controller:
def prueba():
response.flash = db.personal_data(uid=auth.user.id).age

The traceback says that "Row" doesn't have the attribute "age".

I've also tried with a method (Field.Method), with no luck. I always have
the same error

Any help would be appreciated!
LEO

-- 
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/groups/opt_out.


[web2py] Pagination example from book. Make pages start at 1?

2014-02-18 Thread HittingSmoke
I followed the pagination tutorial in the web2py book and I have the 
following controller:

def index():
if len(request.args): page=int(request.args[0])
else: page=0
items_per_page=6
limitby=(page*items_per_page,(page+1)*items_per_page+1)
posts=db().select(db.post.ALL, orderby=~db.post.date, limitby=limitby)
return dict(posts=posts, page=page, items_per_page=items_per_page)

...and this view controlling navigation:


  
{{if page:}}
Prev
{{pass}}
{{if len(posts)>items_per_page:}}
Next
{{pass}}
  


The only problem I have with it is when you go to the second page it 
reports as page 1. I would like the first page to be page 1. Is that 
possible without completely rewriting the pagination function?

-- 
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/groups/opt_out.


Re: [web2py] How can I run postgresql VACUUM from web2py?

2014-02-18 Thread User
Good point seems autovacuum is already turned on, so not necessary.  
Although purely out of curiosity I'd still be interested to hear how to 
execute this statement if possible or is it not possible from web2py?

On Tuesday, February 18, 2014 11:18:17 AM UTC-5, Richard wrote:
>
> postgresql.conf
>
> autovacuum = on 
>
> Except you have particular need should be alright with postgres 9 +
>
> Richard
>
>
> On Mon, Feb 17, 2014 at 8:42 PM, User >wrote:
>
>> I'm trying to run postgresql vacuum from web2py (ultimately to be run by 
>> a scheduled task) and I get the following error:
>>
>> db.executesql('VACUUM sometable;')
>> *** ProgrammingError: ('ERROR', '25001', 'VACUUM cannot run inside a 
>> transaction
>>  block')
>>
>> How can I run VACUUM from web2py?
>>
>>  -- 
>> 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/groups/opt_out.
>>
>
>

-- 
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/groups/opt_out.


Re: [web2py] No module named ...

2014-02-18 Thread Richard Vézina
:)


On Tue, Feb 18, 2014 at 4:43 PM, Maggs  wrote:

> I found the issue. Somehow my __init__.py file did not get added in the
> main app folder (app/__init__.py) in git. I find this interesting because
> the app was running fine up until the point when I tried to add a module.
> If there was no __init__.py in the main app folder, you'd think the app
> wouldn't have worked at all.
> Anyway, problem solved, thanks for your help :)
>
>
> On Tuesday, February 18, 2014 1:40:35 PM UTC-8, Richard wrote:
>
>> Hmmm... Your issue may come form there... I notice that web2py need all
>> the default folder in app to be there to work properly...
>>
>> app/controllers
>> app/cron
>> app/databases
>> app/errors
>> app/languages
>> app/models
>> app/modules
>> app/private
>> app/sessions
>> app/static
>> app/uploads
>> app/views
>>
>> Are they all there (in your prod)?
>>
>>
>> On Tue, Feb 18, 2014 at 4:36 PM, Maggs  wrote:
>>
>>> There's no app/cache folder as I'm not using any caching in this app.
>>>
>>>
>>> On Tuesday, February 18, 2014 1:30:14 PM UTC-8, Richard wrote:
>>>
 So, clean the app by the admin!

 Or delete what in app/cache maybe?

 Richard


 On Tue, Feb 18, 2014 at 4:27 PM, Maggs  wrote:

> Yes I restarted web2py. I even completely removed the folder and
> re-installed it, thinking perhaps there was some caching going on that was
> causing an issue.
>
>
> On Tuesday, February 18, 2014 1:23:01 PM UTC-8, Richard wrote:
>
>> Did you restart web2py?
>>
>> If you didn't it may be related to the issue with track change of
>> module...
>>
>> Richard
>>
>>
>> On Tue, Feb 18, 2014 at 4:06 PM, Maggs  wrote:
>>
>>> Ok this is literally making me crazy. I'm running web2py 2.5.1 in
>>> python 2.7. On my dev box all is fine. I added a new module called cmgui
>>> that is just a wrapper for an outside custom module. Works fine on my 
>>> dev
>>> box. Push it to my prod box and I'm getting "no module named
>>> auth.modules.cmgui". In my confusion I also tried just creating a blank
>>> module called test.py and importing that via import auth.modules.test 
>>> and
>>> same error. It's as if there is no __init__.py in the directory, but 
>>> there
>>> is. I am at a loss -_-
>>>
>>> --
>>> 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/groups/opt_out.
>>>
>>
>>  --
> 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/groups/opt_out.
>

  --
>>> 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/groups/opt_out.
>>>
>>
>>  --
> 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/groups/opt_out.
>

-- 
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/groups/opt_out.


[web2py] Re: Setting default function in default controller with parametric router

2014-02-18 Thread HittingSmoke
I only just realized that I can set a routes.py file in the application 
directory. Got it all set up using the examples contained in 
applications/app/routes.example.py.

On Monday, February 17, 2014 8:31:58 PM UTC-8, HittingSmoke wrote:
>
> I would like to change my 'index' function to 'page' so that when someone 
> calls a specific page and the router doesn't remove the controller name 
> from the url it will say 'page/1' instead of 'index/1'.
>
> I found this answer via a search: 
> https://stackoverflow.com/questions/17050196/web2py-change-default-controller-and-function
>
> I have two problems with it.
>
> 1. It seems to be global. I would like this default function to be 
> specific to a single app and only in the default controller.
>
> 2. The code in the answer doesn't actually work. It causes python to throw 
> a syntax error when uWSGI is started.
>

-- 
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/groups/opt_out.


Re: [web2py] No module named ...

2014-02-18 Thread Maggs
I found the issue. Somehow my __init__.py file did not get added in the 
main app folder (app/__init__.py) in git. I find this interesting because 
the app was running fine up until the point when I tried to add a module. 
If there was no __init__.py in the main app folder, you'd think the app 
wouldn't have worked at all.
Anyway, problem solved, thanks for your help :)

On Tuesday, February 18, 2014 1:40:35 PM UTC-8, Richard wrote:
>
> Hmmm... Your issue may come form there... I notice that web2py need all 
> the default folder in app to be there to work properly...
>
> app/controllers
> app/cron
> app/databases
> app/errors
> app/languages
> app/models
> app/modules
> app/private
> app/sessions
> app/static
> app/uploads
> app/views
>
> Are they all there (in your prod)?
>
>
> On Tue, Feb 18, 2014 at 4:36 PM, Maggs 
> > wrote:
>
>> There's no app/cache folder as I'm not using any caching in this app.
>>
>>
>> On Tuesday, February 18, 2014 1:30:14 PM UTC-8, Richard wrote:
>>
>>> So, clean the app by the admin!
>>>
>>> Or delete what in app/cache maybe?
>>>
>>> Richard
>>>
>>>
>>> On Tue, Feb 18, 2014 at 4:27 PM, Maggs  wrote:
>>>
 Yes I restarted web2py. I even completely removed the folder and 
 re-installed it, thinking perhaps there was some caching going on that was 
 causing an issue.


 On Tuesday, February 18, 2014 1:23:01 PM UTC-8, Richard wrote:

> Did you restart web2py?
>
> If you didn't it may be related to the issue with track change of 
> module...
>
> Richard
>
>
> On Tue, Feb 18, 2014 at 4:06 PM, Maggs  wrote:
>
>> Ok this is literally making me crazy. I'm running web2py 2.5.1 in 
>> python 2.7. On my dev box all is fine. I added a new module called cmgui 
>> that is just a wrapper for an outside custom module. Works fine on my 
>> dev 
>> box. Push it to my prod box and I'm getting "no module named 
>> auth.modules.cmgui". In my confusion I also tried just creating a blank 
>> module called test.py and importing that via import auth.modules.test 
>> and 
>> same error. It's as if there is no __init__.py in the directory, but 
>> there 
>> is. I am at a loss -_-
>>  
>> -- 
>> 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/groups/opt_out.
>>
>
>  -- 
 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/groups/opt_out.

>>>
>>>  -- 
>> 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/groups/opt_out.
>>
>
>

-- 
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/groups/opt_out.


Re: [web2py] No module named ...

2014-02-18 Thread Richard Vézina
Hmmm... Your issue may come form there... I notice that web2py need all the
default folder in app to be there to work properly...

app/controllers
app/cron
app/databases
app/errors
app/languages
app/models
app/modules
app/private
app/sessions
app/static
app/uploads
app/views

Are they all there (in your prod)?


On Tue, Feb 18, 2014 at 4:36 PM, Maggs  wrote:

> There's no app/cache folder as I'm not using any caching in this app.
>
>
> On Tuesday, February 18, 2014 1:30:14 PM UTC-8, Richard wrote:
>
>> So, clean the app by the admin!
>>
>> Or delete what in app/cache maybe?
>>
>> Richard
>>
>>
>> On Tue, Feb 18, 2014 at 4:27 PM, Maggs  wrote:
>>
>>> Yes I restarted web2py. I even completely removed the folder and
>>> re-installed it, thinking perhaps there was some caching going on that was
>>> causing an issue.
>>>
>>>
>>> On Tuesday, February 18, 2014 1:23:01 PM UTC-8, Richard wrote:
>>>
 Did you restart web2py?

 If you didn't it may be related to the issue with track change of
 module...

 Richard


 On Tue, Feb 18, 2014 at 4:06 PM, Maggs  wrote:

> Ok this is literally making me crazy. I'm running web2py 2.5.1 in
> python 2.7. On my dev box all is fine. I added a new module called cmgui
> that is just a wrapper for an outside custom module. Works fine on my dev
> box. Push it to my prod box and I'm getting "no module named
> auth.modules.cmgui". In my confusion I also tried just creating a blank
> module called test.py and importing that via import auth.modules.test and
> same error. It's as if there is no __init__.py in the directory, but there
> is. I am at a loss -_-
>
> --
> 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/groups/opt_out.
>

  --
>>> 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/groups/opt_out.
>>>
>>
>>  --
> 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/groups/opt_out.
>

-- 
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/groups/opt_out.


Re: [web2py] cache issue

2014-02-18 Thread Richard Vézina
I still have the issue, I forgot this call (see arrow)

# Model file
def return_cached_dict(update_cached_dict_if_elapsed_time=900):
del(globals()['cached_dict'])
global cached_dict
cached_dict = cache.ram('cached_dict',
lambda: {r[0]: r[1] for r in
  db.executesql("""SQL Query""")
 },
time_expire=update_cached_dict
_if_elapsed_time)
return_cached_dict(0) #  *<---*

That should had been :

return_cached_dict(900)

When I set it at the proper value, I still have key error...

Richard



On Tue, Feb 18, 2014 at 4:28 PM, Derek  wrote:

> It is clear as day to me, as written here:
>
> Setting time_expire=0 (or a negative value) forces the cached item to be
> refreshed (because the elapsed time since the last save will always be >
> 0), and setting time_expire=None forces retrieval of the cached value,
> regardless of the time elapsed since it was saved (if time_expire is
> alwaysNone, the cached item will effectively never expire).
>
>
> On Tuesday, February 18, 2014 2:05:39 PM UTC-7, Richard wrote:
>
>> @Derek
>>
>> I read that, what still bug me and seems not explicited (and may be cause
>> of my lack of knowledge), is what happen if there is already an instance
>> that use the cache.ram object at the same time I set time_expire to Zero or
>> even worse, if I delete the variable...
>>
>> Richard
>>
>>
>> On Tue, Feb 18, 2014 at 4:02 PM, Richard Vézina wrote:
>>
>>> Wait!
>>>
>>> I made a mistake... It seems to be solve... Should be the pointer... My
>>> last error was here  (in red):
>>>
>>> if form.process().accepts:
>>> del(globals()['cached_dict'])
>>> return_cached_dict(900)
>>>
>>> Should be 0
>>>
>>>  Also move the del in my factory :
>>>
>>> def return_cached_dict(update_cached_dict_if_elapsed_time=900):
>>> del(globals()['cached_dict'])
>>> global cached_dict
>>> cached_dict = cache.ram('cached_dict',
>>> lambda: {r[0]: r[1] for r in
>>>   db.executesql("""SQL Query
>>> """)
>>>  },
>>> time_expire=update_cached_dict
>>> _if_elapsed_time)
>>>
>>> Then :
>>>
>>> if form.process().accepts:
>>> return_cached_dict(0)
>>>
>>>
>>> Richard
>>>
>>>
>>>
>>> On Tue, Feb 18, 2014 at 3:53 PM, Derek  wrote:
>>>
 You are using the 'examples' to make your cache. That's good that you
 are following the examples, but you really should start by reading the book
 first.

 http://web2py.com/book/default/chapter/04#cache

 It's explained here what's happening and what you can do to invalidate
 the cache and special cases.



 On Monday, February 17, 2014 1:41:29 PM UTC-7, Richard wrote:
>
> Hello,
>
> I have an issue with app design and global variable cached python
> dict...
>
> I use web2py 2.4.7
>
> I use to create cached python dict in models like so :
>
> update_cached_dict_if_elapsed_time = 900
> cached_dict = cache.ram('cached_dict',
>   lambda: {r[0]: r[1] for r in
> db.executesql("""...""")},
>   time_expire=update_cached_dict
> _if_elapsed_time)
>
> cached_dict is a for representation of a given table ids... It intent
> to reduce the number of requests that hit the database by using python 
> dict
> as much as possible...
>
> But I got in trouble trying to update this dict with
> update_cached_dictt_if_elapsed_time... First as cached_dict this
> variable is in globals, so I use to add more logic around the
> update_cached_dict_if_elapsed_time var like so :
>
>
> update_cached_dict_if_elapsed_time = None
> if update_cached_dict_if_elapsed_time == 0:
> pass
> elif request.args(0) == 'table_name' and request.function == 'create'
> and request.post_vars:
> update_cached_dict_if_elapsed_time = 0
>
> I find this cumbersome and prone to error because if I have other
> thing that should trigger a dict update, I have to add more logic...
>
> So, I though I could make factory dict function like so :
>
> def factory_cached_dict(update_cached_dict_if_elapsed_time=900):
> global
> cached_dict
> cached_dict = cache.ram('cached_dict',
>   lambda: {r[0]: r[1] for r in
> db.executesql("""...""")},
>   time_expire=update_cached_
> dict_if_elapsed_time)
>
> factory_cached_dict(900)
>
> Above is in models...
>
> Then I though I could just update my global cached_dict var from any
> controller like so :
>
> if form.process().accepts:
>

Re: [web2py] No module named ...

2014-02-18 Thread Maggs
There's no app/cache folder as I'm not using any caching in this app.

On Tuesday, February 18, 2014 1:30:14 PM UTC-8, Richard wrote:
>
> So, clean the app by the admin!
>
> Or delete what in app/cache maybe?
>
> Richard
>
>
> On Tue, Feb 18, 2014 at 4:27 PM, Maggs 
> > wrote:
>
>> Yes I restarted web2py. I even completely removed the folder and 
>> re-installed it, thinking perhaps there was some caching going on that was 
>> causing an issue.
>>
>>
>> On Tuesday, February 18, 2014 1:23:01 PM UTC-8, Richard wrote:
>>
>>> Did you restart web2py?
>>>
>>> If you didn't it may be related to the issue with track change of 
>>> module...
>>>
>>> Richard
>>>
>>>
>>> On Tue, Feb 18, 2014 at 4:06 PM, Maggs  wrote:
>>>
 Ok this is literally making me crazy. I'm running web2py 2.5.1 in 
 python 2.7. On my dev box all is fine. I added a new module called cmgui 
 that is just a wrapper for an outside custom module. Works fine on my dev 
 box. Push it to my prod box and I'm getting "no module named 
 auth.modules.cmgui". In my confusion I also tried just creating a blank 
 module called test.py and importing that via import auth.modules.test and 
 same error. It's as if there is no __init__.py in the directory, but there 
 is. I am at a loss -_-
  
 -- 
 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/groups/opt_out.

>>>
>>>  -- 
>> 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/groups/opt_out.
>>
>
>

-- 
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/groups/opt_out.


[web2py] Re: Making a phone call from within Web2Py

2014-02-18 Thread Derek
well, that could introduce security issues as far as automatically dialing.
555-555-
that will bring up the dialer with the phone number already filled out.

On Monday, February 17, 2014 9:11:15 PM UTC-7, NeoToren wrote:
>
> Maybe I am pushing the limits here...but I wonder, if we have an address 
> book, with phone numbers ...and today most apps (W2P included)  run quite 
> well in browsers (NOT as native app but HTML)then can user just click 
> on the number and the "smart "phone will make the call ?
> Like a ...native app ?
> ;-))
> Did anyone have an idea if the above is doable in W2P ?
> I know W2P can send emails and SMS - but what about making a phone call ?
>

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


Re: [web2py] Re: Is there a way to set the class in auth.register() form?

2014-02-18 Thread Tito Garrido
thanks!


On Tue, Feb 18, 2014 at 4:20 PM, Anthony  wrote:

> def user:
> form = auth()
> if request.args(0) == 'register':
> form['_class'] = 'myclass'
> return dict(form=form)
>
> Anthony
>
> On Tuesday, February 18, 2014 12:54:46 PM UTC-5, Tito Garrido wrote:
>>
>> Hi Folks,
>>
>> I am trying to customize my registration form. Is there a way to set the
>> class of the generated form of auth.register()?
>>
>> Thanks!
>>
>> 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/groups/opt_out.
>



-- 

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/groups/opt_out.


Re: [web2py] No module named ...

2014-02-18 Thread Richard Vézina
So, clean the app by the admin!

Or delete what in app/cache maybe?

Richard


On Tue, Feb 18, 2014 at 4:27 PM, Maggs  wrote:

> Yes I restarted web2py. I even completely removed the folder and
> re-installed it, thinking perhaps there was some caching going on that was
> causing an issue.
>
>
> On Tuesday, February 18, 2014 1:23:01 PM UTC-8, Richard wrote:
>
>> Did you restart web2py?
>>
>> If you didn't it may be related to the issue with track change of
>> module...
>>
>> Richard
>>
>>
>> On Tue, Feb 18, 2014 at 4:06 PM, Maggs  wrote:
>>
>>> Ok this is literally making me crazy. I'm running web2py 2.5.1 in python
>>> 2.7. On my dev box all is fine. I added a new module called cmgui that is
>>> just a wrapper for an outside custom module. Works fine on my dev box. Push
>>> it to my prod box and I'm getting "no module named auth.modules.cmgui". In
>>> my confusion I also tried just creating a blank module called test.py and
>>> importing that via import auth.modules.test and same error. It's as if
>>> there is no __init__.py in the directory, but there is. I am at a loss -_-
>>>
>>> --
>>> 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/groups/opt_out.
>>>
>>
>>  --
> 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/groups/opt_out.
>

-- 
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/groups/opt_out.


Re: [web2py] cache issue

2014-02-18 Thread Derek
It is clear as day to me, as written here:

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

On Tuesday, February 18, 2014 2:05:39 PM UTC-7, Richard wrote:
>
> @Derek
>
> I read that, what still bug me and seems not explicited (and may be cause 
> of my lack of knowledge), is what happen if there is already an instance 
> that use the cache.ram object at the same time I set time_expire to Zero or 
> even worse, if I delete the variable...
>
> Richard
>
>
> On Tue, Feb 18, 2014 at 4:02 PM, Richard Vézina 
> 
> > wrote:
>
>> Wait!
>>
>> I made a mistake... It seems to be solve... Should be the pointer... My 
>> last error was here  (in red):
>>
>> if form.process().accepts:
>> del(globals()['cached_dict'])
>> return_cached_dict(900)
>>
>> Should be 0
>>
>>  Also move the del in my factory :
>>
>> def return_cached_dict(update_cached_dict_if_elapsed_time=900):
>> del(globals()['cached_dict'])
>> global cached_dict
>> cached_dict = cache.ram('cached_dict',
>> lambda: {r[0]: r[1] for r in
>>   db.executesql("""SQL Query
>> """)
>>  },
>> time_expire=update_cached_dict
>> _if_elapsed_time)
>>
>> Then :
>>
>> if form.process().accepts:
>> return_cached_dict(0)
>>
>>
>> Richard
>>
>>
>>
>> On Tue, Feb 18, 2014 at 3:53 PM, Derek >wrote:
>>
>>> You are using the 'examples' to make your cache. That's good that you 
>>> are following the examples, but you really should start by reading the book 
>>> first.
>>>
>>> http://web2py.com/book/default/chapter/04#cache
>>>
>>> It's explained here what's happening and what you can do to invalidate 
>>> the cache and special cases.
>>>
>>>
>>>
>>> On Monday, February 17, 2014 1:41:29 PM UTC-7, Richard wrote:

 Hello,

 I have an issue with app design and global variable cached python 
 dict...

 I use web2py 2.4.7

 I use to create cached python dict in models like so :

 update_cached_dict_if_elapsed_time = 900
 cached_dict = cache.ram('cached_dict',
   lambda: {r[0]: r[1] for r in 
 db.executesql("""...""")},
   time_expire=update_cached_
 dict_if_elapsed_time)

 cached_dict is a for representation of a given table ids... It intent 
 to reduce the number of requests that hit the database by using python 
 dict 
 as much as possible...

 But I got in trouble trying to update this dict with 
 update_cached_dictt_if_elapsed_time... First as cached_dict this 
 variable is in globals, so I use to add more logic around the 
 update_cached_dict_if_elapsed_time var like so :


 update_cached_dict_if_elapsed_time = None
 if update_cached_dict_if_elapsed_time == 0:
 pass
 elif request.args(0) == 'table_name' and request.function == 'create' 
 and request.post_vars:
 update_cached_dict_if_elapsed_time = 0

 I find this cumbersome and prone to error because if I have other thing 
 that should trigger a dict update, I have to add more logic...

 So, I though I could make factory dict function like so :

 def factory_cached_dict(update_cached_dict_if_elapsed_time=900):
 global
 cached_dict
 cached_dict = cache.ram('cached_dict',
   lambda: {r[0]: r[1] for r in 
 db.executesql("""...""")},
   time_expire=update_cached_
 dict_if_elapsed_time)

 factory_cached_dict(900)

 Above is in models...

 Then I though I could just update my global cached_dict var from any 
 controller like so :

 if form.process().accepts:
 factory_cached_dict(0)  # Because in this form I just add a value 
 to the table use to create the python dict

 But I am really desapointed it not seems to work because I still 
 experiment issue with not up to date cached_dict because there is missing 
 key value pairs for id and it representation.

 I think the issue is that even if I call the factory after form submit 
 the dict get recreated at each request by the factory call in models or 
 there is something else going on that I don't understand (maybe issue with 
 cache in web2py in web2py 2.4.7??)

 Thanks for any help.

 Richard

>>>  -- 
>>> Resources:
>>> - http://web2py.com
>>> - http://web2py.com/book (Documentation)
>>> - http://github.com/web2py/web2py (Source code)
>>> - https://

Re: [web2py] No module named ...

2014-02-18 Thread Maggs
Yes I restarted web2py. I even completely removed the folder and 
re-installed it, thinking perhaps there was some caching going on that was 
causing an issue.

On Tuesday, February 18, 2014 1:23:01 PM UTC-8, Richard wrote:
>
> Did you restart web2py?
>
> If you didn't it may be related to the issue with track change of module...
>
> Richard
>
>
> On Tue, Feb 18, 2014 at 4:06 PM, Maggs 
> > wrote:
>
>> Ok this is literally making me crazy. I'm running web2py 2.5.1 in python 
>> 2.7. On my dev box all is fine. I added a new module called cmgui that is 
>> just a wrapper for an outside custom module. Works fine on my dev box. Push 
>> it to my prod box and I'm getting "no module named auth.modules.cmgui". In 
>> my confusion I also tried just creating a blank module called test.py and 
>> importing that via import auth.modules.test and same error. It's as if 
>> there is no __init__.py in the directory, but there is. I am at a loss -_-
>>  
>> -- 
>> 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/groups/opt_out.
>>
>
>

-- 
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/groups/opt_out.


Re: [web2py] No module named ...

2014-02-18 Thread Richard Vézina
Did you restart web2py?

If you didn't it may be related to the issue with track change of module...

Richard


On Tue, Feb 18, 2014 at 4:06 PM, Maggs  wrote:

> Ok this is literally making me crazy. I'm running web2py 2.5.1 in python
> 2.7. On my dev box all is fine. I added a new module called cmgui that is
> just a wrapper for an outside custom module. Works fine on my dev box. Push
> it to my prod box and I'm getting "no module named auth.modules.cmgui". In
> my confusion I also tried just creating a blank module called test.py and
> importing that via import auth.modules.test and same error. It's as if
> there is no __init__.py in the directory, but there is. I am at a loss -_-
>
> --
> 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/groups/opt_out.
>

-- 
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/groups/opt_out.


Re: [web2py] Re: SQLFORM.factory without a database table

2014-02-18 Thread Marty McCasland
Was aiming to create a grid. Just used an in-memory SQLite db to achieve the 
grid.   Works great. 

Sent from my iPad

> On Feb 18, 2014, at 3:14 PM, Richard Vézina  
> wrote:
> 
> Don't understand your question... It generate a self validating form base on 
> field validator defined in models if you clone you field from there or the 
> Field() if you create field input on the fly...
> 
> Do you want a form? or a Grid?
> 
> If the latter there the TABLE() helper...
> 
> Richard
> 
> 
> 
> 
>> On Tue, Feb 18, 2014 at 3:53 PM, Dave S  wrote:
>> 
>> 
>>> On Thursday, February 13, 2014 9:03:33 PM UTC-8, A36_Marty wrote:
>>> I would like to make a grid-like screen without an underlying database 
>>> table.
>> 
>> 
>> is this something interactive, where the user is entering data?  Or is it 
>> just a display?  If the latter, perhaps you just want the TABLE helper.
>> 
>> /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/groups/opt_out.
> 
> -- 
> Resources:
> - http://web2py.com
> - http://web2py.com/book (Documentation)
> - http://github.com/web2py/web2py (Source code)
> - https://code.google.com/p/web2py/issues/list (Report Issues)
> --- 
> You received this message because you are subscribed to a topic in the Google 
> Groups "web2py-users" group.
> To unsubscribe from this topic, visit 
> https://groups.google.com/d/topic/web2py/ZTvWwT9uuNg/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to 
> web2py+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.

-- 
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/groups/opt_out.


Re: [web2py] Re: Angular.js And other js lib

2014-02-18 Thread Richard Vézina
Good point Derek, I saw it in angular.js file when I test the slice (that
at least work), as you say it is a cleaner approach...

:)

Richard


On Tue, Feb 18, 2014 at 4:01 PM, Derek  wrote:

> no, no, no, do not use that slice, it's a waste of time to edit the
> angular.js file itself. you want to do that every time a new version is
> released? also why not just use a cdn for angular.js?
>
> http://docs.angularjs.org/api/ng/provider/$interpolateProvider#startSymbol
> The above link shows how to do it properly.
>
> Here's a snippet from their 'sample' code...
>
>   var customInterpolationApp = angular.module('customInterpolationApp',
> []);
>customInterpolationApp.config(function($interpolateProvider) {
> $interpolateProvider.startSymbol('//');
> $interpolateProvider.endSymbol('//');
>
> That changes the start and end symbols to '//' but you could just as
> easily change them to '[[' and ']]' or '||' and '||' or whatever you want.
>
> On Tuesday, February 18, 2014 1:19:14 PM UTC-7, Richard wrote:
>
>> http://www.web2pyslices.com/slice/show/1922/web2py-angularjs
>>
>> Change angular {{ }} for {! !}
>>
>> Having to type to different character bug me though, but you need a
>> closing tag...
>>
>> :(
>>
>> Richard
>>
>>
>> On Tue, Feb 18, 2014 at 3:05 PM, Derek  wrote:
>>
>>> and to note you can change the brackets in angular to use something
>>> else...
>>>
>>> see here:
>>>
>>> http://docs.angularjs.org/api/ng/service/$interpolate
>>>
>>> by default it uses {{ and }} as starting and ending brackets.
>>>
>>>
>>> On Tuesday, February 18, 2014 12:59:48 PM UTC-7, Derek wrote:

 Well, the problem you have is that if you put angular tags in your
 views, they will be parsed with the template parser of web2py and error.
 The way to avoid that is to use the angular classes instead. For example,
 all the 'ng-app' and 'ng-controller' and 'ng-repeat' attributes (
 http://docs.angularjs.org/tutorial/step_02). Keep in mind that the
 python template language will get parsed first, and only after that will
 the angular template parser be used.

 On Tuesday, February 18, 2014 12:49:42 PM UTC-7, Arvind Gupta wrote:
>
> Can we use angular.js with web2py, if yes can u point me to
> appropriate resources?
>
  --
>>> 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/groups/opt_out.
>>>
>>
>>  --
> 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/groups/opt_out.
>

-- 
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/groups/opt_out.


Re: [web2py] LDAP Auth

2014-02-18 Thread Maggs
Hi Richard,

The modifications I ended up making to the framework were actually quite 
simple. This is web2py 2.5.1 and python 2.7 btw.

In the ldap_auth.py file, I added the following to the ldap_auth function 
parameter list: cacert_file=None, cert_file=None, key_file=None. So now the 
function header looks like so:
def ldap_auth(server='ldap', port=None,
  base_dn='ou=users,dc=domain,dc=com',
  mode='uid', secure=False, cacert_path=None, cacert_file=None,
  cert_file=None, key_file=None,
  bind_dn=None, bind_pw=None, filterstr='objectClass=*',
  username_attrib='uid',
  custom_scope='subtree',
  allowed_groups=None,
  manage_user=False,
  user_firstname_attrib='cn:1',
  user_lastname_attrib='cn:2',
  user_mail_attrib='mail',
  manage_groups=False,
  db=None,
  group_dn=None,
  group_name_attrib='cn',
  group_member_attrib='memberUid',
  group_filterstr='objectClass=*',
  logging_level='error'):

I repeated this same step for the ldap_auth_aux function so it looks like 
this:
def ldap_auth_aux(username,
  password,
  ldap_server=server,
  ldap_port=port,
  ldap_basedn=base_dn,
  ldap_mode=mode,
  ldap_binddn=bind_dn,
  ldap_bindpw=bind_pw,
  secure=secure,
  cacert_path=cacert_path,
  cacert_file=cacert_file,
  cert_file=cert_file,
  key_file=key_file,
  filterstr=filterstr,
  username_attrib=username_attrib,
  custom_scope=custom_scope,
  manage_user=manage_user,
  user_firstname_attrib=user_firstname_attrib,
  user_lastname_attrib=user_lastname_attrib,
  user_mail_attrib=user_mail_attrib,
  manage_groups=manage_groups,
  allowed_groups=allowed_groups,
  db=db):

and finally for the init_ldap function:
init_ldap(ldap_server=server,
  ldap_port=port,
  ldap_basedn=base_dn,
  ldap_mode=mode,
  secure=secure,
  cacert_path=cacert_path,
  cacert_file=cacert_file,
  cert_file=cert_file,
  key_file=key_file):
And within this function I changed the code that was in the if secure 
statement like so:
if secure:
if not ldap_port:
ldap_port = 636

if cacert_path:
ldap.set_option(ldap.OPT_X_TLS_CACERTDIR, cacert_path)

if cacert_file:
ldap.set_option(ldap.OPT_X_TLS_REQUIRE_CERT, 
ldap.OPT_X_TLS_NEVER)
ldap.set_option(ldap.OPT_X_TLS_CACERTFILE, cacert_file)
if cert_file:
ldap.set_option(ldap.OPT_X_TLS_CERTFILE, cert_file)
if key_file:
ldap.set_option(ldap.OPT_X_TLS_KEYFILE, key_file)

con = ldap.initialize("ldaps://" + ldap_server + ":" + 
str(ldap_port))

Something that I had a bit of an issue and eventually figured out is that 
these options need to be set BEFORE the ldap connection is initialized. 
Which in the original code, wasn't happening. In the original code, the 
connection was initialized and THEN the cert options were set, like so:
if secure:
if not ldap_port:
ldap_port = 636
con = ldap.initialize(
"ldaps://" + ldap_server + ":" + str(ldap_port))
if cert_path:
con.set_option(ldap.OPT_X_TLS_CACERTDIR, cert_path)
if cert_file:
con.set_option(ldap.OPT_X_TLS_CACERTFILE, cert_file)
and this does not work.

Hope this helps someone :)

Thanks,
Maggs

On Friday, December 20, 2013 6:43:35 AM UTC-8, Richard wrote:
>
> Could you show your mods?
>
> It could help to understand the issue you have how we can solve them...
>
> Richard
>
>
> On Thu, Dec 19, 2013 at 7:30 PM, Maggs 
> > wrote:
>
>> Yes secure ldap is causing a lot of problems. I hope it gets sorted out 
>> eventually. For now I'm having to modify the framework for my needs. 
>>
>>
>> On Wednesday, November 27, 2013 7:18:45 AM UTC-8, Richard wrote:
>>
>>> ldap_auth need care, to me it's a draft that need code review, but it 
>>> works... I had many issue when I deploy ldap_auth with AD... But I didn't 
>>> have time to work further on these issues, we figure it out what was the 
>>> bottom of them, but refatoring ldap_auth need time and the most important 
>>> tests...
>>>
>>> Richard
>>>
>>>
>>> On Tue, Nov 26, 2013 at 8:12 PM, Maggs  wrote:
>>>
 I am in this s

Re: [web2py] Re: Redis caching

2014-02-18 Thread Arnon Marcus
I like how in this medium people can talk behind your back and in your face
at the same time! :P

I actually invested about 2 weeks (both at work AND at home), experimenting
with MANY different options of storing and retrieving data in redis, using
all structure-types, using both generic (procedural-generated) data, and
our own real-world data. It started out as a pet-project, but it mushroomed
into a very detailed and flexible "py-redis-benchmarking tool", which I
have every intention of sharing on github - I think it's over a 1k-loc
already... You basically tell it which benchmak-combination(s) you wish to
run, and it prints the results in a nicely-organized table. If you choose
to use the procedurally-generated data (for synthetic-benchmarking) you can
define each of the 3 dimensions it has (keys, records, fields), to see how
each effect each redis-storing-option (lists, sets, hashes, etc.). So you
can get a feel for how "scale" behaves as a factor of influence on the
benefits/trade-offs of each storage-option. I think I will add
graph-plotting for IPython, just for the fun of it...

In conclusion:
A major performance-factor is the number of round-trips to redis, so I
employed heavy-use of "pipeline", But it turns out that another
major-performance-factor after that, is the manipulations that need to
happen to the data in python, on pre-storing and post-retrival, in order to
fit the data into the redis-structures. Turns out, that - at least for
bulk-store/retrival (pipeline-usage), the overheads of fitting a data
structure into redis, outweighs the benefits, sometimes by orders of
magnitude. Perhaps if an application is written to use redis as a database,
it would be worth it, as interjecting into a specific value "nested" inside
a redis-structure "may" be faster than having to pull an entire "key" with
serialized data - but that's not the use-case we're talking about for
"caching" in web2py.

So, the *tl;dr;*  version of it, is:
"Flat key-value store of serialized data is fastest for
bulk-store/retrieval"

* Especially when using "hiredis" (python-wrapper around a "c-compiled"
redis-client - That's orders-of-magnitudes faster...)

Then I went to testing many serialization formats/libraries:
- JSON (pure-python)
- simplejson (with "c-compiled" optimizations)
- cjson (a "c-compiled" library w/Python-wrapper)
- ujson (a "c-compiled" library w/Python-wrapper)
- pickle (pure-python)
- cPickle (a "c-compiled" library w/Python-wrapper)
- msgpack (with "c-compiled" optimizations)
- u-msgpack (pure-python)
- marshal

Results:
- all pure-python options are slowest (unsurprising)
- simplejson is almost as fast as cjson when used with
c-compiled-optimization, and is more maintained, so no use for cjson.
- cPickle is almost as fast as marshal, and is platform/version agnostic,
so no use for marshal.
- ujson is only faster than simplejson for very long (and flat) lists, and
is less maintained/popular/mature.

So, that leaves us with:
- simplejson
- cPickle
- msgpack

- cPickle is actually "slowest", AND is python-only.
- With either simplejson or msgpack, you can read the data from redis from
non-python clients AND they both (surprisingly) handle unicode really well..
- msgpack is roughly x2 faster than simplejson, but is less-readable in a
redis-GUI.

However:
When using simplejson or msgpack. once you introduce "DateTime" values, you
need to process the results in python by interjecting into the parsers with
hooks... Once you do that, all the performance-gain nullifies...
So cPickle becomes fastest, as it generates the python "DateTime" objects
in the c-level...

So I ended-up where I started, rounding a full-circle back to flat-keys
with cPickle...

The only benefit I ended-up gaining, is by re-factoring our high-level
cache-data-structure, on-top of redis_cache.py, that does bulk-retrival and
smart-refreshes - but I'm not sure I can share that code...

We are now doing a bulk-get of our entire redis-cache on every request.
It has over 100 keys, some very small and some with hundreds of
nested-records. We narrowed it down to 16ms per-request (best-case), which
is good enough for me.

We basically have a class in a module, which instanciates a
non-thread-local singleton, once per-process. It has an ordered-dictionary
of "keys" mapped to "lambdas". We call it the "cache-catalog". The results
are stored in a regular dictionary (which is thread-local), which maps the
keys to their respective resultant-value. On each request, a bulk-get is
issued with a list of all the keys (which we already have - it's the keys
of the catalog + the "w2py::" prefix, so we don't even need to have
them stored in redis in a separate set... And we still don't have to use
the infamous "GET KEYS" redis-command...), and since the catalog is an
ordered-dictionary, we know which value in the result maps to which key. So
we know the "None" values represent the keys that are currently "missing"
in redis, due to a deletion triggered by a cache-up

Re: [web2py] Re: SQLFORM.factory without a database table

2014-02-18 Thread Richard Vézina
Don't understand your question... It generate a self validating form base
on field validator defined in models if you clone you field from there or
the Field() if you create field input on the fly...

Do you want a form? or a Grid?

If the latter there the TABLE() helper...

Richard




On Tue, Feb 18, 2014 at 3:53 PM, Dave S  wrote:

>
>
> On Thursday, February 13, 2014 9:03:33 PM UTC-8, A36_Marty wrote:
>>
>> I would like to make a grid-like screen without an underlying database
>> table.
>>
>>
> is this something interactive, where the user is entering data?  Or is it
> just a display?  If the latter, perhaps you just want the TABLE helper.
>
> /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/groups/opt_out.
>

-- 
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/groups/opt_out.


[web2py] No module named ...

2014-02-18 Thread Maggs
Ok this is literally making me crazy. I'm running web2py 2.5.1 in python 
2.7. On my dev box all is fine. I added a new module called cmgui that is 
just a wrapper for an outside custom module. Works fine on my dev box. Push 
it to my prod box and I'm getting "no module named auth.modules.cmgui". In 
my confusion I also tried just creating a blank module called test.py and 
importing that via import auth.modules.test and same error. It's as if 
there is no __init__.py in the directory, but there is. I am at a loss -_-

-- 
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/groups/opt_out.


Re: [web2py] cache issue

2014-02-18 Thread Richard Vézina
@Derek

I read that, what still bug me and seems not explicited (and may be cause
of my lack of knowledge), is what happen if there is already an instance
that use the cache.ram object at the same time I set time_expire to Zero or
even worse, if I delete the variable...

Richard


On Tue, Feb 18, 2014 at 4:02 PM, Richard Vézina  wrote:

> Wait!
>
> I made a mistake... It seems to be solve... Should be the pointer... My
> last error was here  (in red):
>
> if form.process().accepts:
> del(globals()['cached_dict'])
> return_cached_dict(900)
>
> Should be 0
>
> Also move the del in my factory :
>
> def return_cached_dict(update_cached_dict_if_elapsed_time=900):
> del(globals()['cached_dict'])
> global cached_dict
> cached_dict = cache.ram('cached_dict',
> lambda: {r[0]: r[1] for r in
>   db.executesql("""SQL Query
> """)
>  },
> time_expire=update_cached_dict
> _if_elapsed_time)
>
> Then :
>
> if form.process().accepts:
> return_cached_dict(0)
>
>
> Richard
>
>
>
> On Tue, Feb 18, 2014 at 3:53 PM, Derek  wrote:
>
>> You are using the 'examples' to make your cache. That's good that you are
>> following the examples, but you really should start by reading the book
>> first.
>>
>> http://web2py.com/book/default/chapter/04#cache
>>
>> It's explained here what's happening and what you can do to invalidate
>> the cache and special cases.
>>
>>
>>
>> On Monday, February 17, 2014 1:41:29 PM UTC-7, Richard wrote:
>>>
>>> Hello,
>>>
>>> I have an issue with app design and global variable cached python dict...
>>>
>>> I use web2py 2.4.7
>>>
>>> I use to create cached python dict in models like so :
>>>
>>> update_cached_dict_if_elapsed_time = 900
>>> cached_dict = cache.ram('cached_dict',
>>>   lambda: {r[0]: r[1] for r in
>>> db.executesql("""...""")},
>>>   time_expire=update_cached_
>>> dict_if_elapsed_time)
>>>
>>> cached_dict is a for representation of a given table ids... It intent to
>>> reduce the number of requests that hit the database by using python dict as
>>> much as possible...
>>>
>>> But I got in trouble trying to update this dict with
>>> update_cached_dictt_if_elapsed_time... First as cached_dict this
>>> variable is in globals, so I use to add more logic around the
>>> update_cached_dict_if_elapsed_time var like so :
>>>
>>>
>>> update_cached_dict_if_elapsed_time = None
>>> if update_cached_dict_if_elapsed_time == 0:
>>> pass
>>> elif request.args(0) == 'table_name' and request.function == 'create'
>>> and request.post_vars:
>>> update_cached_dict_if_elapsed_time = 0
>>>
>>> I find this cumbersome and prone to error because if I have other thing
>>> that should trigger a dict update, I have to add more logic...
>>>
>>> So, I though I could make factory dict function like so :
>>>
>>> def factory_cached_dict(update_cached_dict_if_elapsed_time=900):
>>> global
>>> cached_dict
>>> cached_dict = cache.ram('cached_dict',
>>>   lambda: {r[0]: r[1] for r in
>>> db.executesql("""...""")},
>>>   time_expire=update_cached_
>>> dict_if_elapsed_time)
>>>
>>> factory_cached_dict(900)
>>>
>>> Above is in models...
>>>
>>> Then I though I could just update my global cached_dict var from any
>>> controller like so :
>>>
>>> if form.process().accepts:
>>> factory_cached_dict(0)  # Because in this form I just add a value to
>>> the table use to create the python dict
>>>
>>> But I am really desapointed it not seems to work because I still
>>> experiment issue with not up to date cached_dict because there is missing
>>> key value pairs for id and it representation.
>>>
>>> I think the issue is that even if I call the factory after form submit
>>> the dict get recreated at each request by the factory call in models or
>>> there is something else going on that I don't understand (maybe issue with
>>> cache in web2py in web2py 2.4.7??)
>>>
>>> Thanks for any help.
>>>
>>> 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/groups/opt_out.
>>
>
>

-- 
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" g

Re: [web2py] cache issue

2014-02-18 Thread Richard Vézina
Wait!

I made a mistake... It seems to be solve... Should be the pointer... My
last error was here  (in red):

if form.process().accepts:
del(globals()['cached_dict'])
return_cached_dict(900)

Should be 0

Also move the del in my factory :

def return_cached_dict(update_cached_dict_if_elapsed_time=900):
del(globals()['cached_dict'])
global cached_dict
cached_dict = cache.ram('cached_dict',
lambda: {r[0]: r[1] for r in
  db.executesql("""SQL Query""")
 },
time_expire=update_cached_dict
_if_elapsed_time)

Then :

if form.process().accepts:
return_cached_dict(0)


Richard



On Tue, Feb 18, 2014 at 3:53 PM, Derek  wrote:

> You are using the 'examples' to make your cache. That's good that you are
> following the examples, but you really should start by reading the book
> first.
>
> http://web2py.com/book/default/chapter/04#cache
>
> It's explained here what's happening and what you can do to invalidate the
> cache and special cases.
>
>
>
> On Monday, February 17, 2014 1:41:29 PM UTC-7, Richard wrote:
>>
>> Hello,
>>
>> I have an issue with app design and global variable cached python dict...
>>
>> I use web2py 2.4.7
>>
>> I use to create cached python dict in models like so :
>>
>> update_cached_dict_if_elapsed_time = 900
>> cached_dict = cache.ram('cached_dict',
>>   lambda: {r[0]: r[1] for r in
>> db.executesql("""...""")},
>>   time_expire=update_cached_
>> dict_if_elapsed_time)
>>
>> cached_dict is a for representation of a given table ids... It intent to
>> reduce the number of requests that hit the database by using python dict as
>> much as possible...
>>
>> But I got in trouble trying to update this dict with
>> update_cached_dictt_if_elapsed_time... First as cached_dict this
>> variable is in globals, so I use to add more logic around the
>> update_cached_dict_if_elapsed_time var like so :
>>
>>
>> update_cached_dict_if_elapsed_time = None
>> if update_cached_dict_if_elapsed_time == 0:
>> pass
>> elif request.args(0) == 'table_name' and request.function == 'create' and
>> request.post_vars:
>> update_cached_dict_if_elapsed_time = 0
>>
>> I find this cumbersome and prone to error because if I have other thing
>> that should trigger a dict update, I have to add more logic...
>>
>> So, I though I could make factory dict function like so :
>>
>> def factory_cached_dict(update_cached_dict_if_elapsed_time=900):
>> global
>> cached_dict
>> cached_dict = cache.ram('cached_dict',
>>   lambda: {r[0]: r[1] for r in
>> db.executesql("""...""")},
>>   time_expire=update_cached_
>> dict_if_elapsed_time)
>>
>> factory_cached_dict(900)
>>
>> Above is in models...
>>
>> Then I though I could just update my global cached_dict var from any
>> controller like so :
>>
>> if form.process().accepts:
>> factory_cached_dict(0)  # Because in this form I just add a value to
>> the table use to create the python dict
>>
>> But I am really desapointed it not seems to work because I still
>> experiment issue with not up to date cached_dict because there is missing
>> key value pairs for id and it representation.
>>
>> I think the issue is that even if I call the factory after form submit
>> the dict get recreated at each request by the factory call in models or
>> there is something else going on that I don't understand (maybe issue with
>> cache in web2py in web2py 2.4.7??)
>>
>> Thanks for any help.
>>
>> 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/groups/opt_out.
>

-- 
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/groups/opt_out.


Re: [web2py] Re: Angular.js And other js lib

2014-02-18 Thread Derek
no, no, no, do not use that slice, it's a waste of time to edit the 
angular.js file itself. you want to do that every time a new version is 
released? also why not just use a cdn for angular.js?

http://docs.angularjs.org/api/ng/provider/$interpolateProvider#startSymbol
The above link shows how to do it properly.

Here's a snippet from their 'sample' code...

  var customInterpolationApp = angular.module('customInterpolationApp', []);
   customInterpolationApp.config(function($interpolateProvider) {
$interpolateProvider.startSymbol('//');
$interpolateProvider.endSymbol('//');

That changes the start and end symbols to '//' but you could just as easily 
change them to '[[' and ']]' or '||' and '||' or whatever you want.

On Tuesday, February 18, 2014 1:19:14 PM UTC-7, Richard wrote:
>
> http://www.web2pyslices.com/slice/show/1922/web2py-angularjs
>
> Change angular {{ }} for {! !}
>
> Having to type to different character bug me though, but you need a 
> closing tag...
>
> :(
>
> Richard
>
>
> On Tue, Feb 18, 2014 at 3:05 PM, Derek >wrote:
>
>> and to note you can change the brackets in angular to use something 
>> else...
>>
>> see here:
>>
>> http://docs.angularjs.org/api/ng/service/$interpolate
>>
>> by default it uses {{ and }} as starting and ending brackets. 
>>
>>
>> On Tuesday, February 18, 2014 12:59:48 PM UTC-7, Derek wrote:
>>>
>>> Well, the problem you have is that if you put angular tags in your 
>>> views, they will be parsed with the template parser of web2py and error. 
>>> The way to avoid that is to use the angular classes instead. For example, 
>>> all the 'ng-app' and 'ng-controller' and 'ng-repeat' attributes (
>>> http://docs.angularjs.org/tutorial/step_02). Keep in mind that the 
>>> python template language will get parsed first, and only after that will 
>>> the angular template parser be used.
>>>
>>> On Tuesday, February 18, 2014 12:49:42 PM UTC-7, Arvind Gupta wrote:

 Can we use angular.js with web2py, if yes can u point me to appropriate 
 resources?

>>>  -- 
>> 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/groups/opt_out.
>>
>
>

-- 
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/groups/opt_out.


[web2py] Re: SQLFORM.factory without a database table

2014-02-18 Thread Dave S


On Thursday, February 13, 2014 9:03:33 PM UTC-8, A36_Marty wrote:
>
> I would like to make a grid-like screen without an underlying database 
> table.
>
>
is this something interactive, where the user is entering data?  Or is it 
just a display?  If the latter, perhaps you just want the TABLE helper.

/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/groups/opt_out.


Re: [web2py] cache issue

2014-02-18 Thread Derek
You are using the 'examples' to make your cache. That's good that you are 
following the examples, but you really should start by reading the book 
first.

http://web2py.com/book/default/chapter/04#cache

It's explained here what's happening and what you can do to invalidate the 
cache and special cases.



On Monday, February 17, 2014 1:41:29 PM UTC-7, Richard wrote:
>
> Hello,
>
> I have an issue with app design and global variable cached python dict...
>
> I use web2py 2.4.7
>
> I use to create cached python dict in models like so :
>
> update_cached_dict_if_elapsed_time = 900
> cached_dict = cache.ram('cached_dict',
>   lambda: {r[0]: r[1] for r in 
> db.executesql("""...""")},
>   
> time_expire=update_cached_dict_if_elapsed_time)
>
> cached_dict is a for representation of a given table ids... It intent to 
> reduce the number of requests that hit the database by using python dict as 
> much as possible...
>
> But I got in trouble trying to update this dict with 
> update_cached_dictt_if_elapsed_time... First as cached_dict this variable 
> is in globals, so I use to add more logic around the 
> update_cached_dict_if_elapsed_time var like so :
>
>
> update_cached_dict_if_elapsed_time = None
> if update_cached_dict_if_elapsed_time == 0:
> pass
> elif request.args(0) == 'table_name' and request.function == 'create' and 
> request.post_vars:
> update_cached_dict_if_elapsed_time = 0
>
> I find this cumbersome and prone to error because if I have other thing 
> that should trigger a dict update, I have to add more logic...
>
> So, I though I could make factory dict function like so :
>
> def factory_cached_dict(update_cached_dict_if_elapsed_time=900):
> global
> cached_dict
> cached_dict = cache.ram('cached_dict',
>   lambda: {r[0]: r[1] for r in 
> db.executesql("""...""")},
>   
> time_expire=update_cached_dict_if_elapsed_time)
>
> factory_cached_dict(900)
>
> Above is in models...
>
> Then I though I could just update my global cached_dict var from any 
> controller like so :
>
> if form.process().accepts:
> factory_cached_dict(0)  # Because in this form I just add a value to 
> the table use to create the python dict
>
> But I am really desapointed it not seems to work because I still 
> experiment issue with not up to date cached_dict because there is missing 
> key value pairs for id and it representation.
>
> I think the issue is that even if I call the factory after form submit the 
> dict get recreated at each request by the factory call in models or there 
> is something else going on that I don't understand (maybe issue with cache 
> in web2py in web2py 2.4.7??)
>
> Thanks for any help.
>
> 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/groups/opt_out.


Re: [web2py] Re: Angular.js And other js lib

2014-02-18 Thread Anthony
Note, you can also change the delimiters used in web2py templates by 
setting response.delimiters.

Anthony

On Tuesday, February 18, 2014 3:19:14 PM UTC-5, Richard wrote:
>
> http://www.web2pyslices.com/slice/show/1922/web2py-angularjs
>
> Change angular {{ }} for {! !}
>
> Having to type to different character bug me though, but you need a 
> closing tag...
>
> :(
>
> Richard
>
>
> On Tue, Feb 18, 2014 at 3:05 PM, Derek >wrote:
>
>> and to note you can change the brackets in angular to use something 
>> else...
>>
>> see here:
>>
>> http://docs.angularjs.org/api/ng/service/$interpolate
>>
>> by default it uses {{ and }} as starting and ending brackets. 
>>
>>
>> On Tuesday, February 18, 2014 12:59:48 PM UTC-7, Derek wrote:
>>>
>>> Well, the problem you have is that if you put angular tags in your 
>>> views, they will be parsed with the template parser of web2py and error. 
>>> The way to avoid that is to use the angular classes instead. For example, 
>>> all the 'ng-app' and 'ng-controller' and 'ng-repeat' attributes (
>>> http://docs.angularjs.org/tutorial/step_02). Keep in mind that the 
>>> python template language will get parsed first, and only after that will 
>>> the angular template parser be used.
>>>
>>> On Tuesday, February 18, 2014 12:49:42 PM UTC-7, Arvind Gupta wrote:

 Can we use angular.js with web2py, if yes can u point me to appropriate 
 resources?

>>>  -- 
>> 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/groups/opt_out.
>>
>
>

-- 
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/groups/opt_out.


Re: [web2py] cache issue

2014-02-18 Thread Richard Vézina
if form.process().accepts:
del(globals()['cached_dict'])
return_cached_dict(900)

I still get key error...

:(

Like if they were not executed... I test it and the factory in shell and
everthing work fine there...

Richard


On Tue, Feb 18, 2014 at 3:19 PM, Niphlod  wrote:

> did you try to short-circuit the code to delete the cached value and
> refill it with the new copy of the dict to see if it's a culprit of your
> code or of the cache ?
> Mind that cache.ram has some subtle differences because it just stores a
> pointer to the object, not the copy of the object like all other backends
>
>
> On Tuesday, February 18, 2014 4:01:16 PM UTC+1, Richard wrote:
>
>> Need advice!
>>
>> Richard
>>
>>
>> On Mon, Feb 17, 2014 at 4:11 PM, Richard Vézina wrote:
>>
>>> Nop!
>>>
>>> :(
>>>
>>> Richard
>>>
>>>
>>> On Mon, Feb 17, 2014 at 3:54 PM, Richard Vézina 
>>> wrote:
>>>
 Hmm, I think I find my issue...

 if form.process().accepts:
 db.commit()
 factory_cached_dict(0)  # Because in this form I just add a value
 to the table use to create the python dict


 On Mon, Feb 17, 2014 at 3:41 PM, Richard  wrote:

> Hello,
>
> I have an issue with app design and global variable cached python
> dict...
>
> I use web2py 2.4.7
>
> I use to create cached python dict in models like so :
>
> update_cached_dict_if_elapsed_time = 900
> cached_dict = cache.ram('cached_dict',
>   lambda: {r[0]: r[1] for r in
> db.executesql("""...""")},
>   time_expire=update_cached_
> dict_if_elapsed_time)
>
> cached_dict is a for representation of a given table ids... It intent
> to reduce the number of requests that hit the database by using python 
> dict
> as much as possible...
>
> But I got in trouble trying to update this dict with
> update_cached_dictt_if_elapsed_time... First as cached_dict this
> variable is in globals, so I use to add more logic around the
> update_cached_dict_if_elapsed_time var like so :
>
>
> update_cached_dict_if_elapsed_time = None
> if update_cached_dict_if_elapsed_time == 0:
> pass
> elif request.args(0) == 'table_name' and request.function == 'create'
> and request.post_vars:
> update_cached_dict_if_elapsed_time = 0
>
> I find this cumbersome and prone to error because if I have other
> thing that should trigger a dict update, I have to add more logic...
>
> So, I though I could make factory dict function like so :
>
> def factory_cached_dict(update_cached_dict_if_elapsed_time=900):
> global
> cached_dict
>  cached_dict = cache.ram('cached_dict',
>   lambda: {r[0]: r[1] for r in
> db.executesql("""...""")},
>   time_expire=update_cached_
> dict_if_elapsed_time)
>
> factory_cached_dict(900)
>
> Above is in models...
>
> Then I though I could just update my global cached_dict var from any
> controller like so :
>
> if form.process().accepts:
> factory_cached_dict(0)  # Because in this form I just add a value
> to the table use to create the python dict
>
> But I am really desapointed it not seems to work because I still
> experiment issue with not up to date cached_dict because there is missing
> key value pairs for id and it representation.
>
> I think the issue is that even if I call the factory after form submit
> the dict get recreated at each request by the factory call in models or
> there is something else going on that I don't understand (maybe issue with
> cache in web2py in web2py 2.4.7??)
>
> Thanks for any help.
>
> 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+un...@googlegroups.com.
>
> For more options, visit https://groups.google.com/groups/opt_out.
>


>>>
>>  --
> 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/groups/opt_out.
>

-- 
Resources:
- http:

[web2py] Re: Email password on clear text?

2014-02-18 Thread Niphlod
who sends the email is totally unrelated to who the user is  in fact, 
it's a "service" account that serves the only purpose of being an approved 
sender on the mail relay (a good rule of thumb, it shouldn't be backed by 
an inbox).
If you disclose your app to others, feel free to put that in a variable and 
say explicitely in the docs what it's needed to be set to have the 
application working when deployed elsewhere. 

On Monday, February 17, 2014 2:53:32 PM UTC+1, sw2band wrote:
>
> Good day:
>
> I am developing my first web application with web2py, so I follow the 
> "Setting up mail" section of the reference manual:
>
>
> http://web2py.com/books/default/chapter/29/08/emails-and-sms#Setting-up-email
>
> I have a concern with the *mail.settings.login*, because this expose my 
> password on clear text (if the application is successful, more developers 
> will have access to the code).
>
> Is possible to get this credentials from the auth_user table?. So this would 
> be encrypted and "*synchronized*" with my LDAP directory.
>
> 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/groups/opt_out.


[web2py] Re: Allow NULL in form validator with reference Field

2014-02-18 Thread Niphlod
does your backend support a foreign key with a null value ? not all of them 
can.
As an alternative, you can

Field('awc_pro_id', requires=IS_EMPTY_OR(IS_IN_DB()))

On Monday, February 17, 2014 7:21:14 PM UTC+1, brahama von wrote:
>
> Hi,
>
> dunno why my previous post didn't make it. Here it goes.
>
> part of my model
>
> legacy_db.define_table('courses',
> Field('awc_name','string'),
> Field('awc_version','string'),
> Field('awc_link','string'),
> Field('awc_pro_id',legacy_db.project, required=False, default=None),
> Field('awc_cli_id',legacy_db.client),
> format='%(awc_name)s',
> migrate=False)
>
> While creating a form for insert new courses i get the validator error; 
> "value not in database"
>
> While this is true, i allow that value to be NULL in DB. How can i allow 
> that in the form and insert the record?
>
>
> controller
>
> form=SQLFORM(legacy_db.courses)
> if form.process().accepted:
> response.flash = 'Course was added Correctly'
> return dict(form=form,message=T('Edition for Courses'))
>
>
> 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/groups/opt_out.


Re: [web2py] Eliminating Submit Button

2014-02-18 Thread Richard Vézina
So remove button[type=submit] in

$("button[type=submit]#ButtonSubmitId").hide();

$("#ButtonSubmitId").hide();

Should work with only the tag id

Richard


On Tue, Feb 18, 2014 at 3:05 PM, horridohobbyist
wrote:

> It's not working. I get the alert() messages, but the button methods
> aren't doing anything.
>
> I inserted "_id='fred'" in the INPUT(_type='submit',...) call. I presume
> "button[type=submit]#fred" should correctly reference the object?
>
>
> On Tuesday, 18 February 2014 10:19:54 UTC-5, Richard wrote:
>
>> 
>> $(document).ready(function() {
>> $("input#YourSelectFieldId").focus(); // not required
>> $("button[type=submit]#ButtonSubmitId").hide();
>> $('form select[name=YourSelectFieldId]').on('change', function()
>> {
>> //alert($('select[name=YourSelectFieldId]
>> option:selected').val()); // For testing
>> $("button[type=submit]#ButtonSubmitId").submit();
>> });
>> });
>> 
>>
>>
>> On Tue, Feb 18, 2014 at 7:24 AM, horridohobbyist wrote:
>>
>>> I have a SQLFORM.grid that allows the user to select a query from a
>>> selection of queries. The user selects the query using this form:
>>>
>>> FORM(TABLE(TR(T("Choose Category:"),SELECT([my_list],_
>>> name='category',value=current)),
>>>TR("",INPUT(_type='submit'
>>>
>>> The grid is:
>>>
>>> SQLFORM.grid(query,
>>> orderby=db.products.category,
>>> csv=False)
>>>
>>> I would like the user to not have to click on a submit button. I just
>>> want to have some action that will modify the grid query as soon as the
>>> selection is made. What's the best way to do this? (I can think of a very,
>>> very messy way, but I'd like to avoid that.)
>>>
>>> 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+un...@googlegroups.com.
>>>
>>> For more options, visit https://groups.google.com/groups/opt_out.
>>>
>>
>>  --
> 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/groups/opt_out.
>

-- 
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/groups/opt_out.


Re: [web2py] cache issue

2014-02-18 Thread Niphlod
did you try to short-circuit the code to delete the cached value and refill 
it with the new copy of the dict to see if it's a culprit of your code or 
of the cache ?
Mind that cache.ram has some subtle differences because it just stores a 
pointer to the object, not the copy of the object like all other backends

On Tuesday, February 18, 2014 4:01:16 PM UTC+1, Richard wrote:
>
> Need advice!
>
> Richard
>
>
> On Mon, Feb 17, 2014 at 4:11 PM, Richard Vézina 
> 
> > wrote:
>
>> Nop!
>>
>> :(
>>
>> Richard
>>
>>
>> On Mon, Feb 17, 2014 at 3:54 PM, Richard Vézina 
>> 
>> > wrote:
>>
>>> Hmm, I think I find my issue...
>>>
>>> if form.process().accepts:
>>> db.commit()
>>> factory_cached_dict(0)  # Because in this form I just add a value to 
>>> the table use to create the python dict
>>>
>>>
>>> On Mon, Feb 17, 2014 at 3:41 PM, Richard 
>>> > wrote:
>>>
 Hello,

 I have an issue with app design and global variable cached python 
 dict...

 I use web2py 2.4.7

 I use to create cached python dict in models like so :

 update_cached_dict_if_elapsed_time = 900
 cached_dict = cache.ram('cached_dict',
   lambda: {r[0]: r[1] for r in 
 db.executesql("""...""")},
   
 time_expire=update_cached_dict_if_elapsed_time)

 cached_dict is a for representation of a given table ids... It intent 
 to reduce the number of requests that hit the database by using python 
 dict 
 as much as possible...

 But I got in trouble trying to update this dict with 
 update_cached_dictt_if_elapsed_time... First as cached_dict this variable 
 is in globals, so I use to add more logic around the 
 update_cached_dict_if_elapsed_time var like so :


 update_cached_dict_if_elapsed_time = None
 if update_cached_dict_if_elapsed_time == 0:
 pass
 elif request.args(0) == 'table_name' and request.function == 'create' 
 and request.post_vars:
 update_cached_dict_if_elapsed_time = 0

 I find this cumbersome and prone to error because if I have other thing 
 that should trigger a dict update, I have to add more logic...

 So, I though I could make factory dict function like so :

 def factory_cached_dict(update_cached_dict_if_elapsed_time=900):
 global
 cached_dict
  cached_dict = cache.ram('cached_dict',
   lambda: {r[0]: r[1] for r in 
 db.executesql("""...""")},
   
 time_expire=update_cached_dict_if_elapsed_time)

 factory_cached_dict(900)

 Above is in models...

 Then I though I could just update my global cached_dict var from any 
 controller like so :

 if form.process().accepts:
 factory_cached_dict(0)  # Because in this form I just add a value 
 to the table use to create the python dict

 But I am really desapointed it not seems to work because I still 
 experiment issue with not up to date cached_dict because there is missing 
 key value pairs for id and it representation.

 I think the issue is that even if I call the factory after form submit 
 the dict get recreated at each request by the factory call in models or 
 there is something else going on that I don't understand (maybe issue with 
 cache in web2py in web2py 2.4.7??)

 Thanks for any help.

 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+un...@googlegroups.com .
 For more options, visit https://groups.google.com/groups/opt_out.

>>>
>>>
>>
>

-- 
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/groups/opt_out.


Re: [web2py] Re: Angular.js And other js lib

2014-02-18 Thread Richard Vézina
http://www.web2pyslices.com/slice/show/1922/web2py-angularjs

Change angular {{ }} for {! !}

Having to type to different character bug me though, but you need a closing
tag...

:(

Richard


On Tue, Feb 18, 2014 at 3:05 PM, Derek  wrote:

> and to note you can change the brackets in angular to use something else...
>
> see here:
>
> http://docs.angularjs.org/api/ng/service/$interpolate
>
> by default it uses {{ and }} as starting and ending brackets.
>
>
> On Tuesday, February 18, 2014 12:59:48 PM UTC-7, Derek wrote:
>>
>> Well, the problem you have is that if you put angular tags in your views,
>> they will be parsed with the template parser of web2py and error. The way
>> to avoid that is to use the angular classes instead. For example, all the
>> 'ng-app' and 'ng-controller' and 'ng-repeat' attributes (
>> http://docs.angularjs.org/tutorial/step_02). Keep in mind that the
>> python template language will get parsed first, and only after that will
>> the angular template parser be used.
>>
>> On Tuesday, February 18, 2014 12:49:42 PM UTC-7, Arvind Gupta wrote:
>>>
>>> Can we use angular.js with web2py, if yes can u point me to appropriate
>>> resources?
>>>
>>  --
> 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/groups/opt_out.
>

-- 
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/groups/opt_out.


Re: [web2py] Eliminating Submit Button

2014-02-18 Thread horridohobbyist
It's not working. I get the alert() messages, but the button methods aren't 
doing anything.

I inserted "_id='fred'" in the INPUT(_type='submit',...) call. I presume 
"button[type=submit]#fred" should correctly reference the object?


On Tuesday, 18 February 2014 10:19:54 UTC-5, Richard wrote:
>
> 
> $(document).ready(function() {
> $("input#YourSelectFieldId").focus(); // not required
> $("button[type=submit]#ButtonSubmitId").hide();
> $('form select[name=YourSelectFieldId]').on('change', function() {
> //alert($('select[name=YourSelectFieldId] 
> option:selected').val()); // For testing
> $("button[type=submit]#ButtonSubmitId").submit();
> });
> });
> 
>
>
> On Tue, Feb 18, 2014 at 7:24 AM, horridohobbyist 
> 
> > wrote:
>
>> I have a SQLFORM.grid that allows the user to select a query from a 
>> selection of queries. The user selects the query using this form:
>>
>> FORM(TABLE(TR(T("Choose Category:"),SELECT([my_list
>> ],_name='category',value=current)),
>>TR("",INPUT(_type='submit'
>>
>> The grid is:
>>
>> SQLFORM.grid(query,
>> orderby=db.products.category,
>> csv=False)
>>
>> I would like the user to not have to click on a submit button. I just 
>> want to have some action that will modify the grid query as soon as the 
>> selection is made. What's the best way to do this? (I can think of a very, 
>> very messy way, but I'd like to avoid that.)
>>
>> 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+un...@googlegroups.com .
>> For more options, visit https://groups.google.com/groups/opt_out.
>>
>
>

-- 
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/groups/opt_out.


[web2py] Re: Angular.js And other js lib

2014-02-18 Thread Derek
and to note you can change the brackets in angular to use something else...

see here:

http://docs.angularjs.org/api/ng/service/$interpolate

by default it uses {{ and }} as starting and ending brackets. 

On Tuesday, February 18, 2014 12:59:48 PM UTC-7, Derek wrote:
>
> Well, the problem you have is that if you put angular tags in your views, 
> they will be parsed with the template parser of web2py and error. The way 
> to avoid that is to use the angular classes instead. For example, all the 
> 'ng-app' and 'ng-controller' and 'ng-repeat' attributes (
> http://docs.angularjs.org/tutorial/step_02). Keep in mind that the python 
> template language will get parsed first, and only after that will the 
> angular template parser be used.
>
> On Tuesday, February 18, 2014 12:49:42 PM UTC-7, Arvind Gupta wrote:
>>
>> Can we use angular.js with web2py, if yes can u point me to appropriate 
>> resources?
>>
>

-- 
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/groups/opt_out.


[web2py] Re: Angular.js And other js lib

2014-02-18 Thread Derek
Well, the problem you have is that if you put angular tags in your views, 
they will be parsed with the template parser of web2py and error. The way 
to avoid that is to use the angular classes instead. For example, all the 
'ng-app' and 'ng-controller' and 'ng-repeat' attributes 
(http://docs.angularjs.org/tutorial/step_02). Keep in mind that the python 
template language will get parsed first, and only after that will the 
angular template parser be used.

On Tuesday, February 18, 2014 12:49:42 PM UTC-7, Arvind Gupta wrote:
>
> Can we use angular.js with web2py, if yes can u point me to appropriate 
> resources?
>

-- 
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/groups/opt_out.


Re: [web2py] A query too far? Inner join with group by...

2014-02-18 Thread Derek
Joe, it seems to me all you need is this part here:
select course, event_code, min(finals) as "min_time" from times
where id_competitor= and finals>0
group by course, event_code

Or are you interested in returning other columns within the 'times' table?
if so, just use min(other columns) in the query, no need for a derived 
table.

So, in any case, web2py works a little differently. Taking the book example 
and modifying it, here's what I get...

for row in db(db.times.competitor==).select(
db.times.course, db.times.event_code, min_time, 
groupby=(db.times.course,db.times.event_code)):
print row.times.course, row[min_time]

What you need to do before that can work is to create the min_time 
operator...

min_time = db.times.finals.min()

oh, but you wanted to only select non negative numbers, and finals has some 
negatives in it...  (add a where clause to the select)
Good luck!

On Monday, February 17, 2014 2:46:23 PM UTC-7, Joe Barnhart wrote:
>
> Hi Richard --
>
> Don't need to try it...  Do a thought experiment...  The "belongs" matches 
> the entire set of all affected times, event_codes and courses.  It becomes 
> the cartesian product of all combinations of time, event_code, and course. 
>  It matches N*M*K entries in the times table, where N, M, and K are the 
> counts of the members of the set.  By contrast, the number of rows in the 
> minimum times query is a tiny fraction of that.
>
> Let's say I have a competitor with a minimum time of 10 sec. in event 1, 
> course A.  He may also have that exact time (on a bad day) for event 2, 
> course B.  In this scenario, event 2 course B would normally be a much 
> faster time -- in fact his "best" times has such a faster time.  But when 
> you do the overall query with "belongs" on ALL members of times, 
> event_code, and course, you will match BOTH 10 sec. times -- event 1 on 
> course A and event 2 on course B, so both times will appear in the final 
> result.  (Along with the true best time for event 2, course B, which was 
> faster than 10 sec.)
>
> I could probably do a correlated subquery to solve this problem, but those 
> are famously inefficient.  The join, convoluted as it is (and I agree 
> there) is still the best way.
>
> What I really wish I could do is use a select to return the min(time) and 
> the ID of the row it occurred on.  But GROUP BY won't allow that.  One of 
> the limitations of the set theory underpinning SQL.  That's where the 
> correlated subquery comes it -- do a select with ORDER BY on time, then 
> choose LIMIT BY 0,1 to get only one row.  But that query has to be repeated 
> for every combination of course and event_code.  I have about 20 rows to 
> search for a typical competitor and each query above takes around 700 ms. 
> so that's not a good option!
>
> -- Joe B.
>
> On Monday, February 17, 2014 12:51:07 PM UTC-8, Richard wrote:
>>
>> But what you do in the join should be reproducible in a where clause... I 
>> start rewriting your join into a where clause at first and realize that I 
>> would need to rewrite 3-4 for time the same subquery in sql or I had to 
>> write a recursive query that would not help in translation into web2py 
>> query...
>>
>> I don't see how the multiples belongs would not lead to the samething as 
>> you query did you try it?
>>
>> You still have the option of just using db.executesql(''' your actual sql 
>> query ''')
>>
>> Richard
>>
>>
>> On Mon, Feb 17, 2014 at 3:24 PM, Joe Barnhart wrote:
>>
>>> Hi Richard --
>>>
>>> I thought about a subquery...  But I've never seen or heard of the trick 
>>> of using "subquery[0]" to pick out one column of the subquery.  
>>>
>>> I see your approach is to materialize the subquery as a Rows object and 
>>> then pick out elements.  I don't think this will work as expected tho 
>>> because the "belongs" logic will choose incorrect values.  For example say 
>>> the time is 10 seconds, but there are 20 different rows (NOT "best" times) 
>>> with the same time.  Your approach will choose the 10 sec. time for ALL 
>>> combinations of event code and course -- not just the SPECIFIC combination 
>>> in the row that matches the "best" time..  
>>>
>>> That's why I chose a "join" -- it forces the elements to match 
>>> perfectly.  But thanks for the technique.  The idea of materializing the 
>>> Rows and using it in another query bears thinking about.
>>>
>>> -- Joe
>>>
>>>
>>> On Monday, February 17, 2014 7:32:57 AM UTC-8, Richard wrote:
>>>
 Hello Joe,

 Found your plain sql query already convoluted, there is not simpler way 
 to express it in SQL first? You seem to use join as if it was a where, 
 join 
 not intent for this, using it like that will make thing slower...

 Could this work :

 subquery = db.executesql('''select course, event_code, min(finals) as "
 min_time" from times
 where id_competitor= and finals>0
 group by course, event_code''')

 rows = 

[web2py] Angular.js And other js lib

2014-02-18 Thread Arvind Gupta
Can we use angular.js with web2py, if yes can u point me to appropriate
resources?

-- 
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/groups/opt_out.


[web2py] Re: only one session/login per user?

2014-02-18 Thread Donatas Burba
I need solution for allowing only one session for one username (not relying 
on IPs, just one username == one session). This is my quick solution, maybe 
it helps someone :)

So in models/db.py:

auth.settings.login_onvalidation.append(lambda form: 
delete_user_sessions(form.vars.username))

Somewhere in modules (borrowed from 
applications/admin/cron/expire_sessions.py):

def delete_user_sessions(username):
DIGITS = ('0', '1', '2', '3', '4', '5', '6', '7', '8', '9')
import os, cPickle
from gluon import current
request = current.request
path = os.path.join(request.folder, 'sessions')
if not os.path.exists(path):
return
for filename in os.listdir(path):
fullpath = os.path.join(path, filename)
if os.path.isfile(fullpath) and filename.startswith(DIGITS):
try:
session_data = cPickle.load(open(fullpath, 'rb+'))
session_username = session_data.auth.user.username
if session_username == username:
os.unlink(fullpath)
except:
pass

2014 m. vasaris 4 d., antradienis 08:41:52 UTC+2, DeanK rašė:
>
> I've been searching around trying to figure out how to do this without 
> success.  I need to enforce only a single login per user.  Out of the box 
> you can login using the same credentials from different computers, but I 
> need logging in on a different computer to terminate the session of the 
> first log in.  Is this possible?  I found some posts that hinted at using 
> session.connect, but then i couldn't find "check_client" in the ebook...and 
> it didn't seem to work when i tested it.
>
>
> ## Limit single user sessions
> session.connect(request,response,check_client=True) 
>
> Any tips would be appreciated.  Thanks,
>
> Dean
>

-- 
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/groups/opt_out.


[web2py] Re: Redis caching

2014-02-18 Thread Derek
>endless arguments just to "win"? 

I don't think it's that, I think that people who consider themselves "idea 
men" are people who are generally lazy who don't want to do any of the 
work, but want to take credit for it. They discount the amount of time that 
developers put into a project and state that they could do it better (if 
they could just be bothered to implement their idea, which happens to be 
too simple for them to bother with.) I was merely suggesting that the best 
way to handle such people is to say 'it is a wonderful idea! people might 
steal it! better be the first to implement it yourself and then patent it!' 
What I've seen is that they usually shut up about their great 'new idea' 
and maybe they learn that programming isn't as easy or 'simple' as they 
thought it was.

On Thursday, February 6, 2014 3:44:37 PM UTC-7, Jufsa Lagom wrote:
>
> Hello Arnon.
>
> I just made a quick search of your posts on the other groups on 
> groups.google.com..
>
> On many (almost all) groups that you have made posts, you run into 
> arguments with longtime members/contributors that have put down huge amount 
> of time in the projects.
>
> You say yourself in many posts, that you are inexperienced in the subject 
> that are being discussed?
> Then, perhaps it's good to take a more humble approach when addressing 
> your questions/statements?
> I can only speak for myself, that I should at least pick that approach if 
> I had a question to the community..  
>
> Don't misunderstand me, It's always good with new ideas and fresh 
> insights..
> But when meeting massive resistance in a community about an idea that 
> doesn't seem to get any traction, then perhaps that idea shouldn't be 
> forced with endless arguments just to "win"? 
>
> Sorry for the OT, and this is just a friendly hint from an old news user :)
>
> --
> Kind Regards 
> Jufsa Lagom
>
> On Thursday, January 16, 2014 11:57:05 PM UTC+1, Arnon Marcus wrote:
>>
>> Derek: Are you being sarcastic and mean?
>>
>>  
>>
>>> cache doesn't cache only resultsets, hence pickle is the only possible 
>>> choice.
>>>  
>>>
>>
>> Well, not if you only need flat and basic objects - there the benefit of 
>> pickle is mute and it's overhead is obvious - take a look at this project:
>> https://redis-collections.readthedocs.org/en/latest/
>>  
>>
>>> It's cool. Actually, I started developing something like that using DAL 
>>> callbacks, but as soon as multiple tables are involved with FK and such, it 
>>> starts to loose "speed". Also, your whole app needs to be coded a-la 
>>> "ActiveRecord", i.e. fetch only by PK. 
>>>
>>
>> Hmmm... Haven't thought of that... Well, you can't search/query for 
>> specific records by their hashed-values, but that's not the use-case I was 
>> thinking about - I am not suggesting "replacing" the dal... Plus, that 
>> restriction would also exist when using pickles for such a use-case...
>> What I had in mind is simpler than that - just have a bunch of simple 
>> queries that you would do in your cache.ram anyways, and instead have their 
>> "raw" result-set (before being parsed into "rows" objects) and cached as-is 
>> (almost...) - that would be faster to load-in the cache than into 
>> cache.ram, and also faster for retrieval.
>>  
>>
>>> BTW, I'm not properly sure that fetching 100 records with 100 calls to 
>>> redis vs pulling a single time a pickle of 1000 records and discarding what 
>>> you don't need is faster.
>>>
>>
>> Hmmm... I don't know, redis is famous for crunching somewhere in the 
>> order of 500K requests per-second - have you tested it? 
>>  
>>
>>> BTW2: ORM are already there: redisco and redis-lympid
>>>
>>
>> 10x, I'll take a look - though I think an ORM would defeat the purpose 
>> (in terms of of speed) and would be overkill... 
>>
>

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


[web2py] Re: Is there a way to set the class in auth.register() form?

2014-02-18 Thread Anthony
def user:
form = auth()
if request.args(0) == 'register':
form['_class'] = 'myclass'
return dict(form=form)

Anthony
On Tuesday, February 18, 2014 12:54:46 PM UTC-5, Tito Garrido wrote:
>
> Hi Folks,
>
> I am trying to customize my registration form. Is there a way to set the 
> class of the generated form of auth.register()?
>
> Thanks!
>
> 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/groups/opt_out.


Re: [web2py] Re: how to get globals like "request" available in my own modules ?

2014-02-18 Thread Jonathan Lundell
On 18 Feb 2014, at 10:15 AM, Anthony  wrote:
> What's the difference between your method and doing:
> 
> In mymodule.py:
> 
> from gluon import current
> 
> def helper():
> current.request.get('variable', ...)
> 
> In a model file:
> 
> from mymodule import helper
> from gluon import current
> current.auth = auth
> 
> Anthony

I've adopted this variation in my model:

from gluon import current
current.app = Storage()
current.app.auth = auth
current.app.logger = logger

...and so on. The idea is that current.myapp establishes a namespace (seems 
prudent), and making the namespace an instance of Storage lets me do in the 
module:

from gluon import current

def whatever():
...
do something with current.app.auth

...and the like


> 
> On Tuesday, February 18, 2014 11:42:41 AM UTC-5, Julio F. Schwarzbeck wrote:
> 
> 
> Just a clarification, the method I described is not intended to only 
> "allow" the different environment variables within your app, but extend 
> them by creating a "wrapper" in which you can create your "common" or 
> "helper" methods available throughout your application. 
> 
> Agreed that If what you need is only access to environment variables, 
> indeed current is the way yo go. 
> 
> Thx, 
> 
> Julio 
> 
> On 02/16/2014 04:40 PM, Anthony wrote: 
> > Note, instead of this method, you can now use gluon.current. 
> > 
> > Anthony 
> > 
> > On Sunday, February 16, 2014 6:32:13 PM UTC-5, Julio F. Schwarzbeck wrote: 
> > 
> > 
> > 
> > 
> > I assume that if you will use modules they'll probably be 
> > implemented in 
> > some kind of class, I'd personally do something similar to this.. 
> > 
> > # mymodule.py 
> > class ModuleHelper(object): 
> >   """ Sample Helper for common methods. 
> > 
> >   """ 
> > 
> >   def __init__(self, environment): 
> >   self.request = environment['request'] 
> >   self.response = environment['response'] 
> >   self.session = environment['session'] 
> >   self.cache = environment['cache'] 
> >   self.db = environment['db'] 
> >   self.auth = environment['auth'] 
> > 
> >   def method(self): 
> >   self.request.get('variable', ) 
> > 
> >  ... 
> > 
> > And when instantiating the module say from a model: 
> > 
> > # mymodel.py 
> > from mymodule import ModuleHelper 
> > ... 
> > And Later in the same mymodel.py 
> > ... 
> > # Make the module class/methods available: 
> > my_module_helper = ModuleHelper(globals()) 
> > 
> > Now you can use my_module_helper.my_method(params) from within any view 
> > or controller.. 
> > 
> > Hope it helps. 
> > 
> > Julio 
> > 
> > On 02/16/2014 01:55 PM, Stef Mientki wrote: 
> >  > hello, 
> >  > 
> >  > how to get globals like "request" available in my own modules ? 
> >  > 
> >  > thanks, 
> >  > Stef 
> >  > 
> > 
> > 
> >



-- 
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/groups/opt_out.


[web2py] web2py mini conference in Chicago

2014-02-18 Thread Massimo Di Pierro
Let's try this again

I am planning to organize a one day web2py mini conference in Chicago. 
Would you be interested?

If so, please let me know about your availability.

http://doodle.com/nrgr3tt45m3vr5bg


Massimo

P.S. We may stream it. We may allow remote talks. We will definitively 
allow chats. Only check a box if you can be here in person and possibly 
interested to talk about something.

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


[web2py] Re: how to get globals like "request" available in my own modules ?

2014-02-18 Thread Anthony
What's the difference between your method and doing:

In mymodule.py:

from gluon import current

def helper():
current.request.get('variable', ...)

In a model file:

from mymodule import helper
from gluon import current
current.auth = auth

Anthony

On Tuesday, February 18, 2014 11:42:41 AM UTC-5, Julio F. Schwarzbeck wrote:
>
>
>
> Just a clarification, the method I described is not intended to only 
> "allow" the different environment variables within your app, but extend 
> them by creating a "wrapper" in which you can create your "common" or 
> "helper" methods available throughout your application. 
>
> Agreed that If what you need is only access to environment variables, 
> indeed current is the way yo go. 
>
> Thx, 
>
> Julio 
>
> On 02/16/2014 04:40 PM, Anthony wrote: 
> > Note, instead of this method, you can now use gluon.current. 
> > 
> > Anthony 
> > 
> > On Sunday, February 16, 2014 6:32:13 PM UTC-5, Julio F. Schwarzbeck 
> wrote: 
> > 
> > 
> > 
> > 
> > I assume that if you will use modules they'll probably be 
> > implemented in 
> > some kind of class, I'd personally do something similar to this.. 
> > 
> > # mymodule.py 
> > class ModuleHelper(object): 
> >   """ Sample Helper for common methods. 
> > 
> >   """ 
> > 
> >   def __init__(self, environment): 
> >   self.request = environment['request'] 
> >   self.response = environment['response'] 
> >   self.session = environment['session'] 
> >   self.cache = environment['cache'] 
> >   self.db = environment['db'] 
> >   self.auth = environment['auth'] 
> > 
> >   def method(self): 
> >   self.request.get('variable', ) 
> > 
> >  ... 
> > 
> > And when instantiating the module say from a model: 
> > 
> > # mymodel.py 
> > from mymodule import ModuleHelper 
> > ... 
> > And Later in the same mymodel.py 
> > ... 
> > # Make the module class/methods available: 
> > my_module_helper = ModuleHelper(globals()) 
> > 
> > Now you can use my_module_helper.my_method(params) from within any 
> view 
> > or controller.. 
> > 
> > Hope it helps. 
> > 
> > Julio 
> > 
> > On 02/16/2014 01:55 PM, Stef Mientki wrote: 
> >  > hello, 
> >  > 
> >  > how to get globals like "request" available in my own modules ? 
> >  > 
> >  > thanks, 
> >  > Stef 
> >  > 
> > 
> > 
> > 
> > -- 
> > 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+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/ez6zc...@public.gmane.org
> >  
> > For more options, visit https://groups.google.com/groups/opt_out. 
>
>
>

-- 
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/groups/opt_out.


[web2py] Web2py Separating Controller and View Layer

2014-02-18 Thread Ykä Marjanen
Juslin, I've done it manually like in your example. Yes it's long, but gives 
full control on every field. I also define number of rows for each text box and 
have a placeholder text. Also classes and other parameters (e.g. Default 
values) are easier too define in view than in controller, so that everything is 
in one place,

-- 
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/groups/opt_out.


[web2py] Is there a way to set the class in auth.register() form?

2014-02-18 Thread Tito Garrido
Hi Folks,

I am trying to customize my registration form. Is there a way to set the
class of the generated form of auth.register()?

Thanks!

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/groups/opt_out.


[web2py] Re: how to get globals like "request" available in my own modules ?

2014-02-18 Thread Julio F Schwarzbeck



Just a clarification, the method I described is not intended to only 
"allow" the different environment variables within your app, but extend 
them by creating a "wrapper" in which you can create your "common" or 
"helper" methods available throughout your application.


Agreed that If what you need is only access to environment variables, 
indeed current is the way yo go.


Thx,

Julio

On 02/16/2014 04:40 PM, Anthony wrote:

Note, instead of this method, you can now use gluon.current.

Anthony

On Sunday, February 16, 2014 6:32:13 PM UTC-5, Julio F. Schwarzbeck wrote:




I assume that if you will use modules they'll probably be
implemented in
some kind of class, I'd personally do something similar to this..

# mymodule.py
class ModuleHelper(object):
  """ Sample Helper for common methods.

  """

  def __init__(self, environment):
  self.request = environment['request']
  self.response = environment['response']
  self.session = environment['session']
  self.cache = environment['cache']
  self.db = environment['db']
  self.auth = environment['auth']

  def method(self):
  self.request.get('variable', )

 ...

And when instantiating the module say from a model:

# mymodel.py
from mymodule import ModuleHelper
...
And Later in the same mymodel.py
...
# Make the module class/methods available:
my_module_helper = ModuleHelper(globals())

Now you can use my_module_helper.my_method(params) from within any view
or controller..

Hope it helps.

Julio

On 02/16/2014 01:55 PM, Stef Mientki wrote:
 > hello,
 >
 > how to get globals like "request" available in my own modules ?
 >
 > thanks,
 > Stef
 >



--
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+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/ez6zc...@public.gmane.org
For more options, visit https://groups.google.com/groups/opt_out.



--
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/groups/opt_out.


[web2py] Re: creating a model of a table (with a large amount of data) in a mysql db. is taking a very long time

2014-02-18 Thread Anthony
The amount of data doesn't affect how long it takes the appadmin home page 
to load, as no data are being pulled from the database at that point. Even 
when you do select a specific table, it only loads the first 100 records, 
so again, nothing should hang.

Note, defining the model of the table (as in your code below) doesn't 
actually pull any of the data from the database -- it just tells web2py 
about the structure of the database table so it knows how to make selects, 
updates, inserts, etc.

Anthony

On Tuesday, February 18, 2014 11:15:06 AM UTC-5, John Philip wrote:
>
> Hi there,
>
> I am trying to access a mysql database table with a very large amount of 
> data. 
>
> dbsql =  DAL('mysql://myusername:mypasswrd@host/dbname', migrate=False)
>
> dbsql.define_table('evth',
> Field('datetime', 'integer'),
> Field('eventid','text'),
> Field('stream','integer'),
> Field('application','text'),
> Field('workstation','text'),
> Field('severity','text'),
> Field('type','text'),
> Field('message','text'),
> primarykey=['datetime'])
>
> In theory this should work. However when I run the database administration 
> button to create the models it seems to hang. I suspect because of the 
> amount of data. Since I am only interested in the most recent data is there 
> anyway of doing this without web2py having to model the entire table? 
>
> any help would be much appreciated.
>
> many thanks and regards,
>
> John
>

-- 
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/groups/opt_out.


Re: [web2py] How can I run postgresql VACUUM from web2py?

2014-02-18 Thread Richard Vézina
postgresql.conf

autovacuum = on

Except you have particular need should be alright with postgres 9 +

Richard


On Mon, Feb 17, 2014 at 8:42 PM, User  wrote:

> I'm trying to run postgresql vacuum from web2py (ultimately to be run by a
> scheduled task) and I get the following error:
>
> db.executesql('VACUUM sometable;')
> *** ProgrammingError: ('ERROR', '25001', 'VACUUM cannot run inside a
> transaction
>  block')
>
> How can I run VACUUM from web2py?
>
>  --
> 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/groups/opt_out.
>

-- 
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/groups/opt_out.


[web2py] creating a model of a table (with a large amount of data) in a mysql db. is taking a very long time

2014-02-18 Thread John Philip
Hi there,

I am trying to access a mysql database table with a very large amount of 
data. 

dbsql =  DAL('mysql://myusername:mypasswrd@host/dbname', migrate=False)

dbsql.define_table('evth',
Field('datetime', 'integer'),
Field('eventid','text'),
Field('stream','integer'),
Field('application','text'),
Field('workstation','text'),
Field('severity','text'),
Field('type','text'),
Field('message','text'),
primarykey=['datetime'])

In theory this should work. However when I run the database administration 
button to create the models it seems to hang. I suspect because of the 
amount of data. Since I am only interested in the most recent data is there 
anyway of doing this without web2py having to model the entire table? 

any help would be much appreciated.

many thanks and regards,

John

-- 
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/groups/opt_out.


[web2py] expand_one not working

2014-02-18 Thread sasogeek
in db.py, the table status is defined as follows
db.define_table(
'status',
Field('status', 'text'),
Field('file', 'upload'),
Field('userid'),
)

and in default.py, the download function is defined as
def download():
"""
allows downloading of uploaded files
http:///[app]/default/download/[filename]
"""
return response.download(request, db)

just like in the tutorial book.
and in the views, i have this code

{{from gluon.contrib.autolinks import expand_one}}
...
{{updates=db().select(db.status.ALL, orderby=~db.status.id)}}
{{if updates:}}
{{for update in updates:}}
{{=XML(expand_one(URL('download', 
args=update.file,),cache.ram('mycache',lambda:dict(),3600)))}}
  {{pass}}
{{pass}}


if update.file is an image, it works fine and the image is rendered just 
fine, but when it's a pdf, it doesn't work, I get this error 
Sorry, we were unable to find the document at the original source. Verify 
that the document still exists. You can also try to download the original 
document by clicking here

When I click on the link that says "here", it opens a google docs page in a 
new window with the same error statement in it how do i fix this?

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


Re: [web2py] Re: Question on linking fields

2014-02-18 Thread Jim Steil
Glad to help.


On Tue, Feb 18, 2014 at 6:10 AM, Greg Vaughan wrote:

> Hi Jim
>
> That was exactly what I needed thanks so much. Works perfectly.
>
> --
> Resources:
> - http://web2py.com
> - http://web2py.com/book (Documentation)
> - http://github.com/web2py/web2py (Source code)
> - https://code.google.com/p/web2py/issues/list (Report Issues)
> ---
> You received this message because you are subscribed to a topic in the
> Google Groups "web2py-users" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/web2py/eYOJtIjxCYg/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to
> web2py+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.
>

-- 
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/groups/opt_out.


[web2py] What do you think?

2014-02-18 Thread Travis May
I wanted to bring to your attention an app that I built on PythonAnywhere 
that shows just how quickly you can build something useful with web2py 
using PythonAnywhere to deploy.

http://travismay.pythonanywhere.com/bracket_builder/odds/bracket

I built this app, which contains over 14,000 lines of code as the basis of 
the logical engine, in a sprint I did over the weekend of Feb. 7 - 9.  

To top this off, I am new to Python (less than a year of experience) and 
fairly new to programming in general.  This is not to brag on my abilities, 
but to show just what the power of the web2py framework coupled with 
PythonAnywhere's deployment capabilities can do.

Please let me know what you think of the app!

-- 
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/groups/opt_out.


[web2py] Re: Question on linking fields

2014-02-18 Thread Greg Vaughan
Hi Jim

That was exactly what I needed thanks so much. Works perfectly.

-- 
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/groups/opt_out.


Re: [web2py] Eliminating Submit Button

2014-02-18 Thread Richard Vézina

$(document).ready(function() {
$("input#YourSelectFieldId").focus(); // not required
$("button[type=submit]#ButtonSubmitId").hide();
$('form select[name=YourSelectFieldId]').on('change', function() {
//alert($('select[name=YourSelectFieldId]
option:selected').val()); // For testing
$("button[type=submit]#ButtonSubmitId").submit();
});
});



On Tue, Feb 18, 2014 at 7:24 AM, horridohobbyist
wrote:

> I have a SQLFORM.grid that allows the user to select a query from a
> selection of queries. The user selects the query using this form:
>
> FORM(TABLE(TR(T("Choose Category:"),SELECT([my_list
> ],_name='category',value=current)),
>TR("",INPUT(_type='submit'
>
> The grid is:
>
> SQLFORM.grid(query,
> orderby=db.products.category,
> csv=False)
>
> I would like the user to not have to click on a submit button. I just want
> to have some action that will modify the grid query as soon as the
> selection is made. What's the best way to do this? (I can think of a very,
> very messy way, but I'd like to avoid that.)
>
> 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/groups/opt_out.
>

-- 
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/groups/opt_out.


Re: [web2py] cache issue

2014-02-18 Thread Richard Vézina
Need advice!

Richard


On Mon, Feb 17, 2014 at 4:11 PM, Richard Vézina  wrote:

> Nop!
>
> :(
>
> Richard
>
>
> On Mon, Feb 17, 2014 at 3:54 PM, Richard Vézina <
> ml.richard.vez...@gmail.com> wrote:
>
>> Hmm, I think I find my issue...
>>
>> if form.process().accepts:
>> db.commit()
>> factory_cached_dict(0)  # Because in this form I just add a value to
>> the table use to create the python dict
>>
>>
>> On Mon, Feb 17, 2014 at 3:41 PM, Richard wrote:
>>
>>> Hello,
>>>
>>> I have an issue with app design and global variable cached python dict...
>>>
>>> I use web2py 2.4.7
>>>
>>> I use to create cached python dict in models like so :
>>>
>>> update_cached_dict_if_elapsed_time = 900
>>> cached_dict = cache.ram('cached_dict',
>>>   lambda: {r[0]: r[1] for r in
>>> db.executesql("""...""")},
>>>
>>> time_expire=update_cached_dict_if_elapsed_time)
>>>
>>> cached_dict is a for representation of a given table ids... It intent to
>>> reduce the number of requests that hit the database by using python dict as
>>> much as possible...
>>>
>>> But I got in trouble trying to update this dict with
>>> update_cached_dictt_if_elapsed_time... First as cached_dict this variable
>>> is in globals, so I use to add more logic around the
>>> update_cached_dict_if_elapsed_time var like so :
>>>
>>>
>>> update_cached_dict_if_elapsed_time = None
>>> if update_cached_dict_if_elapsed_time == 0:
>>> pass
>>> elif request.args(0) == 'table_name' and request.function == 'create'
>>> and request.post_vars:
>>> update_cached_dict_if_elapsed_time = 0
>>>
>>> I find this cumbersome and prone to error because if I have other thing
>>> that should trigger a dict update, I have to add more logic...
>>>
>>> So, I though I could make factory dict function like so :
>>>
>>> def factory_cached_dict(update_cached_dict_if_elapsed_time=900):
>>> global
>>> cached_dict
>>>  cached_dict = cache.ram('cached_dict',
>>>   lambda: {r[0]: r[1] for r in
>>> db.executesql("""...""")},
>>>
>>> time_expire=update_cached_dict_if_elapsed_time)
>>>
>>> factory_cached_dict(900)
>>>
>>> Above is in models...
>>>
>>> Then I though I could just update my global cached_dict var from any
>>> controller like so :
>>>
>>> if form.process().accepts:
>>> factory_cached_dict(0)  # Because in this form I just add a value to
>>> the table use to create the python dict
>>>
>>> But I am really desapointed it not seems to work because I still
>>> experiment issue with not up to date cached_dict because there is missing
>>> key value pairs for id and it representation.
>>>
>>> I think the issue is that even if I call the factory after form submit
>>> the dict get recreated at each request by the factory call in models or
>>> there is something else going on that I don't understand (maybe issue with
>>> cache in web2py in web2py 2.4.7??)
>>>
>>> Thanks for any help.
>>>
>>> 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/groups/opt_out.
>>>
>>
>>
>

-- 
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/groups/opt_out.


Re: [web2py] A query too far? Inner join with group by...

2014-02-18 Thread Richard Vézina
So... You seem to be ready for a stored procedure... Or you need to thought
to your problem into more then one step, maybe having a view for the sub
query...

I was to porpose the multiple subquery, since your query is already slow, I
would try this option, just to see if it couldn't be a bit faster...

For slow query that for which I don't want to invest more time to create a
function or stored procedure, I generally create a view and cache it with
web2py...

Richard


On Mon, Feb 17, 2014 at 4:46 PM, Joe Barnhart wrote:

> Hi Richard --
>
> Don't need to try it...  Do a thought experiment...  The "belongs" matches
> the entire set of all affected times, event_codes and courses.  It becomes
> the cartesian product of all combinations of time, event_code, and course.
>  It matches N*M*K entries in the times table, where N, M, and K are the
> counts of the members of the set.  By contrast, the number of rows in the
> minimum times query is a tiny fraction of that.
>
> Let's say I have a competitor with a minimum time of 10 sec. in event 1,
> course A.  He may also have that exact time (on a bad day) for event 2,
> course B.  In this scenario, event 2 course B would normally be a much
> faster time -- in fact his "best" times has such a faster time.  But when
> you do the overall query with "belongs" on ALL members of times,
> event_code, and course, you will match BOTH 10 sec. times -- event 1 on
> course A and event 2 on course B, so both times will appear in the final
> result.  (Along with the true best time for event 2, course B, which was
> faster than 10 sec.)
>
> I could probably do a correlated subquery to solve this problem, but those
> are famously inefficient.  The join, convoluted as it is (and I agree
> there) is still the best way.
>
> What I really wish I could do is use a select to return the min(time) and
> the ID of the row it occurred on.  But GROUP BY won't allow that.  One of
> the limitations of the set theory underpinning SQL.  That's where the
> correlated subquery comes it -- do a select with ORDER BY on time, then
> choose LIMIT BY 0,1 to get only one row.  But that query has to be repeated
> for every combination of course and event_code.  I have about 20 rows to
> search for a typical competitor and each query above takes around 700 ms.
> so that's not a good option!
>
> -- Joe B.
>
> On Monday, February 17, 2014 12:51:07 PM UTC-8, Richard wrote:
>
>> But what you do in the join should be reproducible in a where clause... I
>> start rewriting your join into a where clause at first and realize that I
>> would need to rewrite 3-4 for time the same subquery in sql or I had to
>> write a recursive query that would not help in translation into web2py
>> query...
>>
>> I don't see how the multiples belongs would not lead to the samething as
>> you query did you try it?
>>
>> You still have the option of just using db.executesql(''' your actual sql
>> query ''')
>>
>> Richard
>>
>>
>> On Mon, Feb 17, 2014 at 3:24 PM, Joe Barnhart wrote:
>>
>>> Hi Richard --
>>>
>>> I thought about a subquery...  But I've never seen or heard of the trick
>>> of using "subquery[0]" to pick out one column of the subquery.
>>>
>>> I see your approach is to materialize the subquery as a Rows object and
>>> then pick out elements.  I don't think this will work as expected tho
>>> because the "belongs" logic will choose incorrect values.  For example say
>>> the time is 10 seconds, but there are 20 different rows (NOT "best" times)
>>> with the same time.  Your approach will choose the 10 sec. time for ALL
>>> combinations of event code and course -- not just the SPECIFIC combination
>>> in the row that matches the "best" time..
>>>
>>> That's why I chose a "join" -- it forces the elements to match
>>> perfectly.  But thanks for the technique.  The idea of materializing the
>>> Rows and using it in another query bears thinking about.
>>>
>>> -- Joe
>>>
>>>
>>> On Monday, February 17, 2014 7:32:57 AM UTC-8, Richard wrote:
>>>
 Hello Joe,

 Found your plain sql query already convoluted, there is not simpler way
 to express it in SQL first? You seem to use join as if it was a where, join
 not intent for this, using it like that will make thing slower...

 Could this work :

 subquery = db.executesql('''select course, event_code, min(finals) as "
 min_time" from times
 where id_competitor= and finals>0
 group by course, event_code''')

 rows = db((db.times.event_code.belongs(subquery[1])) & (db.times.
 course.belongs(subquery[0]) & (db.times.min_time.belongs(subquery[2]))
 & (db.times.competitor=='').select(db.times.ALL)

 I can't try

 :(

 Richard


 On Mon, Feb 17, 2014 at 6:38 AM, Joe Barnhart wrote:

> So I'm trying to use the DAL to create all of my queries, but I may
> have just exceeded its capability.
>
> My task is to create a view of "best times" for a particular sport.

[web2py] Re: Remember me with login_bare?

2014-02-18 Thread Anthony
If you need to turn on long expiration manually, you can include the 
following code:

session.auth.expiration = response.session_cookie_expires = auth.
settings.long_expiration
session.auth.remember = True

If your code does an immediate redirect after login, then you don't need to 
set response.session_cookie_expires (it will be set by Auth on the next 
request).

Anthony

On Tuesday, February 18, 2014 5:21:23 AM UTC-5, Robin Manoli wrote:
>
> Is there a way to use the functionality of remember me when using 
> login_bare? If so, how?
>

-- 
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/groups/opt_out.


[web2py] Re: Is it ok (i.e. safe !?) to extend the crud class

2014-02-18 Thread Leonel Câmara
I don't see why it wouldn't be safe it's like extending any class. However, 
if you're doing this you might as well just make your own search controller 
function elsewhere.

-- 
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/groups/opt_out.


[web2py] Is it ok (i.e. safe !?) to extend the crud class

2014-02-18 Thread Paul
Hi,

The html form created by crud.search is great, but for some fields I wanted 
the right hand 'text' input field to be a autocomplete style field so users 
can see all the distinct values for a field that they can then pick.

I've extended crud search in a class, this files is in in the applications 
modules folder,  i had to import from gluon.tools import Crud , from gluon 
import * to get past errors with current.request 

Before I spend more time working on this just wanted to check this is safe 
to do!

Thanks

Paul

-- 
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/groups/opt_out.


[web2py] SQLFORM.grid buttons as text

2014-02-18 Thread horridohobbyist
I've applied a layout that I downloaded from web2py.com. The layout turns 
the Edit and Delete buttons of SQLFORM.grid into textual links (anchors): 
 "Edit" and "Delete". However, the two text labels run together like so: 
"EditDelete". I'd like to put some space between them, ie "Edit   Delete".

I tried doing this in the CSS:

.buttontext {
padding: 5 px;
}

And it does give me the spacer. *But* this causes a scroll bar to appear to 
the right of the grid!

What's the right way to do what I'm trying to do?

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/groups/opt_out.


[web2py] Eliminating Submit Button

2014-02-18 Thread horridohobbyist
I have a SQLFORM.grid that allows the user to select a query from a 
selection of queries. The user selects the query using this form:

FORM(TABLE(TR(T("Choose Category:"),SELECT([my_list
],_name='category',value=current)),
   TR("",INPUT(_type='submit'

The grid is:

SQLFORM.grid(query,
orderby=db.products.category,
csv=False)

I would like the user to not have to click on a submit button. I just want 
to have some action that will modify the grid query as soon as the 
selection is made. What's the best way to do this? (I can think of a very, 
very messy way, but I'd like to avoid that.)

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/groups/opt_out.


[web2py] Cache related table

2014-02-18 Thread Robin Manoli
Hey,
in one of my projects, the users have usernames, and the usernames are not 
to ever change. I also write out auth_user.username, as well as 
auth_user.first_name, so I wonder if these can be cached, even if they are 
a related table.

1. Is there a way to cache all usernames and first names?
2. Can they also be cached if they are related to other tables such as 
*thing.owner 
= auth_user.id, {{=thing.owner.username}}*?

-- 
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/groups/opt_out.


[web2py] Remember me with login_bare?

2014-02-18 Thread Robin Manoli
Is there a way to use the functionality of remember me when using 
login_bare? If so, how?

-- 
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/groups/opt_out.


[web2py] Re: apache windows 2.8.2 sending email blocks the server?

2014-02-18 Thread Tim Richardson
Ah, gotcha! That stuff about GIL and I/O is not 100% true. SMTP is 
blocking. Scheduler is the answer.

On Tuesday, 18 February 2014 17:02:36 UTC+11, Tim Richardson wrote:
>
> I've noticed that apache 2.4 with mod_wsgi and python 2.7 does not respond 
> to other requests while a controller is doing mail.send
> mod_wsgi on windows is one process and threads, which means that python is 
> blocking on sending mail.
> Could this be correct? 
>

-- 
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/groups/opt_out.