[web2py] web3py?

2012-11-26 Thread User
I noticed a thread over in web2py-developers web3py - 
important!
 which 
was exciting to read.  I've flirted with web2py and there's a lot that I 
like about it.  For some reason I find web2py exciting whereas django 
doesn't provide that.  I've used Yii on the php side which is great 
framework as far as php goes and asp.net mvc which is great as well.  I'd 
love to work with python but the main thing making me hesitate with web2py 
is critical mass.  
 
It seems like it wouldn't be hard for web2py to really dominate the python 
web framework space if some of the core criticisms were addressed.  I'm not 
fully up to speed on what they are but I usually hear about unit testing 
and global variables.  It feels like there is a roadblock preventing the 
project from skyrocketing.  Python needs a rails.  I understand that the 
design decisions are by choice with pros and cons.
 
My questions are:
1. Will web3py likely address these often repeated core criticisms? (I saw 
point 5 from the thread linked to above: "5) No more global environment. 
Apps will do "from web3py import *" (see below)")
2. The developer thread is over in the developers section.  Will you have a 
more open forum for users (as opposed to developers) to have input on 
web3py?
 
 

-- 





[web2py] From Drupal to web2py: taxonomy/tagging and comments?

2011-09-12 Thread User
I have some sites that I implemented using Drupal. However as cool as
Drupal is I've never been satisfied with coding in it mostly because
it's in PHP and I've wanted to work with python. I've flirted with
Django but I just recently discovered web2py and it's definitely
caught my eye. Seems like it may be a sweet spot between Drupal and
Django. Although django-cms is also on my radar.

So now I'm wondering how to re-implement my sites with web2py. I've
started going through the web2py book but I'm trying to wrap my head
around some conceptual stuff.

Specifically suppose I have a site about DVD players. So in Drupal I'd
have a CCK (Content Creation Kit) type DVD player, with various
attributes. I guess this would correspond to a web2py model. How would
I implement something like Drupal's taxonomy which is like a tagging
system in web2py? Is there a module/plugin/appliance for that? Or am I
manually creating the model schema to handle tagging?

Secondly, how would you handle something like comments and/or reviews
on posts? Again, is there a pre-built plugin for this or do I have
roll my own?

Finally should I be looking at plugin wiki to handle some of this?


[web2py] How can I give google map javascript api marker title a suitably encoded string?

2013-09-24 Thread User
I'm using the google map javascript api (v3). I have a google map in one of 
my views.  I want to display the location name as the marker title (used 
when hovering over the marker).  I'm using the following code in my view:
 

function init_map() {
var myLatlng = new google.maps.LatLng({{=myobject.lat}}, {{=myobject
.lng}});
var mapOptions = {
center: myLatlng,
zoom: 12,
mapTypeId: google.maps.MapTypeId.ROADMAP
};
var map = new google.maps.Map(document.getElementById("map-canvas"),
mapOptions);
var marker = new google.maps.Marker({
position: myLatlng,
map: map,
title: "{{=myobject.name}}"
});
}
google.maps.event.addDomListener(window, 'load', init_map);


 
This works to output a map but when I mouse over the marker, the character 
encoding is not right.  For example, if  myobject.name contains the string 
"John's Place" then the marker tooltip will literally display "John's 
Place" (that is, with the ampersand and hash).  How can I get it to display 
the string as "John's Place" in a web safe manner?
 

 

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from 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] Model "before save" functionality?

2013-09-25 Thread User
I have a model with latitude and longitude fields.  The lat and lng should 
be computed from the address via Google geocoding.  Whenever the model is 
inserted or updated I want to update the lat and lng from the address of 
the model.
 
In Yii PHP framework there a number of events that you can customize 
surrounding models.  One of them is the beforeSave event (see 
http://www.yiiframework.com/doc/api/1.1/CActiveRecord#beforeSave-detail) 
 which is called every time before a model is saved to the database and 
which I could use to call a geocode function and stuff the resulting lat 
and lng into fields before saving to the database.  This works no matter 
where you are saving the model from. 
 
How can I get similar behavior in web2py?
 
Currently I have a controller where in the "create()" function I use 
onvalidation parameter of the form.process method to trigger the 
geocoding.  This works but then I would need to repeat this logic in an 
"update()" controller function.  And how would I get this to work when 
creating or updating records from the appadmin interface?

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from 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 can I give google map javascript api marker title a suitably encoded string?

2013-09-26 Thread User
Yes I by viewing source I could see that generated javascript string had 
the character entity in it, so I knew the question was how to get web2py to 
output it correctly.  Using XML works! thank you. By using XML the 
generated string becomes "John's Place"
 
My next question is why? And is it still safer from user injected code?  At 
first glance it looks like someone could possibly inject something 
(myobject.name ultimately comes from user input).  Maybe I can just strip 
out double quotes to make sure they can't close the string?

On Thursday, September 26, 2013 12:02:55 PM UTC-4, Christian Foster Howes 
wrote:

> can you use an inspector to see the actual generated javascript?  it's 
> possible that web2py is escaping the apostrophe.  you can try {{=XML(
> myobject.name)}}
>
> On Tuesday, September 24, 2013 5:26:29 PM UTC-7, User wrote:
>>
>> I'm using the google map javascript api (v3). I have a google map in one 
>> of my views.  I want to display the location name as the marker title (used 
>> when hovering over the marker).  I'm using the following code in my view:
>>  
>> {{block head}}
>> 
>> function init_map() {
>> var myLatlng = new google.maps.LatLng({{=myobject.lat}}, {{=
>> myobject.lng}});
>> var mapOptions = {
>> center: myLatlng,
>> zoom: 12,
>> mapTypeId: google.maps.MapTypeId.ROADMAP
>> };
>> var map = new google.maps.Map(document.getElementById(
>> "map-canvas"),
>> mapOptions);
>> var marker = new google.maps.Marker({
>> position: myLatlng,
>> map: map,
>> title: "{{=myobject.name}}"
>> });
>> }
>> google.maps.event.addDomListener(window, 'load', init_map);
>> 
>> {{end}}
>>
>>
>>  
>> This works to output a map but when I mouse over the marker, the 
>> character encoding is not right.  For example, if  myobject.namecontains the 
>> string "John's Place" then the marker tooltip will literally 
>> display "John's Place" (that is, with the ampersand and hash).  How 
>> can I get it to display the string as "John's Place" in a web safe manner?
>>  
>>
>>  
>>
>

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from 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 can I give google map javascript api marker title a suitably encoded string?

2013-09-26 Thread User
Looking online people seem to suggest json encoding.  So what I'm doing now 
is
 
def view():
import gluon.contrib.simplejson.encoder
myobject = db(db.objects.id == request.args(0)).select().first()
myobject.nameJson = gluon.contrib.simplejson.encoder.encode_basestring(
myobject.name)
return dict(myobject=myobject) 


(Not sure if that's the correction json method to use) And then in the view 
using XML as suggested by Christian.  This seems to properly escape 
embedded quotes.  However as I am new to web2py I would appreciate others 
input about the correctness of this.
 

On Thursday, September 26, 2013 5:14:40 PM UTC-4, User wrote:

> Yes I by viewing source I could see that generated javascript string had 
> the character entity in it, so I knew the question was how to get web2py to 
> output it correctly.  Using XML works! thank you. By using XML the 
> generated string becomes "John's Place"
>  
> My next question is why? And is it still safe from user injected code?  At 
> first glance it looks like someone could possibly inject something (
> myobject.name ultimately comes from user input).  Maybe I can just strip 
> out double quotes to make sure they can't close the string?
>
> On Thursday, September 26, 2013 12:02:55 PM UTC-4, Christian Foster Howes 
> wrote:
>
>> can you use an inspector to see the actual generated javascript?  it's 
>> possible that web2py is escaping the apostrophe.  you can try {{=XML(
>> myobject.name)}}
>>
>> On Tuesday, September 24, 2013 5:26:29 PM UTC-7, User wrote:
>>>
>>> I'm using the google map javascript api (v3). I have a google map in one 
>>> of my views.  I want to display the location name as the marker title (used 
>>> when hovering over the marker).  I'm using the following code in my view:
>>>  
>>> {{block head}}
>>> 
>>> function init_map() {
>>> var myLatlng = new google.maps.LatLng({{=myobject.lat}}, {{=
>>> myobject.lng}});
>>> var mapOptions = {
>>> center: myLatlng,
>>> zoom: 12,
>>> mapTypeId: google.maps.MapTypeId.ROADMAP
>>> };
>>> var map = new google.maps.Map(document.getElementById(
>>> "map-canvas"),
>>> mapOptions);
>>> var marker = new google.maps.Marker({
>>> position: myLatlng,
>>> map: map,
>>> title: "{{=myobject.name}}"
>>> });
>>> }
>>> google.maps.event.addDomListener(window, 'load', init_map);
>>> 
>>> {{end}}
>>>
>>>
>>>  
>>> This works to output a map but when I mouse over the marker, the 
>>> character encoding is not right.  For example, if  myobject.namecontains 
>>> the string "John's Place" then the marker tooltip will literally 
>>> display "John's Place" (that is, with the ampersand and hash).  How 
>>> can I get it to display the string as "John's Place" in a web safe manner?
>>>  
>>>
>>>  
>>>
>>

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from 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] Getting started with routes.py error: No module named fileutils ?

2013-09-27 Thread User
Using web2py  Version 2.6.4-stable+timestamp.2013.09.22.17.43.26 with 
Python 2.7.  I've got web2py up and running with a simple app.  Now I'm 
trying to get routes working.  What I did was copy 
routes.patterns.example.py from /examples to the  
folder and rename to routes.py.  Reloading routes from admin at this point 
works.  Then in my app I copied routes.example.py to routes.py.  I reloaded 
routes from admin and an error is generated with a ticket.  Note I did not 
edit either routes file at all yet.  The ticket says:
 
Error ticket for "admin" Ticket ID 

127.0.0.1.2013-09-27.22-20-40

 No module named fileutils
Version  web2py™ Version 2.6.4-stable+timestamp.2013.09.22.17.43.26  Python 
Python 
2.7: C:\www\web2py\web2py_no_console.exe (prefix: C:\www\web2py)  Traceback 

1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.

Traceback (most recent call last):
  File "/home/mdipierro/make_web2py/web2py/gluon/restricted.py", line 217, in 
restricted
  File *"C:/www/web2py/applications/admin/controllers/default.py"* 
, line 
1795, in 
  File "/home/mdipierro/make_web2py/web2py/gluon/globals.py", line 371, in 

  File *"C:/www/web2py/applications/admin/controllers/default.py"* 
, line 
1700, in reload_routes
  File "/home/mdipierro/make_web2py/web2py/gluon/rewrite.py", line 381, in load
  File "/home/mdipierro/make_web2py/web2py/gluon/rewrite.py", line 321, in load
  File "", line 21, in 
  File "/home/mdipierro/make_web2py/web2py/gluon/custom_import.py", line 86, in 
custom_importer
ImportError: No module named fileutils

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from 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: Getting started with routes.py error: No module named fileutils ?

2013-09-30 Thread User
Am I doing something wrong in setting up routes? 

On Saturday, September 28, 2013 12:29:33 AM UTC-4, User wrote:

> Using web2py  Version 2.6.4-stable+timestamp.2013.09.22.17.43.26 with 
> Python 2.7.  I've got web2py up and running with a simple app.  Now I'm 
> trying to get routes working.  What I did was copy 
> routes.patterns.example.py from /examples to the  
> folder and rename to routes.py.  Reloading routes from admin at this point 
> works.  Then in my app I copied routes.example.py to routes.py.  I 
> reloaded routes from admin and an error is generated with a ticket.  Note I 
> did not edit either routes file at all yet.  The ticket says:
>  
> Error ticket for "admin" Ticket ID 
>
> 127.0.0.1.2013-09-27.22-20-40
>
>  No module named fileutils
> Version  web2py™ Version 2.6.4-stable+timestamp.2013.09.22.17.43.26  
> Python Python 2.7: C:\www\web2py\web2py_no_console.exe (prefix: 
> C:\www\web2py)  Traceback 
>
> 1.
> 2.
> 3.
> 4.
> 5.
> 6.
> 7.
> 8.
> 9.
> 10.
> 11.
>
> Traceback (most recent call last):
>   File "/home/mdipierro/make_web2py/web2py/gluon/restricted.py", line 217, in 
> restricted
>   File *"C:/www/web2py/applications/admin/controllers/default.py"* 
> <http://127.0.0.1:8000/admin/default/edit/admin/controllers/default.py>, line 
> 1795, in 
>   File "/home/mdipierro/make_web2py/web2py/gluon/globals.py", line 371, in 
> 
>   File *"C:/www/web2py/applications/admin/controllers/default.py"* 
> <http://127.0.0.1:8000/admin/default/edit/admin/controllers/default.py>, line 
> 1700, in reload_routes
>   File "/home/mdipierro/make_web2py/web2py/gluon/rewrite.py", line 381, in 
> load
>   File "/home/mdipierro/make_web2py/web2py/gluon/rewrite.py", line 321, in 
> load
>   File "", line 21, in 
>   File "/home/mdipierro/make_web2py/web2py/gluon/custom_import.py", line 86, 
> in custom_importer
> ImportError: No module named fileutils
>
>

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from 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: Komodo IDE web2py Setup

2013-09-30 Thread User
Will this work with Komodo Edit 8.5?  How would I install it?

On Thursday, October 22, 2009 7:14:16 PM UTC-4, Richard Penman wrote:

> I have uploaded my web2py extension file to that thread (http:// 
> community.activestate.com/files/codeintel_web2py.py_.txt). 
> Let me know if you have problems getting it working - so far I have 
> only tested it on my own Linux box. 
>
> Richard 
>
>
> On Oct 22, 5:11 pm, Richard  wrote: 
> > hey Ranjeev, 
> > 
> > I got web2py autocompletion working! Just waiting for feedback from 
> > Todd and a place to put it. 
> > 
> > There is a Google Code project for Django integration withKomodo:
> http://code.google.com/p/django-komodo-kit/ 
> > Maybe it's worth starting one for web2py too... 
> > 
> > Richard 
> > 
> > On Oct 21, 7:04 pm, rondevu  wrote: 
> > 
> > > Please share if anyone manages to write the code intel *.cix file. 
> > 
> > > Thanks. 
> > 
> > > Ranjeev 
> > 
> > > On Oct 21, 6:49 am, Richard  wrote: 
> > 
> > > >Komodois my main editor for web2py, so thanks for the tip. 
> > > > I don't like putting that in all my files though... 
> > > > Have asked how to do this properly on their forum:
> http://community.activestate.com/forum/implicit-python-code-completion 
> > 
> > > > Richard 
> > 
> > > > On Oct 21, 3:57 am, rondevu  wrote: 
> > 
> > > > > Well the only way I got code completion to work is using this 
> guide 
> > > > > herehttp://
> kollerie.wordpress.com/2009/04/07/setting-up-your-ide-for-web2... 
> > > > > by inserting the imports in the files your working on 
> > 
> > > > > and 
> > 
> > > > > underKomodoproject properties (Windows) 
> > > > > Script C:\\web2py\web2py.py 
> > > > > Script Arg -a r 
> > > > > Directory C;\ 
> > 
> > > > > Works just like WingIDE. So I may just stick with WingIDE for now. 
> > 
> > > > > On Oct 20, 10:30 pm, Yarko Tymciurak  
>
> > > > > wrote: 
> > 
> > > > > > >Komodois multi-scripting language, so if you have a project 
> that needs Tk, 
> > > > > > > Perl, and / or Python it's a good bet (my first really big 
> Perl project I 
> > > > > > > gotKomodojust so I could figure out what the language was 
> doing, and it 
> > > > > > > was great). 
> > 
> > > > > > > I have not tried a web project with it, nor anything big in 
> Python ... I 
> > > > > > > preferred Wing... but you should be able to get some hints 
> fromKomodoteam 
> > > > > > > on how to have a server run inKomodo(e.g. cherrypy); that much 
> would give 
> > > > > > > you a big step forward. 
> > 
> > > > > > > On Tue, Oct 20, 2009 at 6:55 AM, rondevu  
> wrote: 
> > 
> > > > > > >> Well I have tried WingIDE. And wanted to see the difference 
> of the two 
> > > > > > >> IDEs. 
> > 
> > > > > > >> On Oct 20, 6:56 pm, Alex Fanjul  
> wrote: 
> > > > > > >> > > Im new. How do you configurekomodoto work with web2py? 
> > 
> > > > > > >> > If you can use Wing + web2py its so easyhttp:// 
> > > > > > >>www.wingware.com/doc/howtos/web2pyanditworksverygood. 
> > > > > > >> > -- 
> > > > > > >> > Alejandro Fanjul Fdez. 
> > > > > > >> > alex.fan...@gmail.comwww.mhproject.org 
> > 
> >

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


[web2py] Does an inherited table also inherit _before_insert?

2013-10-01 Thread User
Using table inheritance to define a common set of fields. Given the 
following code:
 
standard_fields = db.Table(db, 'standard_fields',
Field('created_on', 'datetime'),
 )
standard_field._before_insert.append(lambda fields: fields['created'] =request
.now)
 
db.define_table('payment', Field('amount', 'double'), standard_fields)

will table payment inherit the _before_insert behavior?  I'm trying this 
but I think it may not inherit.  If it doesn't, is the only option to 
specify the ._before_insert for each table? I want to add this to a number 
of tables.
 

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from 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: Table inheritance: _before_insert?

2013-10-05 Thread User
When using default field value, if I add a record through appadmin, the 
default is populated in the form and therefore the actual database 
insertion time is not recorded but rather the form generation time.  Is 
there a way around this?
 

On Wednesday, October 2, 2013 8:57:35 AM UTC-4, Anthony wrote:

> No, passing a table object into db.define_table() only copies the tables 
> fields, not its other attributes. Anyway, if you want to set the default 
> value for a field, you would do it using the "default" argument to Field():
>
> standard_fields = db.Table(db, 'standard_fields',
> Field('created_on', 'datetime', default=request.now))
>
> You might also want to set writable=False.
>
> Anthony
>
> On Tuesday, October 1, 2013 11:26:08 PM UTC-4, User wrote:
>>
>> Using table inheritance to define a common set of fields. Given the 
>> following code:
>>  
>> standard_fields = db.Table(db, 'standard_fields',
>> Field('created_on', 'datetime'),
>>  )
>> standard_field._before_insert.append(lambda fields: fields['created_on'] 
>> = request.now)
>>  
>> db.define_table('payment', Field('amount', 'double'), standard_fields)
>>
>> will table payment inherit the _before_insert (or _before_update) 
>> behavior?  I'm trying this but I think it may not inherit.  If it doesn't, 
>> is the only option to specify the ._before_insert for each table? I want 
>> to add this to a number of tables.
>>  
>>
>

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from 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: Table inheritance: _before_insert?

2013-10-05 Thread User
I do have writable=False and I understand that will work for normal 
forms, but it still shows up in appadmin

On Saturday, October 5, 2013 6:28:08 PM UTC-4, Anthony wrote:

> If you don't want the user to see or be able to edit the created_on value, 
> just set readable=writable=False for that field. When an insert is done, 
> the default value set at the time of the insert request will be used.
>
> Anthony
>
> On Saturday, October 5, 2013 5:36:32 PM UTC-4, User wrote:
>>
>> When using default field value, if I add a record through appadmin, the 
>> default is populated in the form and therefore the actual database 
>> insertion time is not recorded but rather the form generation time.  Is 
>> there a way around this?
>>  
>>
>> On Wednesday, October 2, 2013 8:57:35 AM UTC-4, Anthony wrote:
>>
>>> No, passing a table object into db.define_table() only copies the tables 
>>> fields, not its other attributes. Anyway, if you want to set the default 
>>> value for a field, you would do it using the "default" argument to Field():
>>>
>>> standard_fields = db.Table(db, 'standard_fields',
>>> Field('created_on', 'datetime', default=request.now))
>>>
>>> You might also want to set writable=False.
>>>
>>> Anthony
>>>
>>> On Tuesday, October 1, 2013 11:26:08 PM UTC-4, User wrote:
>>>>
>>>> Using table inheritance to define a common set of fields. Given the 
>>>> following code:
>>>>  
>>>> standard_fields = db.Table(db, 'standard_fields',
>>>> Field('created_on', 'datetime'),
>>>>  )
>>>> standard_field._before_insert.append(lambda fields: fields['created_on'
>>>> ] = request.now)
>>>>  
>>>> db.define_table('payment', Field('amount', 'double'), standard_fields)
>>>>
>>>> will table payment inherit the _before_insert (or _before_update) 
>>>> behavior?  I'm trying this but I think it may not inherit.  If it doesn't, 
>>>> is the only option to specify the ._before_insert for each table? I 
>>>> want to add this to a number of tables.
>>>>  
>>>>
>>>

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from 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: web2py!!!

2013-10-12 Thread User
Woah if you're on Windows and can't use python I wouldn't choose PHP as my 
first choice.  Try C#/ASP.NET with either webforms or mvc (
http://www.asp.net/mvc).  You can use free Visual Studio express IDE.  Very 
easy/powerful development IMO and a large community with plenty of examples.
 
If you're really stuck on PHP then I'd say look at Yii possibly with 
Netbeans IDE.  But IMO C#/asp.net mvc is better experience than php if you 
have the choice.

On Saturday, October 12, 2013 2:14:53 PM UTC-4, chicks wrote:

> I've been using web2py for a couple of years now for an intranet site for 
> our small department of about 20.  Absolutely love its intuitive design, 
> the built-in IDE, the ease of database interaction, basically everything 
> about it.  Massimo, you are brilliant!
>
> Now, I've been tasked with building an intranet site for our entire 
> division, a BI dashboard / portal for our Director to keep tabs on all his 
> departments' performance, and to do his blogging, reporting, etc.  
> Naturally, web2py would be my choice, but it has to be hosted on corporate 
> web servers.  Windows, SQL Server, and zero support for Python. :(
>
> I have no experience at all with M$ development, other than some VB6 years 
> ago, so that's out.  I've done PHP in the past, which is fully supported on 
> these hosts, so have been looking at some of the PHP frameworks.  CakePHP 
> and Yii so far.  All I can say is they just aren't as intuitive (to me 
> anyway) as web2py.  Where is the IDE?  I guess I'll have to install PHP and 
> a web server on my desktop and try to develop there, using some sort of 
> PHP-specific editor?  Unfortunately, corporate IT will immediately detect a 
> web server on my desktop, and send me a nasty email to remove it 
> immediately!  
>
> Is there any PHP framework with the sort of built-in IDE that makes web2py 
> such a productive environment?  TIA.
>

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from 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] Code completion: Do I need to install to install web2py from source?

2013-10-18 Thread User
I want to get code completion working in my editor (currently using Komodo 
Edit).  I have seen that at the top of my files I need to put something 
like:
 
if 0:
   from gluon.sql import *
   from gluon.sqlhtml import *
   from gluon.html import *
   db = DAL()
   #optionally use table references instead of db reference
   mytable = Table()

 
I try this but I still don't get completion.  In Komodo preferences I can 
also specify additional python import directories for Komodo to look for 
in.  Do I need to add something there? Tried adding the root web2py folder 
but this doesn't seem to make a difference.  Do I need to use the source 
download of web2py (web2py_src.zip) to get code completion or does it also 
work with web2py_win.zip?
 
Other than putting the above code snippet in my controller, what other step 
might I be missing?
 
 
 

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from 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: Code completion: Do I need to install to install web2py from source?

2013-10-20 Thread User
I see web2py seems to have both mercurial and git repositories.  I'm more 
familiar with hg but I can get more familiar with git if need be.  Is one 
preferred over the other?  Any pros/cons with respect to web2py?  Which is 
path of least resistance?
 

On Saturday, October 19, 2013 3:13:29 PM UTC-4, Tim Richardson wrote:

>
>
> personally, I encourage you to learn about git and using git to download 
> the source. github will tell you how. Even as a newbie it proves itself to 
> be very advantageous (like instant access to any version)
>

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from 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] Mercurial creating new apps?

2013-10-21 Thread User
I have cloned the web2py mercurial repository and hg updated to R-2.7.4.  
I'm using TortoiseHg on windows.  Now when I want to create a new 
application based on the welcome app how should I go about doing this? what 
is the normal workflow for this?  I'm guessing the idea is that I would 
create a new repository for each of my apps.
 
Can I still use the admin to create apps? Do I just manually copy the 
welcome app and then hg init inside of it?
 

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


[web2py] Re: Mercurial creating new apps?

2013-10-21 Thread User
When I click the "Versioning" link I get "Sorry, could not find mercurial 
installed" although I have TortoiseHg installed.  Does this work for you?

On Monday, October 21, 2013 5:56:28 PM UTC-4, Dave S wrote:

> On Monday, October 21, 2013 12:15:05 PM UTC-7, User wrote:
>>
>> I have cloned the web2py mercurial repository and hg updated to R-2.7.4.  
>> I'm using TortoiseHg on windows.  Now when I want to create a new 
>> application based on the welcome app how should I go about doing this? what 
>> is the normal workflow for this?  I'm guessing the idea is that I would 
>> create a new repository for each of my apps.
>>  
>> Can I still use the admin to create apps? Do I just manually copy the 
>> welcome app and then hg init inside of it?
>>  
>>
>
> I believe you can do that, but the main admin app (reached via the "site" 
> button on the Navbar, for instance) has a button for doing the copying for 
> you.  This workflow is discussed in the Overview chapter of the book:
> <http://www.web2py.com/books/default/chapter/29/03/overview#Say-hello>
>
> Also, Web2py should detect your THG installation, and use the mercurial 
> for it.  When you're in the admin view for your app, a "Versioning" button 
> will show on the Navbar.  The page that takes you to is a simple wrapper 
> for Mercurial; it will create a repository and allow you to commit, and 
> show the commit history. If you only are doing linear development (in the 
> Hg/THG sense of linear), then you don't need anything else, but you can 
> point your THG browser to those repositories or use command line stuff if 
> you need more power-user support.
>
> I'm still fairly new to Web2py, but the book and this forum have made me 
> successful in setting up a simple service and some pages to display results 
> and summaries.  It's worth working through the first couple of examples, 
> and when you're comfortable with those launching into your project. 
>  (Mercurial isn't part of the tutorial sessions, though, but you can use it 
> with them.)
>
>
> /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.


[web2py] Re: Table inheritance: _before_insert?

2013-10-23 Thread User
The discrepancy between form generation time and database insertion time is 
mostly an annoyance when creating new records in appadmin.  
 
However, doing it this way I notice the modified time field will not get 
updated in appadmin because it will already have a value from when the 
record was originally inserted.  (I've decided on insertion that the 
modified time will equal the creation time. I realize an alternative option 
is to keep the modified field null until the record is actually modified, 
but I prefer my way) Thus, even though I have the following in my models.py
 
standard_fields.modified_on.update = request.now
 
it will not make a difference in appadmin so it seems like using compute 
may be the best option
 

On Saturday, October 5, 2013 9:06:53 PM UTC-4, Anthony wrote:

> On Saturday, October 5, 2013 8:04:54 PM UTC-4, User wrote:
>
>> I do have writable=False and I understand that will work for normal 
>> forms, but it still shows up in appadmin
>>
>
> Yes, appadmin ignores the writable attribute. Is it really important to 
> distinguish between the time the form is loaded and the time of the insert? 
> If so, something like this might work (not tested):
>
> standard_fields = db.Table(db, 'standard_fields',
> Field('created_on', 'datetime', default=request.now))
> if request.controller == 'appadmin':
> standard_fields.created_on.compute = lambda row: request.now
>
> I believe appadmin will not show a computed field, so the above should 
> compute the value at time of insert.
>
> Anthony
>

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


[web2py] Re: Table inheritance: _before_insert?

2013-10-23 Thread User
Actually unless I'm missing something I don't think using a computed field 
will work for the create_on field because this seems to modify the field 
any time you update the record.  However it does work for the modified_on 
field.  
 

On Thursday, October 24, 2013 2:30:44 AM UTC-4, User wrote:

> The discrepancy between form generation time and database insertion time 
> is mostly an annoyance when creating new records in appadmin.  
>  
> However, doing it this way I notice the modified time field will not get 
> updated in appadmin because it will already have a value from when the 
> record was originally inserted.  (I've decided on insertion that the 
> modified time will equal the creation time. I realize an alternative option 
> is to keep the modified field null until the record is actually modified, 
> but I prefer my way) Thus, even though I have the following in my models.py
>  
> standard_fields.modified_on.update = request.now
>  
> it will not make a difference in appadmin so it seems like using compute 
> may be the best option
>  
>
> On Saturday, October 5, 2013 9:06:53 PM UTC-4, Anthony wrote:
>
>> On Saturday, October 5, 2013 8:04:54 PM UTC-4, User wrote:
>>
>>> I do have writable=False and I understand that will work for normal 
>>> forms, but it still shows up in appadmin
>>>
>>
>> Yes, appadmin ignores the writable attribute. Is it really important to 
>> distinguish between the time the form is loaded and the time of the insert? 
>> If so, something like this might work (not tested):
>>
>> standard_fields = db.Table(db, 'standard_fields',
>> Field('created_on', 'datetime', default=request.now))
>> if request.controller == 'appadmin':
>> standard_fields.created_on.compute = lambda row: request.now
>>
>> I believe appadmin will not show a computed field, so the above should 
>> compute the value at time of insert.
>>
>> Anthony
>>
>

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


[web2py] Database insert of time field in web2py not working?

2013-11-12 Thread User


I have some code that was working before but I can't quite pinpoint why 
it's not working now.  In any case it's a time field in a table and when I 
insert into this field the database shows '00:00:00' in the field (by 
looking at the record in an SQLite admin tool)

Field('start_time','time', default='2:00PM'),

I have a form where this value is inserted along with other form values.  
The insert statement looks like:

 form.vars.id = db.sometable.insert(**db.sometable._filter_fields(form.vars
))

 
I have inspected form.vars in the debugger immediately before this 
statement is executed and I can see form.vars.start_time has a string value 
such as '3:00PM'.  The insert statement executes with no error and the 
record is inserted in the database but the time field shows as 
00:00:00. This further causes an error when trying to view the database 
record from web2py:
 
ValueError: invalid literal for int() with base 10: '00PM'
 
 
Any idea why the time is not inserting properly and how to fix it? Is the 
time string in the wrong format?

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from 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: Database insert of time field in web2py not working?

2013-11-12 Thread User
Just realized I added the following lines after my db.define_table 
statement:
 
db.sometable.start_time.notnull = True
db.sometable.start_time.requires = IS_NOT_EMPTY()

 
I'm thinking that my assignment of IS_NOT_EMPTY() overwrote the default 
IS_TIME() validator associated with time fields.  Does this sound like what 
the problem is?  If so, how do I get around it?

On Tuesday, November 12, 2013 3:24:36 AM UTC-5, User wrote:

> I have some code that was working before but I can't quite pinpoint why 
> it's not working now.  In any case it's a time field in a table and when I 
> insert into this field the database shows '00:00:00' in the field (by 
> looking at the record in an SQLite admin tool)
>
> Field('start_time','time', default='2:00PM'),
>
> I have a form where this value is inserted along with other form values.  
> The insert statement looks like:
>
>  form.vars.id = db.sometable.insert(**db.sometable._filter_fields(form.
> vars))
>
>  
> I have inspected form.vars in the debugger immediately before this 
> statement is executed and I can see form.vars.start_time has a string value 
> such as '3:00PM'.  The insert statement executes with no error and the 
> record is inserted in the database but the time field shows as 
> 00:00:00. This further causes an error when trying to view the database 
> record from web2py:
>  
> ValueError: invalid literal for int() with base 10: '00PM'
>  
>  
> Any idea why the time is not inserting properly and how to fix it? Is the 
> time string in the wrong format?
>
>

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from 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: Database insert of time field in web2py not working?

2013-11-12 Thread User
So since a time field automatically has an IS_TIME validator how would you 
specify additional validators after the db.define_table statement?

On Tuesday, November 12, 2013 3:51:12 AM UTC-5, Niphlod wrote:
>
> requires can be a list of validators.
>
> On Tuesday, November 12, 2013 9:32:27 AM UTC+1, User wrote:
>>
>> Just realized I added the following lines after my db.define_table 
>> statement:
>>  
>> db.sometable.start_time.notnull = True
>> db.sometable.start_time.requires = IS_NOT_EMPTY()
>>
>>  
>> I'm thinking that my assignment of IS_NOT_EMPTY() overwrote the default 
>> IS_TIME() validator associated with time fields.  Does this sound like what 
>> the problem is?  If so, how do I get around it?
>>
>> On Tuesday, November 12, 2013 3:24:36 AM UTC-5, User wrote:
>>
>>> I have some code that was working before but I can't quite pinpoint why 
>>> it's not working now.  In any case it's a time field in a table and when I 
>>> insert into this field the database shows '00:00:00' in the field (by 
>>> looking at the record in an SQLite admin tool)
>>>
>>> Field('start_time','time', default='2:00PM'),
>>>
>>> I have a form where this value is inserted along with other form 
>>> values.  The insert statement looks like:
>>>
>>>  form.vars.id = db.sometable.insert(**db.sometable._filter_fields(form.
>>> vars))
>>>
>>>  
>>> I have inspected form.vars in the debugger immediately before this 
>>> statement is executed and I can see form.vars.start_time has a string value 
>>> such as '3:00PM'.  The insert statement executes with no error and the 
>>> record is inserted in the database but the time field shows as 
>>> 00:00:00. This further causes an error when trying to view the database 
>>> record from web2py:
>>>  
>>> ValueError: invalid literal for int() with base 10: '00PM'
>>>  
>>>  
>>> Any idea why the time is not inserting properly and how to fix it? Is 
>>> the time string in the wrong format?
>>>
>>>

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from 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] Different code at web2py.com/examples/static/epydoc vs code.google.com/p/web2py/source/browse?

2013-11-14 Thread User
Why is the source code for the navbar function
http://web2py.com/examples/static/epydoc/web2py.gluon.tools-pysrc.html#Auth.navbar
different than the code for 
http://code.google.com/p/web2py/source/browse/gluon/tools.py#1318

For example, the latter has nested functions such as Anr(), menu(), and 
bootstrap() while the former doesn't seem to have these.

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from 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: call function with parameter from views

2013-11-14 Thread User
1. On the line:

{{=SPAN(A(T('Process 3'), _href=URL('revert(ids)' ) ) ) }}

You have the function call inside a string so it will just be treated as a 
string.  If you wanted to call it as a function you would probably need to 
do like this:

{{=SPAN(A(T('Process 3'), _href=URL(revert(ids) ) ) ) }}


2. To me, calling the function here doesn't make sense since it doesn't 
return a value but instead redirects

On Thursday, November 14, 2013 9:03:34 PM UTC-5, 黄祥 wrote:

> hi,
>
> i have a function that must be passed with parameter, if i test to call it 
> from controllers it works well. 
> e.g. in controller
> def outstanding_rent():
> query = db.rent_detail.status == 'Rent'
> grid = SQLFORM.grid(query, selectable = lambda ids: revert(ids) )
> return locals()
>
> def revert(ids):
> for id in ids:
> detail = db(db.rent_detail.id == id).select().first()
> db.revert_detail.insert(rent_no = detail.rent_no, 
> due_date = detail.due_date, 
> customer = detail.customer, 
> dvd = detail.dvd, 
> quantity = detail.quantity)
> redirect(URL('report', 'report_revert') )
>
> when i try to move it to views it not work. 
> e.g.
> *controllers/default.py*
> def outstanding_rent():
> query = db.rent_detail.status == 'Rent'
> #grid = SQLFORM.grid(query, selectable = lambda ids: revert(ids) )
> grid = SQLFORM.grid(query, selectable = lambda ids : 
> redirect(URL('revert_checkout', vars = dict(ids = ids) ) ) )
> return locals()
>
> def revert_checkout():
> ids = request.vars.ids
> return dict(ids = ids)
>
>
> def revert(ids):
> for id in ids:
> detail = db(db.rent_detail.id == id).select().first()
> db.revert_detail.insert(rent_no = detail.rent_no, 
> due_date = detail.due_date, 
> customer = detail.customer, 
> dvd = detail.dvd, 
> quantity = detail.quantity)
> redirect(URL('report', 'report_revert') )
>
> *views/default/revert_checkout.html*
> 
> 
> {{=T('DVD')}}
> {{=T('Quantity')}}
> 
> {{for id in ids:}}
> {{detail = db(db.rent_detail.id == id).select().first()}}
> 
> {{=SPAN(detail.dvd.title)}}
> {{=SPAN(detail.quantity)}}
> 
> {{pass}}
> 
>
> #test with args
> {{=SPAN(A(T('Process 1'), _href=URL('revert', args = ids) ) ) }}
> #test with vars
> {{=SPAN(A(T('Process 2'), _href=URL('revert', vars = dict(ids = ids) ) ) ) 
> }}
> #test call like on controler
> {{=SPAN(A(T('Process 3'), _href=URL('revert(ids)' ) ) ) }}
>
> is it possible to call function with parameter from views?
>
> thanks and best regards,
> stifan
>

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


[web2py] Re: call function with parameter from views

2013-11-14 Thread User
I think by default, functions with arguments are not exposed.  From: 
http://stackoverflow.com/questions/3003449/web2py-controllers-with-parameters

"web2py specifically detects valid controller functions as those functions 
that have no arguments"

On Thursday, November 14, 2013 9:03:34 PM UTC-5, 黄祥 wrote:

> hi,
>
> i have a function that must be passed with parameter, if i test to call it 
> from controllers it works well. 
> e.g. in controller
> def outstanding_rent():
> query = db.rent_detail.status == 'Rent'
> grid = SQLFORM.grid(query, selectable = lambda ids: revert(ids) )
> return locals()
>
> def revert(ids):
> for id in ids:
> detail = db(db.rent_detail.id == id).select().first()
> db.revert_detail.insert(rent_no = detail.rent_no, 
> due_date = detail.due_date, 
> customer = detail.customer, 
> dvd = detail.dvd, 
> quantity = detail.quantity)
> redirect(URL('report', 'report_revert') )
>
> when i try to move it to views it not work. 
> e.g.
> *controllers/default.py*
> def outstanding_rent():
> query = db.rent_detail.status == 'Rent'
> #grid = SQLFORM.grid(query, selectable = lambda ids: revert(ids) )
> grid = SQLFORM.grid(query, selectable = lambda ids : 
> redirect(URL('revert_checkout', vars = dict(ids = ids) ) ) )
> return locals()
>
> def revert_checkout():
> ids = request.vars.ids
> return dict(ids = ids)
>
>
> def revert(ids):
> for id in ids:
> detail = db(db.rent_detail.id == id).select().first()
> db.revert_detail.insert(rent_no = detail.rent_no, 
> due_date = detail.due_date, 
> customer = detail.customer, 
> dvd = detail.dvd, 
> quantity = detail.quantity)
> redirect(URL('report', 'report_revert') )
>
> *views/default/revert_checkout.html*
> 
> 
> {{=T('DVD')}}
> {{=T('Quantity')}}
> 
> {{for id in ids:}}
> {{detail = db(db.rent_detail.id == id).select().first()}}
> 
> {{=SPAN(detail.dvd.title)}}
> {{=SPAN(detail.quantity)}}
> 
> {{pass}}
> 
>
> #test with args
> {{=SPAN(A(T('Process 1'), _href=URL('revert', args = ids) ) ) }}
> #test with vars
> {{=SPAN(A(T('Process 2'), _href=URL('revert', vars = dict(ids = ids) ) ) ) 
> }}
> #test call like on controler
> {{=SPAN(A(T('Process 3'), _href=URL('revert(ids)' ) ) ) }}
>
> is it possible to call function with parameter from views?
>
> thanks and best regards,
> stifan
>

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


[web2py] Re: call function with parameter from views

2013-11-15 Thread User
I think by default, functions with arguments are not exposed.  From: 
http://stackoverflow.com/questions/3003449/web2py-controllers-with-parameters

"web2py specifically detects valid controller functions as those functions 
that have no arguments"


On Thursday, November 14, 2013 9:03:34 PM UTC-5, 黄祥 wrote:

> hi,
>
> i have a function that must be passed with parameter, if i test to call it 
> from controllers it works well. 
> e.g. in controller
> def outstanding_rent():
> query = db.rent_detail.status == 'Rent'
> grid = SQLFORM.grid(query, selectable = lambda ids: revert(ids) )
> return locals()
>
> def revert(ids):
> for id in ids:
> detail = db(db.rent_detail.id == id).select().first()
> db.revert_detail.insert(rent_no = detail.rent_no, 
> due_date = detail.due_date, 
> customer = detail.customer, 
> dvd = detail.dvd, 
> quantity = detail.quantity)
> redirect(URL('report', 'report_revert') )
>
> when i try to move it to views it not work. 
> e.g.
> *controllers/default.py*
> def outstanding_rent():
> query = db.rent_detail.status == 'Rent'
> #grid = SQLFORM.grid(query, selectable = lambda ids: revert(ids) )
> grid = SQLFORM.grid(query, selectable = lambda ids : 
> redirect(URL('revert_checkout', vars = dict(ids = ids) ) ) )
> return locals()
>
> def revert_checkout():
> ids = request.vars.ids
> return dict(ids = ids)
>
>
> def revert(ids):
> for id in ids:
> detail = db(db.rent_detail.id == id).select().first()
> db.revert_detail.insert(rent_no = detail.rent_no, 
> due_date = detail.due_date, 
> customer = detail.customer, 
> dvd = detail.dvd, 
> quantity = detail.quantity)
> redirect(URL('report', 'report_revert') )
>
> *views/default/revert_checkout.html*
> 
> 
> {{=T('DVD')}}
> {{=T('Quantity')}}
> 
> {{for id in ids:}}
> {{detail = db(db.rent_detail.id == id).select().first()}}
> 
> {{=SPAN(detail.dvd.title)}}
> {{=SPAN(detail.quantity)}}
> 
> {{pass}}
> 
>
> #test with args
> {{=SPAN(A(T('Process 1'), _href=URL('revert', args = ids) ) ) }}
> #test with vars
> {{=SPAN(A(T('Process 2'), _href=URL('revert', vars = dict(ids = ids) ) ) ) 
> }}
> #test call like on controler
> {{=SPAN(A(T('Process 3'), _href=URL('revert(ids)' ) ) ) }}
>
> is it possible to call function with parameter from views?
>
> thanks and best regards,
> stifan
>

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


[web2py] Does web2py have an ajax username availablity validator?

2013-11-15 Thread User
On my user registration form I'd like to add an ajax username availability 
control similar to how twitter does.  After each character you type on 
twitter registration you get either "Username is available." or "This 
username is already taken!"  Does web2py have something like this already?

I know the username has IS_NOT_IN_DB but this is only triggered on form 
submit.

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from 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: Database insert of time field in web2py not working?

2013-11-15 Thread User
Does this need the original validator to have been defined as a list to 
work?

Is there a difference between

db.table.field.requires = first_validator

and

db.table.field.requires = [first_validator]

Does your append code work in either case?  If there is a difference, when 
you declare a field with "time" type is the IS_TIME validator added as a 
single validator or as a list with length 1?



On Wednesday, November 13, 2013 11:48:57 AM UTC-5, Niphlod wrote:

> db.table.field.requires.append(what_you_need)
>
> On Wednesday, November 13, 2013 6:43:38 AM UTC+1, User wrote:
>>
>> So since a time field automatically has an IS_TIME validator how would 
>> you specify additional validators after the db.define_table statement?
>>
>> On Tuesday, November 12, 2013 3:51:12 AM UTC-5, Niphlod wrote:
>>>
>>> requires can be a list of validators.
>>>
>>> On Tuesday, November 12, 2013 9:32:27 AM UTC+1, User wrote:
>>>>
>>>> Just realized I added the following lines after my db.define_table 
>>>> statement:
>>>>  
>>>> db.sometable.start_time.notnull = True
>>>> db.sometable.start_time.requires = IS_NOT_EMPTY()
>>>>
>>>>  
>>>> I'm thinking that my assignment of IS_NOT_EMPTY() overwrote the default 
>>>> IS_TIME() validator associated with time fields.  Does this sound like 
>>>> what 
>>>> the problem is?  If so, how do I get around it?
>>>>
>>>> On Tuesday, November 12, 2013 3:24:36 AM UTC-5, User wrote:
>>>>
>>>>> I have some code that was working before but I can't quite pinpoint 
>>>>> why it's not working now.  In any case it's a time field in a table and 
>>>>> when I insert into this field the database shows '00:00:00' in the field 
>>>>> (by looking at the record in an SQLite admin tool)
>>>>>
>>>>> Field('start_time','time', default='2:00PM'),
>>>>>
>>>>> I have a form where this value is inserted along with other form 
>>>>> values.  The insert statement looks like:
>>>>>
>>>>>  form.vars.id = db.sometable.insert(**db.sometable._filter_fields(form
>>>>> .vars))
>>>>>
>>>>>  
>>>>> I have inspected form.vars in the debugger immediately before this 
>>>>> statement is executed and I can see form.vars.start_time has a string 
>>>>> value 
>>>>> such as '3:00PM'.  The insert statement executes with no error and the 
>>>>> record is inserted in the database but the time field shows as 
>>>>> 00:00:00. This further causes an error when trying to view the database 
>>>>> record from web2py:
>>>>>  
>>>>> ValueError: invalid literal for int() with base 10: '00PM'
>>>>>  
>>>>>  
>>>>> Any idea why the time is not inserting properly and how to fix it? Is 
>>>>> the time string in the wrong format?
>>>>>
>>>>>

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from 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] Updating auth.user extra_fields?

2013-11-18 Thread User
I want to store user page size preference for when there is a list view of 
items that needs pagination and have that preference persist between 
logins.  Two questions about this:

1. I decided to add an extra field to my auth.table. Is this the best place 
to store this type of data?
auth.settings.extra_fields['auth_user'] = [Field('pagesize','integer')]


2. If I want to update that setting how do I do it?
auth.user.pagesize = 100
seems to adjust the pagesize for the current session but does not seem to 
affect the db.


-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from 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: Updating auth.user extra_fields?

2013-11-19 Thread User
So am I correct in that in order to update the page size I would need to 
both update the database and also update the variable in the current 
session?
That is, the following is necessary:

db(db.auth_user.id == auth.user.id).update(pagesize=100)

auth.user.pagesize = 100




On Tuesday, November 19, 2013 7:28:33 AM UTC-5, Eduardo Cruz wrote:

>
> db(db.auth_user.id == auth.user.id).update(pagesize=100)
>
>  it will update the database. 
>
> El martes, 19 de noviembre de 2013 03:38:40 UTC-4, User escribió:
>>
>> I want to store user page size preference for when there is a list view 
>> of items that needs pagination and have that preference persist between 
>> logins.  Two questions about this:
>>
>> 1. I decided to add an extra field to my auth.table. Is this the best 
>> place to store this type of data?
>> auth.settings.extra_fields['auth_user'] = [Field('pagesize','integer')]
>>
>>
>> 2. If I want to update that setting how do I do it?
>> auth.user.pagesize = 100
>> seems to adjust the pagesize for the current session but does not seem to 
>> affect the db.
>>
>>
>>

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from 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 with div instead of html tables

2013-11-19 Thread User
This sounds like what I'm looking for.  Currently I'm manually creating a 
list display by having a for loop in the view to spit out  items.  
However I'm wondering if I can use sqlform.grid to replace the custom  
list.

1. Is this expected usage of sqlform.grid or is this more of a hack?

2. Can someone give a very basic example of what "myformat" function might 
look like?
mydisplay = myformat(grid.rows)
grid.element('.web2py_table', replace=mydisplay)




On Saturday, September 21, 2013 12:34:51 AM UTC-4, ssuresh wrote:

> Hi,
> I want to use sqlform.grid and all its features, but do not want the 
> display in a tabular format. Is there a way in which I can change the 
> display of sqlform.grid to my custom  instead of  .
>
>  I tried doing some formatting on grid.rows
>
> mydisplay = myformat(grid.rows)
> grid.element('.web2py_table', replace=mydisplay)
>
> but still the resultant output is displayed within a . Is there any 
> alternatives?
>
> Any help would be greatly appreciated.
>
> thanx,
> Suresh
>

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from 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: Updating auth.user extra_fields?

2013-11-19 Thread User
This topic seems to discuss a similar issue: 
https://groups.google.com/d/topic/web2py/_DDXJL7fwLk/discussion

The answer seems to be yes you have to manually update the version in 
session as well as the database if you want the information to be 
synchronized.  Using an after_update hook was discussed as a possible 
workaround.

On Tuesday, November 19, 2013 2:38:40 AM UTC-5, User wrote:

> I want to store user page size preference for when there is a list view of 
> items that needs pagination and have that preference persist between 
> logins.  Two questions about this:
>
> 1. I decided to add an extra field to my auth.table. Is this the best 
> place to store this type of data?
> auth.settings.extra_fields['auth_user'] = [Field('pagesize','integer')]
>
>
> 2. If I want to update that setting how do I do it?
> auth.user.pagesize = 100
> seems to adjust the pagesize for the current session but does not seem to 
> affect the db.
>
>
>

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from 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 with div instead of html tables

2013-11-20 Thread User
That's what I was thinking also but I wanted to make sure I wasn't missing 
some hidden capability of web2py

On Wednesday, November 20, 2013 6:53:21 AM UTC-5, Niphlod wrote:
>
> do it in your own views. altering all the markup of the grid and break it 
> down to do what you're asking it's just asking for disasters at any new 
> release of the grid's code (and lots of cpu wasted for nothing)
>
> On Wednesday, November 20, 2013 3:11:51 AM UTC+1, User wrote:
>>
>> This sounds like what I'm looking for.  Currently I'm manually creating a 
>> list display by having a for loop in the view to spit out  items.  
>> However I'm wondering if I can use sqlform.grid to replace the custom  
>> list.
>>
>> 1. Is this expected usage of sqlform.grid or is this more of a hack?
>>
>> 2. Can someone give a very basic example of what "myformat" function 
>> might look like?
>> mydisplay = myformat(grid.rows)
>> grid.element('.web2py_table', replace=mydisplay)
>>
>>
>>
>>
>> On Saturday, September 21, 2013 12:34:51 AM UTC-4, ssuresh wrote:
>>
>>> Hi,
>>> I want to use sqlform.grid and all its features, but do not want the 
>>> display in a tabular format. Is there a way in which I can change the 
>>> display of sqlform.grid to my custom  instead of  .
>>>
>>>  I tried doing some formatting on grid.rows
>>>
>>> mydisplay = myformat(grid.rows)
>>> grid.element('.web2py_table', replace=mydisplay)
>>>
>>> but still the resultant output is displayed within a . Is there 
>>> any alternatives?
>>>
>>> Any help would be greatly appreciated.
>>>
>>> thanx,
>>> Suresh
>>>
>>

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from 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] Spatial/GIS: find records within X distance of point?

2013-12-08 Thread User
I'm storing latitude/longitude coordinates in a geometry field (using 
PostgreSQL 
9.1.10):

Field('point', 'geometry()')

I understand there is also the geography type but from my reading geometry 
is faster and is suitable for small distances (
http://workshops.boundlessgeo.com/postgis-intro/geography.html#why-not-use-geography
)

I want users to be able to specify a reference point and search for all 
records within X distance from the reference point.  Using raw SQL I would 
use  ST_DWithin  doing 
something like

SELECT name, ST_AsText(point)
FROM mytable
WHERE ST_DWithin(point, ST_GeomFromText('POINT(40.47112 -76.33)',4326), 0.1)

But web2py does not seem to support ST_DWithin only st_within.  So how can 
I achieve a similar result in 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.


[web2py] Re: Spatial/GIS: find records within X distance of point?

2013-12-09 Thread User
Thanks.  This is what I see at line 2983 in dal.py:

def ST_DWITHIN(self, first, second):
"""
http://postgis.org/docs/ST_Within.html
"""
return 'ST_DWithin(%s,%s)' %(self.expand(first), 
self.expand(second, first.type))


The proper documentation is at http://postgis.org/docs/ST_DWithin.html (note 
the 'D').  Also looks like this is missing the 3rd argument to ST_DWithin:

boolean *ST_DWithin*(geometry g1, geometry g2, double precision 
distance_of_srid);


On Sunday, December 8, 2013 9:25:35 AM UTC-5, Massimo Di Pierro wrote:

> Added ST_Dwithin support in trunk. Please check it.
>
> On Sunday, 8 December 2013 07:02:06 UTC-6, User wrote:
>>
>> I'm storing latitude/longitude coordinates in a geometry field (using 
>> PostgreSQL 
>> 9.1.10):
>>
>> Field('point', 'geometry()')
>>
>> I understand there is also the geography type but from my reading 
>> geometry is faster and is suitable for small distances (
>> http://workshops.boundlessgeo.com/postgis-intro/geography.html#why-not-use-geography
>> )
>>
>> I want users to be able to specify a reference point and search for all 
>> records within X distance from the reference point.  Using raw SQL I would 
>> use  ST_DWithin <http://postgis.refractions.net/docs/ST_DWithin.html> doing 
>> something like
>>
>> SELECT name, ST_AsText(point)
>> FROM mytable
>> WHERE ST_DWithin(point, ST_GeomFromText('POINT(40.47112 -76.33)',4326), 
>> 0.1)
>>
>> But web2py does not seem to support ST_DWithin only st_within.  So how 
>> can I achieve a similar result in 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.


[web2py] Re: Spatial/GIS: find records within X distance of point?

2013-12-09 Thread User
Forgive me because I don't understand anything about the internals of 
web2py but doesn't REPLACE take three parameters:

def REPLACE(self, first, (second, third)):
return 'REPLACE(%s,%s,%s)' % (self.expand(first,'string'),
   self.expand(second,'string'),
   self.expand(third,'string'))



Also:

def ST_ASGEOJSON(self, first, second):
"""
http://postgis.org/docs/ST_AsGeoJSON.html
"""
return 'ST_AsGeoJSON(%s,%s,%s,%s)' %(second['version'],
self.expand(first), second['precision'], second['options'])



Or do you mean something different?


On Monday, December 9, 2013 4:45:27 PM UTC-5, Massimo Di Pierro wrote:

> OK. This needs more work than anticipated. Looks like the Query object 
> only supports unary and binary operators. Give me a little more time. ;-)
>
> On Monday, 9 December 2013 12:21:37 UTC-6, User wrote:
>>
>> Thanks.  This is what I see at line 2983 in dal.py:
>>
>> def ST_DWITHIN(self, first, second):
>> """
>> http://postgis.org/docs/ST_Within.html
>> """
>> return 'ST_DWithin(%s,%s)' %(self.expand(first), 
>> self.expand(second, first.type))
>>
>>
>> The proper documentation is at http://postgis.org/docs/ST_DWithin.html (note 
>> the 'D').  Also looks like this is missing the 3rd argument to ST_DWithin:
>>
>> boolean *ST_DWithin*(geometry g1, geometry g2, double precision 
>> distance_of_srid);
>>
>>
>> On Sunday, December 8, 2013 9:25:35 AM UTC-5, Massimo Di Pierro wrote:
>>
>>> Added ST_Dwithin support in trunk. Please check it.
>>>
>>> On Sunday, 8 December 2013 07:02:06 UTC-6, User wrote:
>>>>
>>>> I'm storing latitude/longitude coordinates in a geometry field (using 
>>>> PostgreSQL 
>>>> 9.1.10):
>>>>
>>>> Field('point', 'geometry()')
>>>>
>>>> I understand there is also the geography type but from my reading 
>>>> geometry is faster and is suitable for small distances (
>>>> http://workshops.boundlessgeo.com/postgis-intro/geography.html#why-not-use-geography
>>>> )
>>>>
>>>> I want users to be able to specify a reference point and search for all 
>>>> records within X distance from the reference point.  Using raw SQL I would 
>>>> use  ST_DWithin <http://postgis.refractions.net/docs/ST_DWithin.html> 
>>>> doing 
>>>> something like
>>>>
>>>> SELECT name, ST_AsText(point)
>>>> FROM mytable
>>>> WHERE ST_DWithin(point, ST_GeomFromText('POINT(40.47112 -76.33)',4326), 
>>>> 0.1)
>>>>
>>>> But web2py does not seem to support ST_DWithin only st_within.  So how 
>>>> can I achieve a similar result in 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.


[web2py] Re: Spatial/GIS: find records within X distance of point?

2013-12-09 Thread User
Thanks, on line 2987 I believe the format string is missing the 3rd '%s' 
parameter:

return 'ST_DWithin(%s,%s)' %(self.expand(first), 
self.expand(second, first.type),
 self.expand(third, 'double'))

Should be:

return 'ST_DWithin(%s,%s,%s)' %(self.expand(first), 
self.expand(second, first.type),
 self.expand(third, 'double'))


On Monday, December 9, 2013 6:06:32 PM UTC-5, Massimo Di Pierro wrote:

> Actually you do understand a lot of about this. That's a trick. It works. 
> We can use it in this case too, until we come up with a better design.
> I used the same trick as in REPLACE, in trunk. Please give it a try.
>
> Massimo
>
>
> On Monday, 9 December 2013 16:33:09 UTC-6, User wrote:
>>
>> Forgive me because I don't understand anything about the internals of 
>> web2py but doesn't REPLACE take three parameters:
>>
>> def REPLACE(self, first, (second, third)):
>> return 'REPLACE(%s,%s,%s)' % (self.expand(first,'string'),
>>self.expand(second,'string'),
>>self.expand(third,'string'))
>>
>>
>>
>> Also:
>>
>> def ST_ASGEOJSON(self, first, second):
>> """
>> http://postgis.org/docs/ST_AsGeoJSON.html
>> """
>> return 'ST_AsGeoJSON(%s,%s,%s,%s)' %(second['version'],
>> self.expand(first), second['precision'], second['options'])
>>
>>
>>
>> Or do you mean something different?
>>
>>
>> On Monday, December 9, 2013 4:45:27 PM UTC-5, Massimo Di Pierro wrote:
>>
>>> OK. This needs more work than anticipated. Looks like the Query object 
>>> only supports unary and binary operators. Give me a little more time. ;-)
>>>
>>> On Monday, 9 December 2013 12:21:37 UTC-6, User wrote:
>>>>
>>>> Thanks.  This is what I see at line 2983 in dal.py:
>>>>
>>>> def ST_DWITHIN(self, first, second):
>>>> """
>>>> http://postgis.org/docs/ST_Within.html
>>>> """
>>>> return 'ST_DWithin(%s,%s)' %(self.expand(first), 
>>>> self.expand(second, first.type))
>>>>
>>>>
>>>> The proper documentation is at http://postgis.org/docs/ST_DWithin.html 
>>>> (note 
>>>> the 'D').  Also looks like this is missing the 3rd argument to ST_DWithin:
>>>>
>>>> boolean *ST_DWithin*(geometry g1, geometry g2, double precision 
>>>> distance_of_srid);
>>>>
>>>>
>>>> On Sunday, December 8, 2013 9:25:35 AM UTC-5, Massimo Di Pierro wrote:
>>>>
>>>>> Added ST_Dwithin support in trunk. Please check it.
>>>>>
>>>>> On Sunday, 8 December 2013 07:02:06 UTC-6, User wrote:
>>>>>>
>>>>>> I'm storing latitude/longitude coordinates in a geometry field (using 
>>>>>> PostgreSQL 
>>>>>> 9.1.10):
>>>>>>
>>>>>> Field('point', 'geometry()')
>>>>>>
>>>>>> I understand there is also the geography type but from my reading 
>>>>>> geometry is faster and is suitable for small distances (
>>>>>> http://workshops.boundlessgeo.com/postgis-intro/geography.html#why-not-use-geography
>>>>>> )
>>>>>>
>>>>>> I want users to be able to specify a reference point and search for 
>>>>>> all records within X distance from the reference point.  Using raw SQL I 
>>>>>> would use  
>>>>>> ST_DWithin<http://postgis.refractions.net/docs/ST_DWithin.html> doing 
>>>>>> something like
>>>>>>
>>>>>> SELECT name, ST_AsText(point)
>>>>>> FROM mytable
>>>>>> WHERE ST_DWithin(point, ST_GeomFromText('POINT(40.47112 
>>>>>> -76.33)',4326), 0.1)
>>>>>>
>>>>>> But web2py does not seem to support ST_DWithin only st_within.  So 
>>>>>> how can I achieve a similar result in 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.


[web2py] Re: Spatial/GIS: find records within X distance of point?

2013-12-09 Thread User
This appears to be working correctly now thank you.  One more thing: the 
docstring on line 2985 is referencing the wrong PostGIS function 
(ST_Within), it should be:

"""
http://postgis.org/docs/ST_DWithin.html
"""
(note the D)

On Monday, December 9, 2013 6:54:53 PM UTC-5, Massimo Di Pierro wrote:

> You are right. Please check again.
>
> On Monday, 9 December 2013 17:16:17 UTC-6, User wrote:
>>
>> Thanks, on line 2987 I believe the format string is missing the 3rd '%s' 
>> parameter:
>>
>> return 'ST_DWithin(%s,%s)' %(self.expand(first), 
>> self.expand(second, first.type),
>>  self.expand(third, 'double'))
>>
>> Should be:
>>
>> return 'ST_DWithin(%s,%s,%s)' %(self.expand(first), 
>> self.expand(second, first.type),
>>  self.expand(third, 'double'))
>>
>>
>> On Monday, December 9, 2013 6:06:32 PM UTC-5, Massimo Di Pierro wrote:
>>
>>> Actually you do understand a lot of about this. That's a trick. It 
>>> works. We can use it in this case too, until we come up with a better 
>>> design.
>>> I used the same trick as in REPLACE, in trunk. Please give it a try.
>>>
>>> Massimo
>>>
>>>
>>> On Monday, 9 December 2013 16:33:09 UTC-6, User wrote:
>>>>
>>>> Forgive me because I don't understand anything about the internals of 
>>>> web2py but doesn't REPLACE take three parameters:
>>>>
>>>> def REPLACE(self, first, (second, third)):
>>>> return 'REPLACE(%s,%s,%s)' % (self.expand(first,'string'),
>>>>self.expand(second,'string'),
>>>>self.expand(third,'string'))
>>>>
>>>>
>>>>
>>>> Also:
>>>>
>>>> def ST_ASGEOJSON(self, first, second):
>>>> """
>>>> http://postgis.org/docs/ST_AsGeoJSON.html
>>>> """
>>>> return 'ST_AsGeoJSON(%s,%s,%s,%s)' %(second['version'],
>>>> self.expand(first), second['precision'], second['options'])
>>>>
>>>>
>>>>
>>>> Or do you mean something different?
>>>>
>>>>
>>>> On Monday, December 9, 2013 4:45:27 PM UTC-5, Massimo Di Pierro wrote:
>>>>
>>>>> OK. This needs more work than anticipated. Looks like the Query object 
>>>>> only supports unary and binary operators. Give me a little more time. ;-)
>>>>>
>>>>> On Monday, 9 December 2013 12:21:37 UTC-6, User wrote:
>>>>>>
>>>>>> Thanks.  This is what I see at line 2983 in dal.py:
>>>>>>
>>>>>> def ST_DWITHIN(self, first, second):
>>>>>> """
>>>>>> http://postgis.org/docs/ST_Within.html
>>>>>> """
>>>>>> return 'ST_DWithin(%s,%s)' %(self.expand(first), 
>>>>>> self.expand(second, first.type))
>>>>>>
>>>>>>
>>>>>> The proper documentation is at 
>>>>>> http://postgis.org/docs/ST_DWithin.html (note the 'D').  Also looks 
>>>>>> like this is missing the 3rd argument to ST_DWithin:
>>>>>>
>>>>>> boolean *ST_DWithin*(geometry g1, geometry g2, double precision 
>>>>>> distance_of_srid);
>>>>>>
>>>>>>
>>>>>> On Sunday, December 8, 2013 9:25:35 AM UTC-5, Massimo Di Pierro wrote:
>>>>>>
>>>>>>> Added ST_Dwithin support in trunk. Please check it.
>>>>>>>
>>>>>>> On Sunday, 8 December 2013 07:02:06 UTC-6, User wrote:
>>>>>>>>
>>>>>>>> I'm storing latitude/longitude coordinates in a geometry field 
>>>>>>>> (using PostgreSQL 9.1.10):
>>>>>>>>
>>>>>>>> Field('point', 'geometry()')
>>>>>>>>
>>>>>>>> I understand there is also the geography type but from my reading 
>>>>>>>> geometry is faster and is suitable for small distances (
>>>>>>>> http://workshops.boundlessgeo.com/postgis-intro/geography.html#why-not-use-geography
>>>>>>>> )
>>>>>>>>
>>>>>>>> I want users to be able to specify a reference point and search for 
>>>>>>>> all records within X distance from the reference point.  Using raw SQL 
>>>>>>>> I 
>>>>>>>> would use  
>>>>>>>> ST_DWithin<http://postgis.refractions.net/docs/ST_DWithin.html> doing 
>>>>>>>> something like
>>>>>>>>
>>>>>>>> SELECT name, ST_AsText(point)
>>>>>>>> FROM mytable
>>>>>>>> WHERE ST_DWithin(point, ST_GeomFromText('POINT(40.47112 
>>>>>>>> -76.33)',4326), 0.1)
>>>>>>>>
>>>>>>>> But web2py does not seem to support ST_DWithin only st_within.  So 
>>>>>>>> how can I achieve a similar result in 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.


[web2py] SQLFORM.factory defaults?

2013-12-29 Thread User
I'm creating a form that is not based on a database table.  I understand I 
can add a default to a field created with SQLFORM.factory, for example:

form = SQLFORM.factory(
Field('name', 'string', default='John'),
...

is it possible to specify a default after the above statement has 
executed?  For example something like this:

form = SQLFORM.factory(
Field('name', 'string'),
...
form.something.name.default = 'John'

Or is the only way to specify a default in the Field constructor?  The 
reason I ask is because I have some logic involved in determining the 
default value (of course I can think of a workaround but I'm just curious)
  

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from 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 is the purpose of data-w2p_disable_with?

2013-12-30 Thread User
Links I build with the anchor A html helper look like:

Anchor 
Text

What is the purpose of the data-w2p_disable_with = "default" attribute and 
how can I remove it?

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


[web2py] Select all fields plus a calculated field?

2013-12-31 Thread User
What is the proper way to select all fields plus a few additional 
calculated fields? Here is my basic query with no calculated field

location = db(db.location.id == loc_id).select().first()


This query returns location as a  object with fields 
for the location table as attributes. With this I can access 
location.address for example.

Now to add calculated fields to get the geo spatial coordinates from the 
point field, I'm trying this:

location = db(db.location.id == loc_id).select(db.location.ALL,
  db.location.point.st_x().
with_alias('latitude'),
  db.location.point.st_y().
with_alias('longitude')).first()


Is this the proper way? This returns a  object with 
a "location" field (which is in turn also a Row object)  and "latitude" and 
"longitude" fields.

Now in order to access the address field I must do location.location.address

How can make it so I can access the fields like location.address and 
location.latitude?

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from 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 for latitude and longitude from geometry field?

2014-01-01 Thread User
Suppose I have a table like:

db.define_table('location',
Field(name, 'string'),
Field('point', 'geometry()')
)

I want to have the latitude and longitude as attributes also (whose value 
can be derived from the point field).  So I try this:

db.define_table('location',
Field(name, 'string'),
Field('point', 'geometry()'),
Field.Virtual('latitude', lambda row: row.location.point.st_x()),
Field.Virtual('longitude', lambda row: row.location.point.st_y()),
)

But it doesn't work and fails silently.  The model just doesn't have 
latitude or longitude fields. I also tried with Field.Method but this 
complains that 'point' is of typer str.

I guess the complication is that st_x() translates into a database 
function.  I'm thinking about parsing the point string which is of the form 
"POINT(x y)" as a workaround but I'd rather use st_x if someone can show me 
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: Select all fields plus a calculated field?

2014-01-02 Thread User
My workaround is to change this:

location = db(db.location.id == loc_id).select(db.location.ALL,
  db.location.point.st_x().
with_alias('latitude'),
  db.location.point.st_y().
with_alias('longitude')).first()



into this:

row = db(db.location.id == loc_id).select(db.location.ALL,
  db.location.point.st_x().
with_alias('latitude'),
  db.location.point.st_y().
with_alias('longitude')).first()

location = row.location
location.latitude = row.latitude
location.longitude = row.longitude


It works but it's a little kludgy as far as I'm concerned.  Anyone have a 
cleaner solution?

On Tuesday, December 31, 2013 7:00:10 PM UTC-5, User wrote:

> What is the proper way to select all fields plus a few additional 
> calculated fields? Here is my basic query with no calculated field
>
> location = db(db.location.id == loc_id).select().first()
>
>
> This query returns location as a  object with 
> fields for the location table as attributes. With this I can access 
> location.address for example.
>
> Now to add calculated fields to get the geo spatial coordinates from the 
> point field, I'm trying this:
>
> location = db(db.location.id == loc_id).select(db.location.ALL,
>   db.location.point.st_x().
> with_alias('latitude'),
>   db.location.point.st_y().
> with_alias('longitude')).first()
>
>
> Is this the proper way? This returns a  object with 
> a "location" field (which is in turn also a Row object)  and "latitude" and 
> "longitude" fields.
>
> Now in order to access the address field I must do 
> location.location.address
>
> How can make it so I can access the fields like location.address and 
> location.latitude?
>
>

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from 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: Virtual field for latitude and longitude from geometry field?

2014-01-03 Thread User
Didn't realize you could make a second query in a Virtual field but makes 
sense now that I see it.  Although I'd rather not make the extra query (2 
actually since longitude would need to do the same thing) so I guess I will 
just add latitude and longitude directly to my original select instead of 
trying to make them Virtual fields. e.g.

db(db.location.id>0).select(db.location.ALL, db.location.point.st_x(), db.
location.point.st_y())



On Friday, January 3, 2014 4:16:57 AM UTC-5, Paolo Valleri wrote:

> st_*() are db engine functions, you should query the db to get the output 
> you are looking for. Given that, in your virtual field you should make a 
> new query, something like that:
>
> Field.Virtual('latitude', lambda row: db(db.location.id == row.location.id
> ).select(db.location.point.st_x()).first()[db.location.point.st_x()]
>
> Paolo
>
> On Thursday, January 2, 2014 9:59:14 PM UTC+1, Christian Foster Howes 
> wrote:
>>
>> i bet that by the time your lambda is running the point has been 
>> converted to a string already.  can you see if that is true?  i'm not sure 
>> how to invoke db functions in a lambda of a virtual field. :(
>>
>> On Wednesday, January 1, 2014 5:50:54 PM UTC-8, User wrote:
>>>
>>> Suppose I have a table like:
>>>
>>> db.define_table('location',
>>> Field(name, 'string'),
>>> Field('point', 'geometry()')
>>> )
>>>
>>> I want to have the latitude and longitude as attributes also (whose 
>>> value can be derived from the point field).  So I try this:
>>>
>>> db.define_table('location',
>>> Field(name, 'string'),
>>> Field('point', 'geometry()'),
>>> Field.Virtual('latitude', lambda row: row.location.point.st_x()),
>>> Field.Virtual('longitude', lambda row: row.location.point.st_y()),
>>> )
>>>
>>> But it doesn't work and fails silently.  The model just doesn't have 
>>> latitude or longitude fields. I also tried with Field.Method but this 
>>> complains that 'point' is of typer str.
>>>
>>> I guess the complication is that st_x() translates into a database 
>>> function.  I'm thinking about parsing the point string which is of the form 
>>> "POINT(x y)" as a workaround but I'd rather use st_x if someone can show me 
>>> 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: What is the purpose of data-w2p_disable_with?

2014-01-03 Thread User
Good to know.  How can I remove it for all my links?

On Monday, December 30, 2013 8:18:11 PM UTC-5, Anthony wrote:
>
> That's so the link can be temporarily disabled (the text will be replaced 
> with "Working...") when it is used to trigger an Ajax request. However, I 
> don't know why it's included in the anchor tag in all cases -- seems like 
> it would only be needed when the "cid", "component", or "callback" 
> arguments are used.
>
> Anthony
>
> On Monday, December 30, 2013 5:39:53 PM UTC-5, User wrote:
>>
>> Links I build with the anchor A html helper look like:
>>
>> Anchor 
>> Text
>>
>> What is the purpose of the data-w2p_disable_with = "default" attribute 
>> and how can I remove it?
>>
>>

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


[web2py] Re: SQLFORM and IS_IN_SET problem

2014-01-07 Thread User
I have the same problem as the original poster.  I am only storing a single 
value as of now but I'm using list:string instead of string so that if I 
change my mind to allow multiple values it will be easier to transition.  
Is this a bug that it won't preselect the selected value?  Alternatively, 
does migration from a string field to a list:string field preserve the 
string data?


On Monday, October 10, 2011 7:20:46 PM UTC-4, Anthony wrote:

> On Monday, October 10, 2011 6:01:49 PM UTC-4, Cliff wrote:
>>
>> Mostly fixed now.  There was also a bug in my controller code that was 
>> complicating things. 
>>
>> One problem remains.  With readonly=True, the field still shows the 
>> dictionary key rather than the value.
>>
>
> With readonly, I guess it's not using the widget, so it will just show the 
> value stored in the field itself. Maybe you can define a represent function 
> for the field so it shows the label associated with the value.
>
> Anthony
>

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


[web2py] Scheduler: Error retrieving status?

2014-01-09 Thread User
I'm just getting started with the scheduler and I'm getting an error when I 
start it on windows 7:

C:\www\web2py>python web2py.py -K my_app
web2py Web Framework
Created by Massimo Di Pierro, Copyright 2007-2014
Version 2.8.2-stable+timestamp.2013.12.09.17.54.55
Database drivers available: SQLite(sqlite3), MySQL(pymysql), PostgreSQL(
psycopg2
), PostgreSQL(pg8000), MSSQL(pyodbc), DB2(pyodbc), Teradata(pyodbc), Ingres(
pyod
bc), IMAP(imaplib)
starting single-scheduler for "my_app"...
ERROR:web2py.scheduler.mycomputer#10144:Error retrieving status
ERROR:web2py.scheduler.mycomputer#10144:Error retrieving status


This error just continually repeats until I ctrl-c.
Here is my scheduler.py:

# coding: utf8
def doit():
print 'hello world'

tasks = dict(
doit=doit,
)
from gluon.scheduler import Scheduler
scheduler = Scheduler(db, tasks)


I created a single row in the scheduler_task table. What is causing this 
error? How do I begin to debug this? (Note when browsing my site there are 
no errors).

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from 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: Scheduler: Error retrieving status?

2014-01-10 Thread User
postgresql.  Also my app which uses same database works and I can see the 
tables and the row in scheduler_task table from appadmin

On Friday, January 10, 2014 9:57:25 AM UTC-5, Niphlod wrote:
>
> what db are you using ?
> that error usually pops up when the scheduler can't access the scheduler_* 
> tables.
>
> On Friday, January 10, 2014 2:09:26 AM UTC+1, User wrote:
>>
>> I'm just getting started with the scheduler and I'm getting an error when 
>> I start it on windows 7:
>>
>> C:\www\web2py>python web2py.py -K my_app
>> web2py Web Framework
>> Created by Massimo Di Pierro, Copyright 2007-2014
>> Version 2.8.2-stable+timestamp.2013.12.09.17.54.55
>> Database drivers available: SQLite(sqlite3), MySQL(pymysql), PostgreSQL(
>> psycopg2
>> ), PostgreSQL(pg8000), MSSQL(pyodbc), DB2(pyodbc), Teradata(pyodbc), 
>> Ingres(pyod
>> bc), IMAP(imaplib)
>> starting single-scheduler for "my_app"...
>> ERROR:web2py.scheduler.mycomputer#10144:Error retrieving status
>> ERROR:web2py.scheduler.mycomputer#10144:Error retrieving status
>>
>>
>> This error just continually repeats until I ctrl-c.
>> Here is my scheduler.py:
>>
>> # coding: utf8
>> def doit():
>> print 'hello world'
>> 
>> tasks = dict(
>> doit=doit,
>> )
>> from gluon.scheduler import Scheduler
>> scheduler = Scheduler(db, tasks)
>>
>>
>> I created a single row in the scheduler_task table. What is causing this 
>> error? How do I begin to debug this? (Note when browsing my site there are 
>> no errors).
>>
>>

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from 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: Scheduler: Error retrieving status?

2014-01-10 Thread User
I created a bare bones app and the scheduler seems to work without error.  
Not really sure what's happening with the problem app but if I had to guess 
I'm thinking it might be related to using

db._common_fields.append(standard_fields)

where standard_fields is a table with fields such as date_created, 
created_by, modified_by etc. which in turn has defaults like 
auth.user_id.  Unexpected by me, these got appended to the scheduler 
tables. Maybe there is some problematic interaction with this.

I'm going to try explicitly adding standard_fields to my app tables rather 
than using db._common_fields.append to see if that fixes it.


On Friday, January 10, 2014 10:53:22 AM UTC-5, User wrote:

> postgresql.  Also my app which uses same database works and I can see the 
> tables and the row in scheduler_task table from appadmin
>
> On Friday, January 10, 2014 9:57:25 AM UTC-5, Niphlod wrote:
>>
>> what db are you using ?
>> that error usually pops up when the scheduler can't access the 
>> scheduler_* tables.
>>
>> On Friday, January 10, 2014 2:09:26 AM UTC+1, User wrote:
>>>
>>> I'm just getting started with the scheduler and I'm getting an error 
>>> when I start it on windows 7:
>>>
>>> C:\www\web2py>python web2py.py -K my_app
>>> web2py Web Framework
>>> Created by Massimo Di Pierro, Copyright 2007-2014
>>> Version 2.8.2-stable+timestamp.2013.12.09.17.54.55
>>> Database drivers available: SQLite(sqlite3), MySQL(pymysql), PostgreSQL(
>>> psycopg2
>>> ), PostgreSQL(pg8000), MSSQL(pyodbc), DB2(pyodbc), Teradata(pyodbc), 
>>> Ingres(pyod
>>> bc), IMAP(imaplib)
>>> starting single-scheduler for "my_app"...
>>> ERROR:web2py.scheduler.mycomputer#10144:Error retrieving status
>>> ERROR:web2py.scheduler.mycomputer#10144:Error retrieving status
>>>
>>>
>>> This error just continually repeats until I ctrl-c.
>>> Here is my scheduler.py:
>>>
>>> # coding: utf8
>>> def doit():
>>> print 'hello world'
>>> 
>>> tasks = dict(
>>> doit=doit,
>>> )
>>> from gluon.scheduler import Scheduler
>>> scheduler = Scheduler(db, tasks)
>>>
>>>
>>> I created a single row in the scheduler_task table. What is causing this 
>>> error? How do I begin to debug this? (Note when browsing my site there are 
>>> no errors).
>>>
>>>

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from 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: Scheduler: Error retrieving status?

2014-01-10 Thread User
Ok that appears to have been the problem.  Getting rid of 
db._common_fields.append(standard_fields) fixed it.  Didn't hone in on the 
exact problem but maybe it's because I had not null on created_by, 
modified_by fields which defaulted to auth.user_id.  Does a scheduled task 
even have a concept of a logged in user?

On Friday, January 10, 2014 7:07:32 PM UTC-5, User wrote:
>
> I created a bare bones app and the scheduler seems to work without error.  
> Not really sure what's happening with the problem app but if I had to guess 
> I'm thinking it might be related to using
>
> db._common_fields.append(standard_fields)
>
> where standard_fields is a table with fields such as date_created, 
> created_by, modified_by etc. which in turn has defaults like 
> auth.user_id.  Unexpected by me, these got appended to the scheduler 
> tables. Maybe there is some problematic interaction with this.
>
> I'm going to try explicitly adding standard_fields to my app tables rather 
> than using db._common_fields.append to see if that fixes it.
>
>
> On Friday, January 10, 2014 10:53:22 AM UTC-5, User wrote:
>
>> postgresql.  Also my app which uses same database works and I can see the 
>> tables and the row in scheduler_task table from appadmin
>>
>> On Friday, January 10, 2014 9:57:25 AM UTC-5, Niphlod wrote:
>>>
>>> what db are you using ?
>>> that error usually pops up when the scheduler can't access the 
>>> scheduler_* tables.
>>>
>>> On Friday, January 10, 2014 2:09:26 AM UTC+1, User wrote:
>>>>
>>>> I'm just getting started with the scheduler and I'm getting an error 
>>>> when I start it on windows 7:
>>>>
>>>> C:\www\web2py>python web2py.py -K my_app
>>>> web2py Web Framework
>>>> Created by Massimo Di Pierro, Copyright 2007-2014
>>>> Version 2.8.2-stable+timestamp.2013.12.09.17.54.55
>>>> Database drivers available: SQLite(sqlite3), MySQL(pymysql), PostgreSQL
>>>> (psycopg2
>>>> ), PostgreSQL(pg8000), MSSQL(pyodbc), DB2(pyodbc), Teradata(pyodbc), 
>>>> Ingres(pyod
>>>> bc), IMAP(imaplib)
>>>> starting single-scheduler for "my_app"...
>>>> ERROR:web2py.scheduler.mycomputer#10144:Error retrieving status
>>>> ERROR:web2py.scheduler.mycomputer#10144:Error retrieving status
>>>>
>>>>
>>>> This error just continually repeats until I ctrl-c.
>>>> Here is my scheduler.py:
>>>>
>>>> # coding: utf8
>>>> def doit():
>>>> print 'hello world'
>>>> 
>>>> tasks = dict(
>>>> doit=doit,
>>>> )
>>>> from gluon.scheduler import Scheduler
>>>> scheduler = Scheduler(db, tasks)
>>>>
>>>>
>>>> I created a single row in the scheduler_task table. What is causing 
>>>> this error? How do I begin to debug this? (Note when browsing my site 
>>>> there 
>>>> are no errors).
>>>>
>>>>

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from 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: Debugging with the scheduler

2014-01-11 Thread User
For future reference just adding the fact that you can open a web2py shell 
and call your scheduler tasks directly in order to debug them.  This wasn't 
obvious to me but is much easier than trying to run the scheduler and debug 
it via logging statements.

For example:

python web2py.py  -M -S your_app_name

and then call a function from your scheduler.py file which will just be a 
global function (that is, just type the function name at the shell 
prompt).  Inside your function you can set a pdb break point and debug to 
your heart's content.

scheduler.py:

def myfunction():
import pdb; pdb.set_trace()
...





On Wednesday, February 27, 2013 4:36:10 PM UTC-5, José L. wrote:

> 2013/2/26 Niphlod >: 
> > never done it, but debugging a multiprocessing spawned process needs 
> > additional tuning http://pydev.org/manual_adv_remote_debugger.html 
> > 
> > PS: can I ask what is not working ? if it's a "focused" problem maybe I 
> can 
> > come up with an answer . 
>
> I've fixed it , it was a problem with a locked file when using shelve. 
> I've used a workaround but I don't feel happy with the solution (it 
> works but's terribly ugly). Any idea to exchange a big Python list 
> with data between the main web2py application and the long-lasting 
> backgroud process is welcome. 
>
> Regards. 
>
>
> > 
> > 
> > On Tuesday, February 26, 2013 9:12:23 PM UTC+1, José L. wrote: 
> >> 
> >> Hello, 
> >> I'm working with async processes using the scheduler (with the 
> >> unvaluable help of the "learn by trial" application from Niphlod. 
> >> 
> >> I wonder if there's an easy way to debug the processes that are being 
> >> executed in the background (I'm  having problems with them, they work 
> >> ok when run from web2py directly as a normal process, but not when 
> >> they're executed by the scheduler). 
> >> Pdb would be great, but if not, is there any way to use the ugly but 
> >> useful "print vars" commands to see the flow of execution of the 
> >> tasks? 
> >> 
> >> I know of the output field in the scheduler_task table in the 
> >> database, but that's terribly slow 
> >> 
> >> Regards. 
> >> José L. 
> > 
> > -- 
> > 
> > --- 
> > You received this message because you are 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] Does migration from a 'string' field to a 'list:string' field preserve data?

2014-01-13 Thread User
Does a migration from a 'string' field to a 'list:string' field preserve 
string data that is already in the database and convert it to the format 
required by list:string?

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from 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: Does migration from a 'string' field to a 'list:string' field preserve data?

2014-01-13 Thread User
I just test this with a simple app using SQLite database and it seems that 
it doesn't quite work.

It appears it will truncate the string data that exists in the string 
field.  Specifically it will remove the first and last character of 
whatever is in the string field.  For example:

"hello" -> "ell"
"something" -> "omthin"
"world" -> "orl"

Migration back from list:string to string will preserve the existing 
list:string data in the web2py representation:

"hello", "world" -> "|hello|world|"
"one", "two" -> "|one|two|"



On Monday, January 13, 2014 3:34:47 PM UTC-5, User wrote:

> Does a migration from a 'string' field to a 'list:string' field preserve 
> string data that is already in the database and convert it to the format 
> required by list:string?
>

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from 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 and IS_IN_SET problem

2014-01-13 Thread User
So I tested the migration feature and string to list:string doesn't work.  
So we are left with the fact that a list:string field with IS_IN_SET 
multiple=False will not select the current value in an SQLFORM.

Seems kind of like a bug to me, does anyone else think so?


On Tuesday, January 7, 2014 8:08:13 PM UTC-5, User wrote:

> I have the same problem as the original poster.  I am only storing a 
> single value as of now but I'm using list:string instead of string so that 
> if I change my mind to allow multiple values it will be easier to 
> transition.  Is this a bug that it won't preselect the selected value?  
> Alternatively, does migration from a string field to a list:string field 
> preserve the string data?
>
>
> On Monday, October 10, 2011 7:20:46 PM UTC-4, Anthony wrote:
>
>> On Monday, October 10, 2011 6:01:49 PM UTC-4, Cliff wrote:
>>>
>>> Mostly fixed now.  There was also a bug in my controller code that was 
>>> complicating things. 
>>>
>>> One problem remains.  With readonly=True, the field still shows the 
>>> dictionary key rather than the value.
>>>
>>
>> With readonly, I guess it's not using the widget, so it will just show 
>> the value stored in the field itself. Maybe you can define a represent 
>> function for the field so it shows the label associated with the value.
>>
>> Anthony
>>
>

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


[web2py] Re: Does migration from a 'string' field to a 'list:string' field preserve data?

2014-01-13 Thread User


It appears it will leave the string data that exists in the string field 
alone in the database, however web2py will interpret it such that the first 
and last character are truncated.  For example:

"hello" -> "ell"

"something" -> "omethin"

"world" -> "orl"
As soon as you add another list item to the string, then web2py 
will overwrite the original string's first and last characters with pipe 
characters in the database in addition to adding the new item.

Migration back from list:string to string will preserve whatever 
list:string data is there (in the web2py representation format).

"hello", "world" -> "|hello|world|"

"one", "two" -> "|one|two|"

Would it make sense for the migration process to handle this more 
gracefully?


On Monday, January 13, 2014 3:34:47 PM UTC-5, User wrote:

> Does a migration from a 'string' field to a 'list:string' field preserve 
> string data that is already in the database and convert it to the format 
> required by list:string?
>

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from 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: Data Fixtures

2014-01-13 Thread User
I have the same question.  Is there any update on this almost 2 years later?

On Thursday, March 8, 2012 4:32:45 PM UTC-5, Bruce Wade wrote:
>
> Hi,
>
> I have seen lots of postings about people wanting to pre-load data 
> (fixtures) in web2py. However I have never found a standard solution.
>
> What are the best practices? Also before someone suggests putting them in 
> the models directory I don't think that is a good idea. I would prefer 
> something more like django where we can run a command to load the fixtures 
> whenever we want.
>
> IE: 
> python web2py.py -f fixtures_path or file
>
> -- 
> -- 
> Regards,
> Bruce Wade
> http://ca.linkedin.com/in/brucelwade
> http://www.wadecybertech.com
> http://www.warplydesigned.com
> http://www.fitnessfriendsfinder.com
>  

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from 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: Does migration from a 'string' field to a 'list:string' field preserve data?

2014-01-14 Thread User
I just tested this with a simple app using postgresql database and it seems 
that it doesn't quite work.

It appears it will leave the string data that exists in the string field 
alone in the database, however web2py will interpret it such that the first 
and last character are truncated.  For example:

"hello" -> "ell"
"something" -> "omthin"
"world" -> "orl"

As soon as you add another list item to the string, then web2py will 
truncate the original string's first and last characters in the database in 
addition to adding the new item.

Migration back from list:string to string will preserve whatever 
list:string data is there (in the web2py representation format).

"hello", "world" -> "|hello|world|"
"one", "two" -> "|one|two|"

Would it make sense for the migration process to handle this more 
gracefully?

On Monday, January 13, 2014 3:34:47 PM UTC-5, User wrote:

> Does a migration from a 'string' field to a 'list:string' field preserve 
> string data that is already in the database and convert it to the format 
> required by list:string?
>

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from 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 and IS_IN_SET problem

2014-01-14 Thread User
Thanks good point about just modifying the db field directly to add pipe 
characters if migrating from string to list:string.  I think in that case I 
will make my field a string field and migrate later if necessary.

On Tuesday, January 14, 2014 9:48:53 AM UTC-5, Anthony wrote:
>
> On Tuesday, January 14, 2014 1:18:11 AM UTC-5, User wrote:
>>
>> So I tested the migration feature and string to list:string doesn't 
>> work.  So we are left with the fact that a list:string field with IS_IN_SET 
>> multiple=False will not select the current value in an SQLFORM.
>>
>> Seems kind of like a bug to me, does anyone else think so?
>>
>
> I wouldn't call it a bug. It's somewhat of an odd use case.  Using 
> IS_IN_SET with multiple=False gives you a non-multiple SELECT widget. Such 
> a widget can have only a single option selected, so the web2py SELECT 
> helper checks to see if the current value of the field is the same as any 
> of the OPTION values. Because the current value of the list:string field is 
> a list (and not an individual string), it will not match the value of any 
> option values.
>
> Instead, you can just switch to a string field, and if you ever need to 
> migrate, just wrap each string in pipe characters (i.e., "|thestring|").
>
> Another option is to create a custom widget:
>
> Field('myfield', 'list:string', requires=IS_IN_SET(...), widget=mywidget)
>
> Finally, you can do:
>
> Field('myfield', 'list:string', requires=IS_IN_SET(..., multiple=(1, 1)),
>   comment='Please select only one.')
>
> The above will show a multiple select box instead of a single-select 
> drop-down, but it will require the user to select exactly one option (will 
> return an error message otherwise).
>
> Anthony
>

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


[web2py] Re: Does migration from a 'string' field to a 'list:string' field preserve data?

2014-01-14 Thread User
For completeness and future reference this can also be done directly in SQL 
for example in postgresql:

UPDATE your_table set some_field =  '|' || some_field || '|';

On Tuesday, January 14, 2014 8:52:40 AM UTC-5, Anthony wrote:

> For now, if you want to do a migration, all you have to do is loop through 
> the records and put a pipe character ("|") before and after each string. 
> Perhaps this can be automated -- you can submit an issue on Google Code.
>
> Anthony
>
> On Tuesday, January 14, 2014 1:21:52 AM UTC-5, User wrote:
>>
>> It appears it will leave the string data that exists in the string field 
>> alone in the database, however web2py will interpret it such that the first 
>> and last character are truncated.  For example:
>>
>> "hello" -> "ell"
>>
>> "something" -> "omethin"
>>
>> "world" -> "orl"
>> As soon as you add another list item to the string, then web2py 
>> will overwrite the original string's first and last characters with pipe 
>> characters in the database in addition to adding the new item.
>>
>> Migration back from list:string to string will preserve whatever 
>> list:string data is there (in the web2py representation format).
>>
>> "hello", "world" -> "|hello|world|"
>>
>> "one", "two" -> "|one|two|"
>>
>> Would it make sense for the migration process to handle this more 
>> gracefully?
>>
>>
>> On Monday, January 13, 2014 3:34:47 PM UTC-5, User wrote:
>>
>>> Does a migration from a 'string' field to a 'list:string' field preserve 
>>> string data that is already in the database and convert it to the format 
>>> required by list:string?
>>>
>>

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from 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] Select scalar?

2014-01-15 Thread User
Is there a convenience method to select a scalar value from a database 
table?

What I do currently is:

db(db.customer.id == 5).select(db.customer.first_name).first().first_name

If not would it make sense to add one?  Seems like a reasonably common use 
case.  Maybe something like

db(db.customer.id == 5).scalar(db.customer.first_name)

Not that big a difference but might be worthwhile.



-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from 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: What is the purpose of data-w2p_disable_with?

2014-01-20 Thread User
Anyone know how to remove it?  I'm about to switch to using raw html 
instead of A helper but if someone knows a way to remove the 
"data-w2p_disable_with" 
attribute I'd rather do that.  If there is not an official way perhaps 
there is a hack where I could redefine the A helper somehow



On Saturday, January 4, 2014 1:25:43 AM UTC-5, User wrote:

> Good to know.  How can I remove it for all my links?
>
> On Monday, December 30, 2013 8:18:11 PM UTC-5, Anthony wrote:
>>
>> That's so the link can be temporarily disabled (the text will be replaced 
>> with "Working...") when it is used to trigger an Ajax request. However, I 
>> don't know why it's included in the anchor tag in all cases -- seems like 
>> it would only be needed when the "cid", "component", or "callback" 
>> arguments are used.
>>
>> Anthony
>>
>> On Monday, December 30, 2013 5:39:53 PM UTC-5, User wrote:
>>>
>>> Links I build with the anchor A html helper look like:
>>>
>>> Anchor 
>>> Text
>>>
>>> What is the purpose of the data-w2p_disable_with = "default" attribute 
>>> and how can I remove it?
>>>
>>>

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


[web2py] Re: foreign key reference and "not null" mutually exclusive. by design, or a bug?

2014-01-22 Thread User
I also would like a non-null foreign key reference, but like OP 
experienced web2py will not create one.  Why is this?  And is there a 
workaround to make reference fields not null?  Or worst case can I add the 
not null constraint manually in the db without breaking anything?


On Tuesday, June 19, 2012 11:40:37 AM UTC-4, Ivan wrote:

> Same problem here!
> The "notnull=True" parameter doesn't append the "NOT NULL" clause for 
> reference fields.
> The IS_IN_DB function activates the check at form-level while the notnull 
> parameter should set the constraint at db-level.
>
>

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from 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: foreign key reference and "not null" mutually exclusive. by design, or a bug?

2014-01-23 Thread User
Thanks.  Here is the issue in case anyone is interested:

http://code.google.com/p/web2py/issues/detail?id=1395


On Wednesday, January 22, 2014 3:39:56 PM UTC-5, Anthony wrote:

> This is a bug, and an issue has been created. Yes, you should be able to 
> make the change directly in the database.
>
> Anthony
>
> On Wednesday, January 22, 2014 1:13:30 PM UTC-5, User wrote:
>>
>> I also would like a non-null foreign key reference, but like OP 
>> experienced web2py will not create one (I'm using postgresql).  Why is 
>> this?  And is there a workaround to make reference fields not null?  Or 
>> worst case can I add the not null constraint manually in the db without 
>> breaking anything?
>>
>>
>> On Tuesday, June 19, 2012 11:40:37 AM UTC-4, Ivan wrote:
>>
>>> Same problem here!
>>> The "notnull=True" parameter doesn't append the "NOT NULL" clause for 
>>> reference fields.
>>> The IS_IN_DB function activates the check at form-level while the 
>>> notnull parameter should set the constraint at db-level.
>>>
>>>

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from 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] Warning about using web2py URL rewrite?

2014-01-24 Thread User
 
http://www.web2py.com/AlterEgo/default/show/42 says:
 

"web2py supports URL rerwite although this is not really recommended. You 
should really use Apache (or lighttpd) + mod_proxy (or mod_rewrite) for 
this purpose. Moreover rewriting web2py urls can break links in 
applications. So *do not do it*. Anyway if you really really want to ..."

 
Is this a valid warning?  Why might this be?  And if apache mod_rewrite is 
better does anyone have a basic example for routing an application at 
www.example.com/someapp/default/index to www.example.com/

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from 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] URL-based languages for pattern-based routing?

2014-01-24 Thread User
I'm using pattern-based routing to meet some of my routing needs.  How can 
I support URL-based languages (as described in 
http://www.web2py.com/book/default/chapter/04#Parameter-based-system) but 
with the pattern-based routing?

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from 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: What is the purpose of data-w2p_disable_with?

2014-01-26 Thread User
I see this is fixed in trunk now 
http://code.google.com/p/web2py/source/detail?r=ed705d58b82c0d2363b04e69256c9fe122434a37
thanks guys

On Monday, January 20, 2014 5:39:59 PM UTC-5, Anthony wrote:

> It shouldn't be causing any problems, so you don't really *have* to 
> remove it. Unfortunately, it is inserted by the .xml() method, so you can't 
> just manipulate the A() object. Instead, you can do:
>
> {{=XML(A(...).xml().replace(' data-w2p_disable_with="default"', ''))}}
>
> I suppose you could make a class that does that:
>
> class A2(A):
> def xml(self):
> return super(A2, self).xml().replace(' 
> data-w2p_disable_with="default"', '')
>
> Anyway, we should probably change the behavior of A() so it doesn't add 
> that attribute when not needed.
>
> Anthony
>
> On Monday, January 20, 2014 2:22:17 PM UTC-5, User wrote:
>>
>> Anyone know how to remove it?  I'm about to switch to using raw html 
>> instead of A helper but if someone knows a way to remove the 
>> "data-w2p_disable_with" 
>> attribute I'd rather do that.  If there is not an official way perhaps 
>> there is a hack where I could redefine the A helper somehow
>>
>>
>>
>> On Saturday, January 4, 2014 1:25:43 AM UTC-5, User wrote:
>>
>>> Good to know.  How can I remove it for all my links?
>>>
>>> On Monday, December 30, 2013 8:18:11 PM UTC-5, Anthony wrote:
>>>>
>>>> That's so the link can be temporarily disabled (the text will be 
>>>> replaced with "Working...") when it is used to trigger an Ajax request. 
>>>> However, I don't know why it's included in the anchor tag in all cases -- 
>>>> seems like it would only be needed when the "cid", "component", or 
>>>> "callback" arguments are used.
>>>>
>>>> Anthony
>>>>
>>>> On Monday, December 30, 2013 5:39:53 PM UTC-5, User wrote:
>>>>>
>>>>> Links I build with the anchor A html helper look like:
>>>>>
>>>>> >>>> data-w2p_disable_with="default">Anchor 
>>>>> Text
>>>>>
>>>>> What is the purpose of the data-w2p_disable_with = "default" attribute 
>>>>> and how can I remove it?
>>>>>
>>>>>

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


[web2py] Re: RFC: validator IS_NOT_IN_SET

2014-01-27 Thread User
I think this is a useful validator, any chance this can end up in web2py?

On Friday, August 9, 2013 4:13:30 PM UTC-4, Kyle Flanagan wrote:
>
> I had to use this today. However, this does not work correctly when the 
> set is empty. We assume that if the set is empty, whatever variable value 
> being tested is not in the set.
>
> Here's an updated __call__ function:
>
> def __call__(self, value): 
> value, error = IS_IN_SET.__call__(self, value) 
> # if IS_IN_SET says value was in the set AND the set isn't empty
> # then return an error
> if error == None and len(self.theset) > 0: 
> return (value, self.error_message) 
> else: 
> return (value, None)  
>
>
>
> On Monday, August 23, 2010 9:19:48 AM UTC-5, Vidul Petrov wrote:
>>
>> Hi all, 
>>
>> I needed IS_NOT_IN_SET validator and added it in my custom 
>> "validators.py", do you think it is useful? 
>>
>>
>> class IS_NOT_IN_SET(IS_IN_SET): 
>> """ 
>> example:: 
>>
>> INPUT(_type='text', _name='name', 
>>   requires=IS_NOT_IN_SET(['max', 'john'],zero='')) 
>>
>> the argument of IS_NOT_IN_SET must be a list or set 
>>
>> >>> IS_NOT_IN_SET(['max', 'john'])('max') 
>> ('max', 'value not allowed') 
>> >>> IS_NOT_IN_SET(['max', 'john'])('na') 
>> ('na', None) 
>> >>> IS_NOT_IN_SET(('id1','id2'), ['first label','second 
>> label'])('id100') 
>> ('id100', None) 
>> >>> IS_NOT_IN_SET(('id1','id2'), ['first label','second 
>> label'])('id1') 
>> ('id1', 'value not allowed') 
>> >>> IS_NOT_IN_SET(('id1','id2'), ['first label','second 
>> label'])('id2') 
>> ('id2', 'value not allowed') 
>> >>> IS_NOT_IN_SET({'id1':'first label', 'id2':'second label'}) 
>> ('id100') 
>> ('id100', None) 
>> >>> IS_NOT_IN_SET({'id1':'first label', 'id2':'second label'}) 
>> ('id1') 
>> ('id1', 'value not allowed') 
>> >>> IS_NOT_IN_SET({'id1':'first label', 'id2':'second label'}) 
>> ('id2') 
>> ('id2', 'value not allowed') 
>> >>> import itertools 
>> >>> IS_NOT_IN_SET(itertools.chain(['1','3','5'],['2','4','6'])) 
>> ('100') 
>> ('100', None) 
>> >>> IS_NOT_IN_SET(itertools.chain(['1','3','5'],['2','4','6'])) 
>> ('1') 
>> ('1', 'value not allowed') 
>> >>> IS_NOT_IN_SET(itertools.chain(['1','3','5'],['2','4','6'])) 
>> ('6') 
>> ('6', 'value not allowed') 
>> >>> IS_NOT_IN_SET(itertools.chain(['1','3','5'],['2','4','6'])) 
>> ('7') 
>> ('7', None) 
>> """ 
>>
>> def __init__(self, *a, **b): 
>> IS_IN_SET.__init__(self, *a, **b) 
>>
>> def __call__(self, value): 
>> value, error = IS_IN_SET.__call__(self, value) 
>> if error == None: 
>> return (value, self.error_message) 
>> else: 
>> return (value, None) 
>>
>

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from 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] Getting a 400 bad request instead of 404 for urls with hyphens?

2014-01-27 Thread User
I am trying to get error handling for page not found errors working.  I'm 
using the following example:

http://www.web2pyslices.com/slice/show/1529/custom-error-routing

This seems to be working for URLs such as

www.example.com/asdf
www.example.com/longurlthatdoesnotexit?_next=/

I get my 404 page.

However as soon as I put a hyphen (or dash) in the URL

www.example.com/as-df

I get a 400 BAD REQUEST error and the page just says "invalid request"

How can I fix this so it behaves as expected and returns a 404 error?


-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from 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] Minimum password length not working?

2014-01-27 Thread User
In the web2py book it says:

By default, auth also requires a minimum password length of 4. This can be 
changed:

auth.settings.password_min_length = 4


(from http://www.web2py.com/book/default/chapter/09#Settings-and-messages)

So I tried changing to:

auth.settings.password_min_length = 7


After web2py server restart this still allows registration with a password less

than 7 characters (4 still seems to be the minimum).  What am I missing?


-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from 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] How to change password "Too short" message?

2014-01-28 Thread User
When registering a new user using the default Auth forms, if the password 
entered is too short, an error message "Too short" is displayed.  I would 
like to change this message to something more meaningful such as "Password 
must be at least x characters"

1. How do I do this?
2. Shouldn't the default message be something like this?  Seems not user 
friendly to just say password "Too short" with no indication to the user 
how long a password should be.  Are they just supposed to keep entering 
passwords until they hit whatever arbitrary password length we have set?

Alternatively, is there a way to specify a permanent hint on the form that 
passwords must be x characters?

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from 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] Location of auth.settings statements relative to auth.define_tables?

2014-01-28 Thread User
In the welcome application, all auth.settings statements appear after 
auth.define_tables statement:

## create all tables needed by auth if not custom tables
auth.define_tables(username=False, signature=False)
## configure email
mail = auth.settings.mailer
mail.settings.server = 'logging' or 'smtp.gmail.com:587'
mail.settings.sender = 'y...@gmail.com'
mail.settings.login = 'username:password'
## configure auth policy
auth.settings.registration_requires_verification = False
auth.settings.registration_requires_approval = False
auth.settings.reset_password_requires_verification = True


However, some auth setting statement must occur before auth.define_tables 
in order to take effect (such as auth.settings.password_min_length).  How 
do I know which ones need to come before or after auth.define_tables?  Or 
can/should they all come before auth.define_tables?


-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from 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] Do I need to set auth.settings.hmac_key?

2014-01-28 Thread User
Is best practice to set auth.settings.hmac_key='sha512:somelongpassword'?  
Or is this not necessary?  And if I should do it, does it need to be done 
before auth.define_tables? 

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from 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 change password "Too short" message?

2014-01-28 Thread User
Thanks, issue created: http://code.google.com/p/web2py/issues/detail?id=1863

On Tuesday, January 28, 2014 6:57:35 PM UTC-5, Anthony wrote:
>
> On Tuesday, January 28, 2014 4:46:27 PM UTC-5, User wrote:
>>
>> When registering a new user using the default Auth forms, if the password 
>> entered is too short, an error message "Too short" is displayed.  I would 
>> like to change this message to something more meaningful such as "Password 
>> must be at least x characters"
>>
>> 1. How do I do this?
>>
>
> db.auth_user.password.requires[0].error_message = 'Password must be at 
> least x characters'
>  
>
>> 2. Shouldn't the default message be something like this?  Seems not user 
>> friendly to just say password "Too short" with no indication to the user 
>> how long a password should be.  Are they just supposed to keep entering 
>> passwords until they hit whatever arbitrary password length we have set?
>>
>
> Yes, good idea. Please open an issue on Google Code.
>  
>
>> Alternatively, is there a way to specify a permanent hint on the form 
>> that passwords must be x characters?
>>
>
> It would probably be a good idea to add this by default as well. You can 
> do it manually via:
>
> db.auth_user.password.comment = 'Password must be...'  
>
> Anthony
>

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


[web2py] Blocking/lockout for excessive login attempts?

2014-01-28 Thread User
Does web2py have any ability to block too many login attempts from 
occurring perhaps by locking the user out?  Or showing a captcha after x 
login tries? Or some other feature to mitigate brute force password 
attempts?

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from 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 is the purpose of the ABOUT file in an application?

2014-01-28 Thread User
In the welcome application there is an "ABOUT" file whose contents are:

Write something about this app.
Developed with web2py.

What's the intended purpose of this file and is it protected from end 
users' viewing?  Is this for developers?  

Also is the LICENSE file protected from end user viewing?

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from 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] Pattern-based Application-Specific URL rewrite basic example?

2014-01-28 Thread User


My /routes.py currently has:
# -*- coding: utf-8 -*-



# default_application, default_controller, default_function
# are used when the respective element is missing from the
# (possibly rewritten) incoming URL
#
default_application = 'init'# ordinarily set in base routes.py
default_controller = 'default'  # ordinarily set in app-specific routes.py
default_function = 'index'  # ordinarily set in app-specific routes.py

# routes_app is a tuple of tuples.  The first item in each is a regexp that 
will
# be used to match the incoming request URL. The second item in the tuple is
# an applicationname.  This mechanism allows you to specify the use of an
# app-specific routes.py. This entry is meaningful only in the base 
routes.py.
#
# Example: support welcome, admin, app and myapp, with myapp the default:

routes_app = ((r'/(?Pwelcome|admin|app)\b.*', r'\g'),
  (r'(.*)', r'myapp'),
  (r'/?(.*)', r'myapp'))

...

For a basic example of routing www.example.com/someapp/default/contact to 
www.example.com/contact what needs to go in the /routes.py and 
what needs to go in the /applications/someapp/routes.py?

If I'm using application specific routing does this mean I should leave 
routes_in and routes_out completely alone in /routes.py?

Also for specifying errors, do I use routes_onerror in 
/routes.py or /applications/someapp/routes.py?


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


[web2py] Re: Pattern-based Application-Specific URL rewrite basic example?

2014-01-29 Thread User
Happy to say this is now working.  One thing I was wondering is if the 
application specific url rewriting could route at the root level or not 
(e.g. route www.example.com/someapp/default/contat to 
www.example.com/contact) or if it was limited to having an app prefix (e.g. 
only route www.example.com/someapp/default/contact to 
www.example.com/someapp/contact).  Well I can confirm that it does not need 
an app prefix.

Here's what I put in /routes.py assuming my app's name is 
"someapp":

# -*- coding: utf-8 -*-
# default_application, default_controller, default_function
# are used when the respective element is missing from the
# (possibly rewritten) incoming URL
#
default_application = 'someapp'# ordinarily set in base routes.py
default_controller = 'default'  # ordinarily set in app-specific routes.py
default_function = 'index'  # ordinarily set in app-specific routes.py
# routes_app is a tuple of tuples.  The first item in each is a regexp that 
will
# be used to match the incoming request URL. The second item in the tuple is
# an applicationname.  This mechanism allows you to specify the use of an
# app-specific routes.py. This entry is meaningful only in the base 
routes.py.
#
# Example: support welcome, admin, app and myapp, with myapp the default:

routes_app = ((r'/(?Pwelcome|admin|app|someapp)\b.*', r'\g'),
  (r'(.*)', r'someapp'),
  (r'/?(.*)', r'someapp'))


other than that I left routes_in and routes_out alone.

Then in my /applications/someapp/routes.py I put:

default_controller = 'default'  # ordinarily set in app-specific routes.py
default_function = 'index'  # ordinarily set in app-specific routes.py

BASE = ''  # optonal prefix for incoming URLs

routes_in = (
('/(?Pabout|contact)', r'/someapp/default/\g'),
# remove the BASE prefix
(BASE + '/$anything', '/$anything'),
)
routes_out = (
(r'/$app/default/index', '/'),
(r'/$app/default/$anything', '/$anything'),
# restore the BASE prefix
('/$anything', BASE + '/$anything'),
)
routes_onerror = [
(r'*/*', r'/someapp/default/handle_error')
]


Not yet sure if the BASE stuff is necessary.  Also can confirm error 
routing works in the app specific routes.py with no error routes specified 
in the main routing file.

Note when I tried using the $app variable in routes_in as shown below it 
seemed to give a Rocket error

routes_in = (
('/(?Pabout|contact)', r'/$app/default/\g'),
# remove the BASE prefix
(BASE + '/$anything', '/$anything'),
)


I prefer the app specific routing because it makes it easy to version 
control your app's routes with your app's repository.

On Tuesday, January 28, 2014 11:25:07 PM UTC-5, User wrote:

> My /routes.py currently has:
> # -*- coding: utf-8 -*-
>
>
>
> # default_application, default_controller, default_function
> # are used when the respective element is missing from the
> # (possibly rewritten) incoming URL
> #
> default_application = 'init'# ordinarily set in base routes.py
> default_controller = 'default'  # ordinarily set in app-specific routes.py
> default_function = 'index'  # ordinarily set in app-specific routes.py
>
> # routes_app is a tuple of tuples.  The first item in each is a regexp 
> that will
> # be used to match the incoming request URL. The second item in the tuple 
> is
> # an applicationname.  This mechanism allows you to specify the use of an
> # app-specific routes.py. This entry is meaningful only in the base 
> routes.py.
> #
> # Example: support welcome, admin, app and myapp, with myapp the default:
>
> routes_app = ((r'/(?Pwelcome|admin|app)\b.*', r'\g'),
>   (r'(.*)', r'myapp'),
>   (r'/?(.*)', r'myapp'))
>
> ...
>
> For a basic example of routing www.example.com/someapp/default/contact to 
> www.example.com/contact what needs to go in the /routes.py 
> and what needs to go in the /applications/someapp/routes.py?
>
> If I'm using application specific routing does this mean I should leave 
> routes_in and routes_out completely alone in /routes.py?
>
> Also for specifying errors, do I use routes_onerror in 
> /routes.py or /applications/someapp/routes.py?
>
>
>

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


[web2py] Re: Do I need to set auth.settings.hmac_key?

2014-01-30 Thread User
Ok I was confused because the books says (
http://www.web2py.com/book/default/chapter/09#Settings-and-messages)

The following is a very important setting:

auth.settings.hmac_key = None

It must be set to something like "sha512:a-pass-phrase" and it will be 
passed to the CRYPT validator for the "password" field of the auth_usertable. 
It will be the algorithm and a-pass-phrase used to hash the 
passwords.

Do you think the book should be modified to reflect that this is 
automatically done already?
 
I see in a different section it says:

The password field of the db.auth_user table defaults to a CRYPT validator, 
which needs and hmac_key. On legacy web2py applications you may see an 
extra argument passed to the Auth constructor: hmac_key = 
Auth.get_or_create_key(). The latter is a function that read the HMAC key 
from a file "private/auth.key" within the application folder. If the file 
does not exist it creates a random hmac_key. If multiple apps share the 
same auth database, make sure they also use the same hmac_key. This is no 
longer necessary for new applications since passwords are salted with an 
individual random salt.

But it wasn't clear to me whether I should set it or not as the two 
sections kind of go against each other.
 
On Thursday, January 30, 2014 8:42:37 AM UTC-5, Massimo Di Pierro wrote:

> This is really not necessary since we automatically salt and hash all 
> passwords.
>  
> On Tuesday, 28 January 2014 17:04:37 UTC-6, User wrote:
>
>> Is best practice to set 
>> auth.settings.hmac_key='sha512:somelongpassword'?  Or is this not 
>> necessary?  And if I should do it, does it need to be done before 
>> auth.define_tables? 
>>
>

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from 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] request.is_local not working?

2014-01-30 Thread User
I'm using web2py on webfaction and as far as I can tell request.is_local is 
not working.  I have a page that uses the generic.html view which has the 
following lines:

{{if request.is_local:}}
{{=response.toolbar()}}
{{pass}}

The web2py book says:

request.is_local: True if the client is localhost, False otherwise. Should 
work behind a proxy if the proxy supports http_x_forwarded_for.

Yet it still shows the toolbar when viewing my hosted site. Using the 
toolbar I can see that HTTP_X_FORWARDED_FOR is set to my personal computer 
ip address.  Any ideas why this doesn't work?

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from 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: Do I need to set auth.settings.hmac_key?

2014-01-31 Thread User
Should I create an issue for changes to the book? Or do you already have it 
notated?

On Friday, January 31, 2014 12:55:51 PM UTC-5, Massimo Di Pierro wrote:
>
> It should be modified.
>
>
> On Thursday, 30 January 2014 11:35:08 UTC-6, User wrote:
>>
>> Ok I was confused because the books says (
>> http://www.web2py.com/book/default/chapter/09#Settings-and-messages)
>>
>> The following is a very important setting:
>>
>> auth.settings.hmac_key = None
>>
>> It must be set to something like "sha512:a-pass-phrase" and it will be 
>> passed to the CRYPT validator for the "password" field of the 
>> auth_usertable. It will be the algorithm and a-pass-phrase used to hash the 
>> passwords.
>>
>> Do you think the book should be modified to reflect that this is 
>> automatically done already?
>>  
>> I see in a different section it says:
>>
>> The password field of the db.auth_user table defaults to a CRYPTvalidator, 
>> which needs and 
>> hmac_key. On legacy web2py applications you may see an extra argument 
>> passed to the Auth constructor: hmac_key = Auth.get_or_create_key(). The 
>> latter is a function that read the HMAC key from a file "private/auth.key" 
>> within the application folder. If the file does not exist it creates a 
>> random hmac_key. If multiple apps share the same auth database, make 
>> sure they also use the same hmac_key. This is no longer necessary for 
>> new applications since passwords are salted with an individual random salt.
>>
>> But it wasn't clear to me whether I should set it or not as the two 
>> sections kind of go against each other.
>>  
>> On Thursday, January 30, 2014 8:42:37 AM UTC-5, Massimo Di Pierro wrote:
>>
>>> This is really not necessary since we automatically salt and hash all 
>>> passwords.
>>>  
>>> On Tuesday, 28 January 2014 17:04:37 UTC-6, User wrote:
>>>
>>>> Is best practice to set 
>>>> auth.settings.hmac_key='sha512:somelongpassword'?  Or is this not 
>>>> necessary?  And if I should do it, does it need to be done before 
>>>> auth.define_tables? 
>>>>
>>>

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from 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] Can I specify a display name in emails sent via auth.settings.mailer?

2014-02-05 Thread User
I would like the from address of automated emails for user registration, 
retrieve password, etc to have a display name.  How can I do this?

Currently my mailer is defined similar to:

mail = auth.settings.mailer
mail.settings.server = 'logging' or 'smtp.gmail.com:587'
mail.settings.sender = 'i...@example.com'

Can I do something like this?

mail.settings.sender = 'Company Name 
'<'companyi...@example.com'>

I saw this related post: 
https://groups.google.com/forum/#!topic/web2py/GCY_jQusDKk but that is only 
discussing the mail.send() method I believe

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from 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] possible bug with IS_TIME() midnight in 12 hour format?

2014-02-10 Thread User
I have an input field on a form where users can enter a time in 12-hour 
format.  Entering 12:00AM on this form seems to be getting interpreted as 
12PM (debugging I can see the python time object is datetime.time(12, 0).  
Calling the validator directly in the web2py shell gives:

rtn = IS_TIME()('12:00 am')
(datetime.time(12, 0), None)

Is this a bug?  Shouldn't it return datetime.time(0, 0)?

Also, seems a little odd that there are no test cases for midnight or 
noon in def test_IS_TIME(self)

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from 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: possible bug with IS_TIME() midnight in 12 hour format?

2014-02-11 Thread User
Thanks, also seems like there should be the following test cases 
in \web2py\gluon\tests\test_validators.py def test_IS_TIME(self):

rtn = IS_TIME()('12:00 am')
self.assertEqual(rtn, (datetime.time(0, 0), None))

rtn = IS_TIME()('12:01 am')
self.assertEqual(rtn, (datetime.time(0, 1), None))

rtn = IS_TIME()('12:00 pm')
self.assertEqual(rtn, (datetime.time(12, 0), None))





On Tuesday, February 11, 2014 9:10:51 AM UTC-5, Massimo Di Pierro wrote:

> You are right. Now fixed in trunk.
>
> On Tuesday, 11 February 2014 01:57:25 UTC-6, User wrote:
>>
>> I have an input field on a form where users can enter a time in 12-hour 
>> format.  Entering 12:00AM on this form seems to be getting interpreted as 
>> 12PM (debugging I can see the python time object is datetime.time(12, 0).  
>> Calling the validator directly in the web2py shell gives:
>>
>> rtn = IS_TIME()('12:00 am')
>> (datetime.time(12, 0), None)
>>
>> Is this a bug?  Shouldn't it return datetime.time(0, 0)?
>>
>> Also, seems a little odd that there are no test cases for midnight or 
>> noon in def test_IS_TIME(self)
>>
>

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from 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: web2py scheduler

2014-02-11 Thread User
You could try adding standard python logging statements to try to figure 
out what's happening.

Edit /logging.conf and add an entry for your app following the 
instructions in the file.  Then in scheduler.py:

import logging

def your_scheduled_function():
logger = logging.getLogger('web2py.app.your_app')
logger.debug('BEGIN: your_scheduled_function')
...



Then check /logs folder for the log output

On Tuesday, February 11, 2014 5:06:21 AM UTC-5, Jayadevan M wrote:

> How can I debug a scheduler task that goes into RUNNING status and never 
> changes to any other status? The same function, when called from web2py in 
> shell mode, does what it is expected to do and exits normally.
>

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from 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: possible bug with IS_TIME() midnight in 12 hour format?

2014-02-11 Thread User
Possibly, I have never contributed to an open source project so I don't 
know what's involved.  Are there instructions somewhere?

On Tuesday, February 11, 2014 11:21:15 AM UTC-5, Massimo Di Pierro wrote:
>
> I agree. Can you submit a patch?
>
> On Tuesday, 11 February 2014 09:33:40 UTC-6, User wrote:
>>
>> Thanks, also seems like there should be the following test cases 
>> in \web2py\gluon\tests\test_validators.py def test_IS_TIME(self):
>>
>> rtn = IS_TIME()('12:00 am')
>> self.assertEqual(rtn, (datetime.time(0, 0), None))
>>
>> rtn = IS_TIME()('12:01 am')
>> self.assertEqual(rtn, (datetime.time(0, 1), None))
>>
>> rtn = IS_TIME()('12:00 pm')
>> self.assertEqual(rtn, (datetime.time(12, 0), None))
>>
>>
>>
>>
>>
>> On Tuesday, February 11, 2014 9:10:51 AM UTC-5, Massimo Di Pierro wrote:
>>
>>> You are right. Now fixed in trunk.
>>>
>>> On Tuesday, 11 February 2014 01:57:25 UTC-6, User wrote:
>>>>
>>>> I have an input field on a form where users can enter a time in 12-hour 
>>>> format.  Entering 12:00AM on this form seems to be getting interpreted as 
>>>> 12PM (debugging I can see the python time object is datetime.time(12, 0).  
>>>> Calling the validator directly in the web2py shell gives:
>>>>
>>>> rtn = IS_TIME()('12:00 am')
>>>> (datetime.time(12, 0), None)
>>>>
>>>> Is this a bug?  Shouldn't it return datetime.time(0, 0)?
>>>>
>>>> Also, seems a little odd that there are no test cases for midnight or 
>>>> noon in def test_IS_TIME(self)
>>>>
>>>

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from 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: possible bug with IS_TIME() midnight in 12 hour format?

2014-02-11 Thread User
Can this be done with Mercurial?

On Tuesday, February 11, 2014 11:36:41 AM UTC-5, Anthony wrote:
>
>
> http://web2py.com/books/default/chapter/29/15/helping-web2py#Contributing-code-and-documentation-changes
> .
>
> But if that's too much for now, you can also email a patch file to Massimo.
>
> Anthony
>
> On Tuesday, February 11, 2014 11:31:16 AM UTC-5, User wrote:
>>
>> Possibly, I have never contributed to an open source project so I don't 
>> know what's involved.  Are there instructions somewhere?
>>
>> On Tuesday, February 11, 2014 11:21:15 AM UTC-5, Massimo Di Pierro wrote:
>>>
>>> I agree. Can you submit a patch?
>>>
>>> On Tuesday, 11 February 2014 09:33:40 UTC-6, User wrote:
>>>>
>>>> Thanks, also seems like there should be the following test cases 
>>>> in \web2py\gluon\tests\test_validators.py def test_IS_TIME(self):
>>>>
>>>> rtn = IS_TIME()('12:00 am')
>>>> self.assertEqual(rtn, (datetime.time(0, 0), None))
>>>>
>>>> rtn = IS_TIME()('12:01 am')
>>>> self.assertEqual(rtn, (datetime.time(0, 1), None))
>>>>
>>>> rtn = IS_TIME()('12:00 pm')
>>>> self.assertEqual(rtn, (datetime.time(12, 0), None))
>>>>
>>>>
>>>>
>>>>
>>>>
>>>> On Tuesday, February 11, 2014 9:10:51 AM UTC-5, Massimo Di Pierro wrote:
>>>>
>>>>> You are right. Now fixed in trunk.
>>>>>
>>>>> On Tuesday, 11 February 2014 01:57:25 UTC-6, User wrote:
>>>>>>
>>>>>> I have an input field on a form where users can enter a time in 
>>>>>> 12-hour format.  Entering 12:00AM on this form seems to be getting 
>>>>>> interpreted as 12PM (debugging I can see the python time object is 
>>>>>> datetime.time(12, 0).  Calling the validator directly in the web2py 
>>>>>> shell 
>>>>>> gives:
>>>>>>
>>>>>> rtn = IS_TIME()('12:00 am')
>>>>>> (datetime.time(12, 0), None)
>>>>>>
>>>>>> Is this a bug?  Shouldn't it return datetime.time(0, 0)?
>>>>>>
>>>>>> Also, seems a little odd that there are no test cases for midnight or 
>>>>>> noon in def test_IS_TIME(self)
>>>>>>
>>>>>

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from 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] How can I show response.flash messages with different styles?

2014-02-12 Thread User
I am using bootstrap 2.3.2 and I would like to use Bootstrap css alert 
classes to style response.flash.  These include:
alert
alert-error
alert-success
alert-info

Is there an easy way to specify the type of flash from the controller? 
I'm thinking I could do something like:

response.flash_style = 'alert-success'


and then:

 {{if response.flash:}}
   
   ×
   {{=response.flash}}
   
 {{pass}}  



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


[web2py] Re: How can I show response.flash messages with different styles?

2014-02-12 Thread User
It works, just looking for best practices.  Curious if anyone had anything 
really slick.  Not too crazy about adding on the fly attribute to response 
object, but perhaps a slightly more mangled name would make me more 
comfortable with that (Although chance of collision seems pretty small and 
if it were to happen would be easy enough to change)

On Wednesday, February 12, 2014 9:36:58 PM UTC-5, Anthony wrote:
>
> Does your solution below not work?
>
> On Wednesday, February 12, 2014 8:54:46 PM UTC-5, User wrote:
>>
>> I am using bootstrap 2.3.2 and I would like to use Bootstrap css alert 
>> classes to style response.flash.  These include:
>> alert
>> alert-error
>> alert-success
>> alert-info
>>
>> Is there an easy way to specify the type of flash from the controller? 
>> I'm thinking I could do something like:
>>
>> response.flash_style = 'alert-success'
>>
>>
>> and then:
>>
>>  {{if response.flash:}}
>>
>>×> button>
>>{{=response.flash}}
>>
>>  {{pass}}  
>>
>>
>>
>>

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


[web2py] Re: How can I show response.flash messages with different styles?

2014-02-13 Thread User
I like this, but will it play nicely with built-in flash messages?  Seems 
like if you get a web2py built in flash message (e.g. "logged in","logged 
out") it will come out with no styling since the styling is now in the 
function rather than the layout?  Although there aren't so many built-in 
messages that you couldn't override them so probably not that big of an 
issue.

On Wednesday, February 12, 2014 10:13:03 PM UTC-5, Anthony wrote:
>
> On Wednesday, February 12, 2014 9:48:34 PM UTC-5, Cliff Kachinske wrote:
>>
>> response.flash = SPAN('flash message goes here', _class='whatever')
>>
>
> And since this case involves a div and a button, to avoid having to repeat 
> all that every time, just write a function that takes a message and a flash 
> type and generates the appropriate helper object:
>
> def flash(message, type='info'):
> return DIV(BUTTON(XML('×'), _type='button', _class='close', data
> =dict(dismiss='alert')),
>message, class='alert alert-%s' % type)
>
> response.flash = flash('You did it!', 'success')
>
> Anthony
>
>  
>
>> On Wednesday, February 12, 2014 8:54:46 PM UTC-5, User wrote:
>>>
>>> I am using bootstrap 2.3.2 and I would like to use Bootstrap css alert 
>>> classes to style response.flash.  These include:
>>> alert
>>> alert-error
>>> alert-success
>>> alert-info
>>>
>>> Is there an easy way to specify the type of flash from the controller? 
>>> I'm thinking I could do something like:
>>>
>>> response.flash_style = 'alert-success'
>>>
>>>
>>> and then:
>>>
>>>  {{if response.flash:}}
>>>
>>>×
>>> ;
>>>{{=response.flash}}
>>>
>>>  {{pass}}  
>>>
>>>
>>>
>>>

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


[web2py] Recording failed login attempts in database via login_onfail?

2014-02-13 Thread User
I want to record the number of failed login attempts in db.auth_user.  I've 
added an extra field:

auth.settings.extra_fields['auth_user'] = [
Field('failed_login_attempts','integer', default=0),


My thought was to capture increment this number in login_onfail.  However, 
how can I find out which user failed the login from this function handler?  
As far as I can see it doesn't take the login form as an argument like 
onaccept.  Or if that is not possible where in the chain of events can I 
increment this count on a failed login?

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from 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] ReCaptcha: setting key 'login_catpcha' does not exist?

2014-02-14 Thread User
I want to add a captcha to my login form.  Eventually I want this to be 
conditional based on how many login attemps have been made.  However, my 
first step is to get it to show on the login form. In my default.py 
controller I have:

def user():
function = request.args(0)
if function == 'register':
# ...
elif function == 'login':
#import ipdb; ipdb.set_trace()
auth.settings.login_onfail = login_failed
from gluon.tools import Recaptcha
public_key = 'xyz'
private_key = 'xyz'
auth.settings.login_catpcha = Recaptcha(request, public_key,private_key
) 
form = auth.login()

return dict(form=form)




When I visit the page I get:


 setting key 'login_catpcha' does not exist

Commenting out offending line and the code works (albeit without a captcha) 
Any ideas on what's going wrong here?

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from 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: ReCaptcha: setting key 'login_catpcha' does not exist?

2014-02-14 Thread User
good catch it's working now

On Friday, February 14, 2014 11:06:39 PM UTC-5, Massimo Di Pierro wrote:
>
> auth.settings.login_catpcha = Recaptcha(request, public_key, private_key) 
>
> should be
>
> auth.settings.login_captcha = Recaptcha(request, public_key, private_key) 
>
> On Friday, 14 February 2014 11:31:57 UTC-6, User wrote:
>>
>> I want to add a captcha to my login form.  Eventually I want this to be 
>> conditional based on how many login attemps have been made.  However, my 
>> first step is to get it to show on the login form. In my default.py 
>> controller I have:
>>
>> def user():
>> function = request.args(0)
>> if function == 'register':
>> # ...
>> elif function == 'login':
>> #import ipdb; ipdb.set_trace()
>> auth.settings.login_onfail = login_failed
>> from gluon.tools import Recaptcha
>> public_key = 'xyz'
>> private_key = 'xyz'
>> auth.settings.login_catpcha = Recaptcha(request, 
>> public_key,private_key
>> ) 
>> form = auth.login()
>>
>> return dict(form=form)
>>
>>
>>
>>
>> When I visit the page I get:
>>
>>
>>  setting key 'login_catpcha' does not exist
>>
>> Commenting out offending line and the code works (albeit without a 
>> captcha) Any ideas on what's going wrong here?
>>
>

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from 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] How can I run postgresql VACUUM from web2py?

2014-02-17 Thread User
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.


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.


[web2py] How can I restrict an input field to latin alphabet characters only?

2014-02-19 Thread User
How can I restrict an input field to (extended) latin alphabet characters 
only?  I'm thinking a validator that will return an error message if 
characters are not extended Latin characters

Basically I want to allow:
Zürich or Cancún

but reject:
上海市
or
دبي

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


[web2py] Re: Version Control advice

2014-02-19 Thread User
I also agree with separate repositories per app.

My web2py folder is a mercurial repository (I cloned the web2py repository 
http://code.google.com/p/web2py/source/checkout) Then for each application 
I want to make, I create a new repository for that application in the 
web2py/applications folder.  So you end up with a nested repository 
structure but they actually play nicely and don't interfere with each other 
(thanks to the ignore files)

This way I can update web2py as needed to get new versions or bug fixes.  
And my applications are in separate repositories because they really have 
nothing to do with web2py core.

On Wednesday, February 19, 2014 6:00:37 AM UTC-5, Tim Richardson wrote:

> Well, I'm not very sophisticated but I have separate git repositories per 
> app, I can't any advantages in having one repository for everything.
>
> On Wednesday, 19 February 2014 12:13:13 UTC+11, Carlos Zenteno wrote:
>>
>> 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.


[web2py] Re: How can I restrict an input field to latin alphabet characters only?

2014-02-20 Thread User
I agree the IS_MATCH could work but what is the regex that you would use?

On Thursday, February 20, 2014 9:06:23 AM UTC-5, Leonel Câmara wrote:
>
> I'm guessing you can use IS_MATCH.
>
> Another alternative, you could make a validator that would try and encode 
> a unicode version of the text you're validating to iso-8859-15 or something 
> and see if you don't get any exceptions. 
>

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from 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] Use custom XML TAG to generate void or self-closing tags?

2014-02-21 Thread User
How can I generate a self-closing tag (
http://dev.w3.org/html5/html-author/#start-tag) or void element using the 
TAG helper?

For example, in the header I want to generate:

http://example.com/article?pg=2";>


or

http://example.com/article?pg=2"/>


However using TAG.link(_rel='next', 
_href='http://example.com/article?pg=2') generates:

http://example.com/article?pg=2";>




-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from 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: Use custom XML TAG to generate void or self-closing tags?

2014-02-21 Thread User
Out of curiosity is the HTML syntax for void elements possible (i.e. start 
tag only) with a helper?

e.g.
http://example.com/article?pg=2";>



On Friday, February 21, 2014 5:37:57 PM UTC-5, Anthony wrote:

> TAG['link/'](_href=...)
>
> To generate a self-closing tag, the tag name must end with a "/", so to do 
> that, you need to use the TAG["tagname"] syntax instead of TAG.tagname.
>
> Anthony
>
> On Friday, February 21, 2014 4:43:08 PM UTC-5, User wrote:
>>
>> How can I generate a self-closing tag (
>> http://dev.w3.org/html5/html-author/#start-tag) or void element using 
>> the TAG helper?
>>
>> For example, in the header I want to generate:
>>
>> http://example.com/article?pg=2";>
>>
>>
>> or
>>
>> http://example.com/article?pg=2"/>
>>
>>
>> However using TAG.link(_rel='next', _href='
>> http://example.com/article?pg=2') generates:
>>
>> http://example.com/article?pg=2";>
>>
>>
>>
>>
>>

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from 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] Date display i18n internationalization?

2014-02-23 Thread User
I have some dates that I want to display in the proper culture specific 
format.  I want a simple solution so what I want is rather than me having 
to specify the date format for every possible culture is to use the 
following default:

dd-mm-

and then specify a handful of exceptions, e.g. for United States:

mm-dd- 

How can I achieve this in web2py where it's switched based on the 
Accept-Language header?


-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from 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.


  1   2   >