[web2py] Re: web2py received 2011 BOSSIE Award by InfoWorld.com

2011-09-10 Thread GoldenTiger
In this community there's a rumor that he is a cyborg.
Take a look at posts stats:

17918   mdipierro
 2324   Massimo Di Pierro
 2116   Yarko
 1814   thade...@thadeusb.com
 1776   Jonathan Lundell
 1461   DenesL
 1454   rochacbruno
 1401   Anthony
 1311   pbreit
 1104   nat...@freezable.com

On 10 sep, 22:46, António Ramos  wrote:
>  hey,
> we are here all fascinated about web2py and i was thinking ,
>
> who is Massimo as a man in the society, among friends, does he drive a
> Ferrary or a fiat 500?
>
> Does he eat meat or is a vegetarian. Is he good at other stuff or was just
> born to bring us web2py ?
> What are his projects in the future. How does he sees Web2py in 5 years?
>
> Let me be curious about a guy that created such a powerfull and funny tool.
>
> I envy you :)
>
> Let me suggest to you all
>
> Stop programming and give Massimo an Applause  for making the clock ticking
>
> +
>
> 2011/9/9 mikech > Congratulations!  Hey DePaul you just 
> got some PR from one of your esteemed
> > faculty!


Re: [web2py] Re: uWSGI 0.9.9

2011-09-10 Thread Vasile Ermicioi
the one that works with 0.9.8.5

uwsgi --protocol http --socket 127.0.0.1: --pythonpath
/home/myusername/web2py --module wsgihandler -d
/home/myusername/tmp/uwsgi.log -t 20 --async 24 --ugreen --limit-as 64 -r
--no-orphans -M -p 1 --touch-reload /home/myusername/tmp/uwsgireload.txt
--reload-on-rss 50

the one that works with 0.9.9.1 but exits on touch (to reload) and
dispatches 2 child processes instead of one

uwsgi --http 127.0.0.1: --pythonpath /home/myusername/web2py --module
wsgihandler -d /home/myusername/tmp/uwsgi.log -t 20 --async 12 --ugreen
--limit-as 36 -r --no-orphans -M -p 1 --touch-reload
/home/myusername/tmp/uwsgireload.txt --reload-on-rss 50


Re: [web2py] Re: uWSGI 0.9.9

2011-09-10 Thread Roberto De Ioris

> hi Roberto,
> This version seems to be backward incompatible:
>
> --protocol http --socket 127.0.0.1: doesn't seems to work for me
>
> and using uwsgi --http 127.0.0.1: with --touch-reload makes uwsgi
> to exit completely (no uwsgi processes after touching the file )
>

Hi, can you post the whole command line ?

-- 
Roberto De Ioris
http://unbit.it


[web2py] Español != Español

2011-09-10 Thread weheh
My controller says this just before returning:

response.flash='Español'


Chrome flashes Español
Firefox flashes Español
IE flashes Español

All browsers are set to UTF-8 encoding. The same web2py code is
running in all cases. I'm on Windows 7. I'm using Eclipse -- all
encodings set to UTF-8 from top to bottom.

What the $(*&^!@$# could be going wrong here?


[web2py] Re: Computing a field from the value of another field

2011-09-10 Thread pbreit
Good point.

[web2py] Re: Computing a field from the value of another field

2011-09-10 Thread Massimo Di Pierro
I do this.


auth.settings.extra_fields['auth_user'] =
[Field('city'),Field('country')]

def lola(form):
if form.vars.institution_country:
form.vars.longitude, form.vars.latitude = geocode("%s %s" %
(form.vars.city, form.vars.country))

auth.settings.register_onvalidation=lola
auth.settings.profile_onvalidation=lola

On Sep 10, 9:01 pm, Anthony  wrote:
> On Saturday, September 10, 2011 9:35:17 PM UTC-4, pbreit wrote:
>
> > Maybe even a computed field?
> >http://web2py.com/book/default/chapter/06#Computed-Fields
>
> Yes, I suppose that's not a bad idea, though in this case, I guess that
> would require calling the geocoding function twice -- once for the lon field
> and once for the lat field (since each field will need its own compute
> function). Since the function involves a call to Google's servers, that may
> introduce more delay than you want (though perhaps the function could cache
> the longitude and latitude, so when the second field's compute function is
> called, it fetches from the cache instead of hitting Google again).
>
> Anthony


[web2py] Re: Computing a field from the value of another field

2011-09-10 Thread Anthony
On Saturday, September 10, 2011 9:35:17 PM UTC-4, pbreit wrote:
>
> Maybe even a computed field?
> http://web2py.com/book/default/chapter/06#Computed-Fields
>

Yes, I suppose that's not a bad idea, though in this case, I guess that 
would require calling the geocoding function twice -- once for the lon field 
and once for the lat field (since each field will need its own compute 
function). Since the function involves a call to Google's servers, that may 
introduce more delay than you want (though perhaps the function could cache 
the longitude and latitude, so when the second field's compute function is 
called, it fetches from the cache instead of hitting Google again).

Anthony


[web2py] Re: what other tools do you use with web2py

2011-09-10 Thread pbreit
CoffeeScript supposedly makes JavaScript more pleasant. Same for LESS and 
SASS for CSS. I haven't used any of them.

[web2py] Re: Computing a field from the value of another field

2011-09-10 Thread pbreit
Maybe even a computed field?
http://web2py.com/book/default/chapter/06#Computed-Fields

You might want to store the postcode and check it to see if the new one is 
different before geocoding it.


[web2py] Re: has anyone done web2py + google maps?

2011-09-10 Thread niknok
Thank you all for the responses and links. They are very good models
to learn from.

Has anyone done something similar to crimereports.com or haybol.ph?

On Sep 11, 7:09 am, Christopher Steel  wrote:
> You might want to check out Public Radio Roadtrip an application done (in
> progress?) by John Tynan. It was still slightly rough around the edges the
> last time I tried it out but was looking really interesting and was
> exploring some really interesting ideas.
>
> *Public Radio Roadtrip*
>
> GAE test site
>
> http://publicradioroadtrip.appspot.com/publicradioroadtrip
>
> Get the Code here
>
> http://code.google.com/p/publicradioroadtrip/
>
> John's Blog
>
> http://p2pu.org/en/johntynan/
>
> John also did an application for public radio funding campaigns...


[web2py] Re: Ajax Call -Determining which button was pressed

2011-09-10 Thread Anthony
It's up to you how you trigger/call the ajax() function -- if you want to 
call it when a button is clicked, then add the call to the button's onclick 
attribute. You don't have to  specify any field -- just use [] for the 
second argument.

Anthony

On Saturday, September 10, 2011 6:45:08 PM UTC-4, Ramos wrote:
>
> Hello,
>
> the ajax function  example in the web2py book
>
> ajax('{{=URL('new_post')}}',['your_message'], 'target');
>
> sends the value of the field *your_message* to the controller function
>
> I dont want to send the value of a field but a button onclick action 
>
> My webpage can have 2,4 10 or 20 buttons. It depends . And each time i 
> press a button i need to call the ajax function to process that button
>
> can the ajax function process a button instead of a text field?
>
>
> Thank you
>
>

Re: [web2py] Re: Computing a field from the value of another field

2011-09-10 Thread Anthony
On Saturday, September 10, 2011 6:51:51 PM UTC-4, leftcase wrote:
>
> Cool, Thanks Anthony!
>
> Does the onvalidation option have benefits over and above the way I've done 
> it.
>
I guess it's a bit simpler because it still allows form.accepts() to handle 
the DB insert, so you don't have to do it manually.

Anthony 


[web2py] Re: Ajax Call -Determining which button was pressed

2011-09-10 Thread Massimo Di Pierro
I do not understand. If you want to call an action, get the output and
then send it via ajax you can do


click me


On Sep 10, 5:45 pm, António Ramos  wrote:
> Hello,
>
> the ajax function  example in the web2py book
>
> ajax('{{=URL('new_post')}}',['your_message'], 'target');
>
> sends the value of the field *your_message* to the controller function
>
> I dont want to send the value of a field but a button onclick action
>
> My webpage can have 2,4 10 or 20 buttons. It depends . And each time i press
> a button i need to call the ajax function to process that button
>
> can the ajax function process a button instead of a text field?
>
> Thank you


[web2py] Re: has anyone done web2py + google maps?

2011-09-10 Thread Christopher Steel
You might want to check out Public Radio Roadtrip an application done (in 
progress?) by John Tynan. It was still slightly rough around the edges the 
last time I tried it out but was looking really interesting and was 
exploring some really interesting ideas.

*Public Radio Roadtrip*

GAE test site

http://publicradioroadtrip.appspot.com/publicradioroadtrip

Get the Code here

http://code.google.com/p/publicradioroadtrip/

John's Blog

http://p2pu.org/en/johntynan/

John also did an application for public radio funding campaigns...


Re: [web2py] Re: Computing a field from the value of another field

2011-09-10 Thread Chris Rowson
Cool, Thanks Anthony!

Does the onvalidation option have benefits over and above the way I've done it?

Chris

> Another option might be using an onvalidation function:
> http://web2py.com/book/default/chapter/07#onvalidation
> Anthony
>
> On Saturday, September 10, 2011 4:37:08 PM UTC-4, leftcase wrote:
>>
>> Hi there,
>>
>> I bought the web2py .pdf, and have been reading it, but I'm struggling
>> a little bit with:
>>
>> http://www.web2py.com/book/default/chapter/07#SQLFORM
>>
>> Specifically the section "SQLFORM without database IO"
>>
>> I have 2 fields, lon & lat I'd like to calculated from a postcode and
>> enter into the database. I want this to happen automatically, I don't
>> want the user to see them in the form.
>>
>> As you can see below, I've done this by setting dbio=False, computing
>> the fields from the postcode value then adding them to the forms.var
>> dict before submitting it all together. Is this a rational way to
>> accomplish my requirements?
>>
>> Thanks in advance!
>>
>> Chris
>>
>> def adddata():
>>     form=SQLFORM(db.data, fields=['provider', 'speed', 'postcode',
>> 'ping'])
>>     if form.accepts(request.vars, session, dbio=False): #<-- dbio
>> false means it doesn't submit till we ask it to
>>        geocoded=__geocode(form.vars.postcode) #<-- so compute the other
>> fields
>>        #add some computed values to the form.vars dictionary for
>> submission
>>        form.vars['lon']=geocoded['lon']
>>        form.vars['lat']=geocoded['lat']
>>        #and insert the data into the database
>>        db.data.insert(**dict(form.vars))
>>        #response.flash puts the flash in this page, session.flash in
>> the next page of the session
>>        session.flash = 'form accepted'
>>        redirect(URL(r=request, f='index'))
>>     elif form.errors:
>>        response.flash = 'form has errors'
>>     return dict(form=form)
>


[web2py] Ajax Call -Determining which button was pressed

2011-09-10 Thread António Ramos
Hello,

the ajax function  example in the web2py book

ajax('{{=URL('new_post')}}',['your_message'], 'target');

sends the value of the field *your_message* to the controller function

I dont want to send the value of a field but a button onclick action

My webpage can have 2,4 10 or 20 buttons. It depends . And each time i press
a button i need to call the ajax function to process that button

can the ajax function process a button instead of a text field?


Thank you


[web2py] Re: Computing a field from the value of another field

2011-09-10 Thread Anthony
Another option might be using an onvalidation function: 
http://web2py.com/book/default/chapter/07#onvalidation

Anthony

On Saturday, September 10, 2011 4:37:08 PM UTC-4, leftcase wrote:
>
> Hi there,
>
> I bought the web2py .pdf, and have been reading it, but I'm struggling
> a little bit with:
>
> http://www.web2py.com/book/default/chapter/07#SQLFORM
>
> Specifically the section "SQLFORM without database IO"
>
> I have 2 fields, lon & lat I'd like to calculated from a postcode and
> enter into the database. I want this to happen automatically, I don't
> want the user to see them in the form.
>
> As you can see below, I've done this by setting dbio=False, computing
> the fields from the postcode value then adding them to the forms.var
> dict before submitting it all together. Is this a rational way to
> accomplish my requirements?
>
> Thanks in advance!
>
> Chris
>
> def adddata():
> form=SQLFORM(db.data, fields=['provider', 'speed', 'postcode', 'ping'])
> if form.accepts(request.vars, session, dbio=False): #<-- dbio
> false means it doesn't submit till we ask it to
>geocoded=__geocode(form.vars.postcode) #<-- so compute the other 
> fields
>#add some computed values to the form.vars dictionary for submission
>form.vars['lon']=geocoded['lon']
>form.vars['lat']=geocoded['lat']
>#and insert the data into the database
>db.data.insert(**dict(form.vars))
>#response.flash puts the flash in this page, session.flash in
> the next page of the session
>session.flash = 'form accepted'
>redirect(URL(r=request, f='index'))
> elif form.errors:
>response.flash = 'form has errors'
> return dict(form=form)
>
>

[web2py] Re: Making slides with web2py and markmin

2011-09-10 Thread Massimo Di Pierro
No. It makes the view. You just return it.

On Sep 10, 3:53 pm, António Ramos  wrote:
> Humm, dont i need a view?
>
> Em 10 de setembro de 2011 21:52, António Ramos escreveu:
>
>
>
>
>
>
>
> > Working now :)
>
> > Em 10 de setembro de 2011 21:29, António Ramos 
> > escreveu:
>
> > Traceback (most recent call last):
> >> File "gluon/restricted.py", line 191, in restricted
> >> File "gluon/restricted.py", line 178, in compile2
> >> TypeError: compile() expected string without null bytes
>
> >> :(
>
> >> Just a screenshot please
>
> >> 2011/9/10 Michele Comitini 
>
> >>> +1
>
> >>> Terrific!
>
> >>> mic
> >>> Il giorno 10/set/2011 21:24, "Massimo Di Pierro" <
> >>> mdipie...@cs.depaul.edu> ha scritto:
>
> >>> > Based on desk.js now you can do this
>
> >>> > Put the attached slide.py under models (any app).
>
> >>> > Write a controller like
>
> >>> > def test():
> >>> > content = """
> >>> > # My slides title
> >>> > ## Slide One
> >>> > this allows you to create slides using markmin
> >>> > ## Slide Two
> >>> > - you can use lists
> >>> > - you can use [[linkshttp://www.google.com]]
> >>> > - you can use images [[imagehttp://image.example.comcenter]]
> >>> > """
> >>> > return SLIDE(content,title="My slides")
>
> >>> > Notice the resulting file is pure html5 with external links therefore
> >>> it can be downloaded as an independent document.


[web2py] Re: web2py received 2011 BOSSIE Award by InfoWorld.com

2011-09-10 Thread Massimo Di Pierro
LOL

> who is Massimo as a man in the society, among friends, does he drive a
> Ferrary or a fiat 500?

11 years old Honda Civic but only 60K miles on it. I do not drive
much. I like trains and planes. My son his 6 and he also prefers
trains and planes.

> Does he eat meat or is a vegetarian. Is he good at other stuff or was just
> born to bring us web2py ?

I do eat meat. I feel guilty about it but I cannot stand vegetables.
I was born to be a high energy physicist. I ended up being a professor
of Computational Finance (although this quarter I am teaching how to
build Physics Engines for games). web2py is an accident.

> What are his projects in the future. How does he sees Web2py in 5 years?

You should tell me that. I will continue work on it and try make it
better.
I do not believe that software can last 5 years without major changes.

Anyway, seriously. web2py is what it is because lot of smart people
are here and have contributed to it. When I made web2py 1.0 my goals
were modest and web2py has vastly exceeded these goals.
I am trying not to impose a vision of what it should do except I try
to enforce:
- backward compatibility
- a uniform and intuitive api

You guys have been teaching me a lot of things that I did not know 3
years ago including how to use distributed version control systems
(and am still a noob) and how to manage people.


[web2py] Re: Computing a field from the value of another field

2011-09-10 Thread Chris Rowson
> Hi there,
>
> I bought the web2py .pdf, and have been reading it, but I'm struggling
> a little bit with:
>
> http://www.web2py.com/book/default/chapter/07#SQLFORM
>
> Specifically the section "SQLFORM without database IO"
>
> I have 2 fields, lon & lat I'd like to calculated from a postcode and
> enter into the database. I want this to happen automatically, I don't
> want the user to see them in the form.
>
> As you can see below, I've done this by setting dbio=False, computing
> the fields from the postcode value then adding them to the forms.var
> dict before submitting it all together. Is this a rational way to
> accomplish my requirements?
>
> Thanks in advance!
>
> Chris
>
> def adddata():
>    form=SQLFORM(db.data, fields=['provider', 'speed', 'postcode', 'ping'])
>    if form.accepts(request.vars, session, dbio=False): #<-- dbio
> false means it doesn't submit till we ask it to
>       geocoded=__geocode(form.vars.postcode) #<-- so compute the other fields
>       #add some computed values to the form.vars dictionary for submission
>       form.vars['lng']=geocoded['lng']
>       form.vars['lat']=geocoded['lat']
>       #and insert the data into the database
>       db.data.insert(**dict(form.vars))
>       #response.flash puts the flash in this page, session.flash in
> the next page of the session
>       session.flash = 'form accepted'
>       redirect(URL(r=request, f='index'))
>    elif form.errors:
>       response.flash = 'form has errors'
>    return dict(form=form)
>

It might also help to show you the geocode function (changed lon to lng too)

def __geocode(address):
import urllib
import xml.dom.minidom
"""Returns latitude and longitude when passed a postcode
"""
geocodeUrl='http://maps.googleapis.com/maps/api/geocode/xml?address='
sensor='&sensor=false'
#send the postcode to Google for geocoding
dom=xml.dom.minidom.parse(urllib.urlopen(geocodeUrl+address+sensor))

#grab the location element
location=dom.getElementsByTagName('location')[0]

#pull out the lat & lng elements and remove the  &  tags

lat=location.getElementsByTagName('lat')[0].toxml().replace('','').replace('','')

lng=location.getElementsByTagName('lng')[0].toxml().replace('','').replace('','')

georesults = {'lat':lat, 'lng':lng}

return georesults


[web2py] Re: Making slides with web2py and markmin

2011-09-10 Thread Christopher Steel
Very nice. Works great!

I think Markmin is a pretty powerful tool because it is so easy for people 
to use. This could make a really big difference for a lot of people.

Thank You.




[web2py] Re: web2py received 2011 BOSSIE Award by InfoWorld.com

2011-09-10 Thread weheh
Bravíssimo, Massimo!


[web2py] Re: web2py received 2011 BOSSIE Award by InfoWorld.com

2011-09-10 Thread Eric
Congratulations for Massimo and all the other contributors!  You've
achieved a lot in a relatively short amount of time.

On Sep 7, 10:59 pm, wwwgong  wrote:
> Congratulations!
>
> more details from 
> here:http://www.infoworld.com/d/open-source-software/bossie-awards-2011-th...


[web2py] Instant Admin third-party security audit?

2011-09-10 Thread Eric
I'm just writing to find out if a third-party has audited the code for
the new instant admin plug-in for web2py (https://github.com/sramana/
web2py-instant-admin).  It's a beautiful interface for the db, and I
mean nothing personal against the developers, who have done a
fantastic job building a great-looking way to access the db.

It's just this is a lot of code, and I've not yet gone over the whole
thing myself (and would not be the ideal candidate for doing a
security audit anyway).  And before I give access to my db to a new
third-party plug-in, I'd like to know at least that others are using
it in production, and ideally that someone skilled in auditing python
code for security has taken a close look at it.  It would be a great
admin interface for admins to use with an app I've created.


[web2py] Re: Quick authentication question

2011-09-10 Thread Eric
And if you're using Apache with mod_wsgi and you want to use basic
authentication with a web2py service, don't forget to add the line
"WSGIPassAuthorization On" to wsgi.conf under /etc/apache2/mods-
enabled  I spent over an hour trying to figure out why I wasn't able
to do basic authentication before I ran across a prior post that
described this essential step.

On Sep 8, 8:58 pm, Anthony  wrote:
> Have you tried
>
> auth.settings.allow_basic_login = True
>
> Seehttp://web2py.com/book/default/chapter/08#Access-Control-and-Basic-Au
>
> Anthony
>
>
>
>
>
>
>
> On Thursday, September 8, 2011 7:48:04 PM UTC-4, Matt wrote:
>
> > Hi there,
>
> > I have a very quick question about basic authentication.
>
> > Does web2py support this approach?
>
> > https://username:passw...@www.website.com/index
>
> > Matt


Re: [web2py] Re: Crud.update Multiple

2011-09-10 Thread Richard Vézina
for fieldvalue in list of values:
    db.person.insert(name=fieldvalue)


Off coarse you can do it for multiple values :

list1=[(valfield1,valfield2,valfield3),(etc.),(etc.)] # Note : first
tuples = first rows you want to insert

for field1, field2, field3 in list1
db.person.insert(field1=field1, field2=field2, field3=field3)
db.commit # or you wait and the end of the loop better only one commit

Richard


On Sat, Sep 10, 2011 at 4:12 PM, Serbitar  wrote:
>
> To be more specific:
>
> Multiple records (found via a query), all with different values of
> course and one text field for each record. Just one submit button.
>
> On Sep 10, 9:55 pm, Serbitar  wrote:
> > is there any way toupdatemultiplerecordswith crud.update, or 
> > evenrecordswith a given query?


Re: [web2py] Making slides with web2py and markmin

2011-09-10 Thread António Ramos
Humm, dont i need a view?

Em 10 de setembro de 2011 21:52, António Ramos escreveu:

> Working now :)
>
>
> Em 10 de setembro de 2011 21:29, António Ramos escreveu:
>
> Traceback (most recent call last):
>> File "gluon/restricted.py", line 191, in restricted
>> File "gluon/restricted.py", line 178, in compile2
>> TypeError: compile() expected string without null bytes
>>
>>
>> :(
>>
>>
>> Just a screenshot please
>>
>>
>> 2011/9/10 Michele Comitini 
>>
>>> +1
>>>
>>> Terrific!
>>>
>>> mic
>>> Il giorno 10/set/2011 21:24, "Massimo Di Pierro" <
>>> mdipie...@cs.depaul.edu> ha scritto:
>>>
>>> > Based on desk.js now you can do this
>>> >
>>> > Put the attached slide.py under models (any app).
>>> >
>>> > Write a controller like
>>> >
>>> > def test():
>>> > content = """
>>> > # My slides title
>>> > ## Slide One
>>> > this allows you to create slides using markmin
>>> > ## Slide Two
>>> > - you can use lists
>>> > - you can use [[links http://www.google.com]]
>>> > - you can use images [[image http://image.example.com center]]
>>> > """
>>> > return SLIDE(content,title="My slides")
>>> >
>>> > Notice the resulting file is pure html5 with external links therefore
>>> it can be downloaded as an independent document.
>>> >
>>> >
>>>
>>
>>
>


Re: [web2py] Making slides with web2py and markmin

2011-09-10 Thread António Ramos
Working now :)


Em 10 de setembro de 2011 21:29, António Ramos escreveu:

> Traceback (most recent call last):
> File "gluon/restricted.py", line 191, in restricted
> File "gluon/restricted.py", line 178, in compile2
> TypeError: compile() expected string without null bytes
>
>
> :(
>
>
> Just a screenshot please
>
>
> 2011/9/10 Michele Comitini 
>
>> +1
>>
>> Terrific!
>>
>> mic
>> Il giorno 10/set/2011 21:24, "Massimo Di Pierro" 
>> ha scritto:
>>
>> > Based on desk.js now you can do this
>> >
>> > Put the attached slide.py under models (any app).
>> >
>> > Write a controller like
>> >
>> > def test():
>> > content = """
>> > # My slides title
>> > ## Slide One
>> > this allows you to create slides using markmin
>> > ## Slide Two
>> > - you can use lists
>> > - you can use [[links http://www.google.com]]
>> > - you can use images [[image http://image.example.com center]]
>> > """
>> > return SLIDE(content,title="My slides")
>> >
>> > Notice the resulting file is pure html5 with external links therefore it
>> can be downloaded as an independent document.
>> >
>> >
>>
>
>


Re: [web2py] Re: web2py received 2011 BOSSIE Award by InfoWorld.com

2011-09-10 Thread António Ramos
 hey,
we are here all fascinated about web2py and i was thinking ,

who is Massimo as a man in the society, among friends, does he drive a
Ferrary or a fiat 500?

Does he eat meat or is a vegetarian. Is he good at other stuff or was just
born to bring us web2py ?
What are his projects in the future. How does he sees Web2py in 5 years?


Let me be curious about a guy that created such a powerfull and funny tool.


I envy you :)

Let me suggest to you all


Stop programming and give Massimo an Applause  for making the clock ticking

+


2011/9/9 mikech 

> Congratulations!  Hey DePaul you just got some PR from one of your esteemed
> faculty!


[web2py] Computing a field from the value of another field

2011-09-10 Thread Chris Rowson
Hi there,

I bought the web2py .pdf, and have been reading it, but I'm struggling
a little bit with:

http://www.web2py.com/book/default/chapter/07#SQLFORM

Specifically the section "SQLFORM without database IO"

I have 2 fields, lon & lat I'd like to calculated from a postcode and
enter into the database. I want this to happen automatically, I don't
want the user to see them in the form.

As you can see below, I've done this by setting dbio=False, computing
the fields from the postcode value then adding them to the forms.var
dict before submitting it all together. Is this a rational way to
accomplish my requirements?

Thanks in advance!

Chris

def adddata():
form=SQLFORM(db.data, fields=['provider', 'speed', 'postcode', 'ping'])
if form.accepts(request.vars, session, dbio=False): #<-- dbio
false means it doesn't submit till we ask it to
   geocoded=__geocode(form.vars.postcode) #<-- so compute the other fields
   #add some computed values to the form.vars dictionary for submission
   form.vars['lon']=geocoded['lon']
   form.vars['lat']=geocoded['lat']
   #and insert the data into the database
   db.data.insert(**dict(form.vars))
   #response.flash puts the flash in this page, session.flash in
the next page of the session
   session.flash = 'form accepted'
   redirect(URL(r=request, f='index'))
elif form.errors:
   response.flash = 'form has errors'
return dict(form=form)


Re: [web2py] Making slides with web2py and markmin

2011-09-10 Thread António Ramos
Traceback (most recent call last):
File "gluon/restricted.py", line 191, in restricted
File "gluon/restricted.py", line 178, in compile2
TypeError: compile() expected string without null bytes


:(


Just a screenshot please


2011/9/10 Michele Comitini 

> +1
>
> Terrific!
>
> mic
> Il giorno 10/set/2011 21:24, "Massimo Di Pierro" 
> ha scritto:
>
> > Based on desk.js now you can do this
> >
> > Put the attached slide.py under models (any app).
> >
> > Write a controller like
> >
> > def test():
> > content = """
> > # My slides title
> > ## Slide One
> > this allows you to create slides using markmin
> > ## Slide Two
> > - you can use lists
> > - you can use [[links http://www.google.com]]
> > - you can use images [[image http://image.example.com center]]
> > """
> > return SLIDE(content,title="My slides")
> >
> > Notice the resulting file is pure html5 with external links therefore it
> can be downloaded as an independent document.
> >
> >
>


[web2py] what other tools do you use with web2py

2011-09-10 Thread Carl
Have a look at pyjs.org
It converts Pyrhon into JavaScript.


[web2py] Re: Crud.update Multiple

2011-09-10 Thread Serbitar
To be more specific:

Multiple records (found via a query), all with different values of
course and one text field for each record. Just one submit button.

On Sep 10, 9:55 pm, Serbitar  wrote:
> is there any way toupdatemultiplerecordswith crud.update, or evenrecordswith 
> a given query?


[web2py] Crud.update Multiple

2011-09-10 Thread Serbitar
is there any way to update multiple records with crud.update, or even
records with a given query?


Re: [web2py] Re: has anyone done web2py + google maps?

2011-09-10 Thread Chris Rowson
I'm a Python Web Dev noob, but I had a similar requirement. I created
this function to convert a postcode into lon & lat data suitable for
use in Google Maps. It's a work in progress, not very elegant, and it
doesn't have any error management but it's a start. Hopefully someone
on the list will be able to point out any serious problems with it if
there are any ;-)

import urllib
import xml.dom.minidom
"""Returns latitude and longitude when passed a postcode
"""
geocodeUrl='http://maps.googleapis.com/maps/api/geocode/xml?address='
sensor='&sensor=false'
#send the postcode to Google for geocoding
dom=xml.dom.minidom.parse(urllib.urlopen(geocodeUrl+address+sensor))

#grab the location element
location=dom.getElementsByTagName('location')[0]

#pull out the lat & lng elements and remove the  &  tags

lat=location.getElementsByTagName('lat')[0].toxml().replace('','').replace('','')

lng=location.getElementsByTagName('lng')[0].toxml().replace('','').replace('','')

georesults = {'lat':lat, 'lng':lng}

return georesults


Re: [web2py] Making slides with web2py and markmin

2011-09-10 Thread Michele Comitini
+1

Terrific!

mic
Il giorno 10/set/2011 21:24, "Massimo Di Pierro" 
ha scritto:
> Based on desk.js now you can do this
>
> Put the attached slide.py under models (any app).
>
> Write a controller like
>
> def test():
> content = """
> # My slides title
> ## Slide One
> this allows you to create slides using markmin
> ## Slide Two
> - you can use lists
> - you can use [[links http://www.google.com]]
> - you can use images [[image http://image.example.com center]]
> """
> return SLIDE(content,title="My slides")
>
> Notice the resulting file is pure html5 with external links therefore it
can be downloaded as an independent document.
>
>


[web2py] Re: uWSGI 0.9.9

2011-09-10 Thread elffikk
hi Roberto,
This version seems to be backward incompatible:

--protocol http --socket 127.0.0.1: doesn't seems to work for me

and using uwsgi --http 127.0.0.1: with --touch-reload makes uwsgi
to exit completely (no uwsgi processes after touching the file )


[web2py] Re: How do I install a plugin??

2011-09-10 Thread Luca
Ah, ok, I figured it out. 

What I expected to be called "install" is called "upload". 
It's kind of funny to have to "upload" something I have just "downloaded", 
but whatever :-)


[web2py] Re: How do I install a plugin??

2011-09-10 Thread Anthony
Upload the plugin file -- that will "install" it.

On Saturday, September 10, 2011 3:03:51 PM UTC-4, Luca wrote:
>
> Suppose I downloaded a plugin.  Now I 
> have: web2py.plugin.layout_EfflorescenceBlue.w2p
> Great; how do I install it?  The book says to use the edit page in admin, 
> but I see no such option in the edit page in admin to install a plugin file. 
>  There is a link to download plugins (which I have done, now what?), and one 
> to upload plugins, but no link to install them. 
>
> What am I to do with my plugin file? 
>
> Thanks! - Luca
>


Re: [web2py] Re: problems changing database field type

2011-09-10 Thread Richard Vézina
This seems interresting...

Thanks

Richard

On Fri, Sep 9, 2011 at 6:18 PM, Michael Toomim  wrote:

> I think we need more tools for fixing broken migrations!
>
> When I have something broken, sometimes I go into the sql console,
> edit the database manually, and then use these functions to tell
> web2py that I've changed the table in sql.  (However, I haven't had to
> use these for at least a year... maybe some dal bugs have been fixed
> and migrations don't break as frequently anymore?)
>
> def db_hash():
>import cPickle, hashlib
>return hashlib.md5(database).hexdigest()
>
> def get_migrate_status(table_name):
>import cPickle, hashlib
>f = open('applications/init/databases/%s_%s.table'
> % (hashlib.md5(database).hexdigest(),
>table_name),
> 'r')
>result = cPickle.load(f)
>f.close()
>return result
>
> def save_migrate_status(table_name, status):
>import cPickle, hashlib
>f = open('applications/init/databases/%s_%s.table'
> % (hashlib.md5(database).hexdigest(),
>table_name),
> 'w')
>cPickle.dump(status, f)
>f.close()
>print 'saved'
>
> def del_migrate_column(table_name, column_name):
>a = get_migrate_status(table_name)
>del a[column_name]
>save_migrate_status(table_name, a)
>
>
> On Sep 9, 11:17 am, pbreit  wrote:
> > I think we need some more documentation on migrations, especially around
> > fixing broken migrations, how to modify schema manually, how the sql.log
> and
> > .table files work and how/when to recreate, etc.
>


[web2py] How do I install a plugin??

2011-09-10 Thread Luca
Suppose I downloaded a plugin.  Now I 
have: web2py.plugin.layout_EfflorescenceBlue.w2p
Great; how do I install it?  The book says to use the edit page in admin, 
but I see no such option in the edit page in admin to install a plugin file. 
 There is a link to download plugins (which I have done, now what?), and one 
to upload plugins, but no link to install them. 

What am I to do with my plugin file? 

Thanks! - Luca


[web2py] encoding

2011-09-10 Thread Emy
hey all
my website is dealing with arabic characters and I have a problem with
encoding I can read from DB wothout problem when I try to insert any
data using ajax function  I got the string written like that in
python :
"%D8%A8%D8%A8%D9%8A%D9%8A%D9%8A%D8%B3%D8%B3%'"

when I try to write :
txt=unicode(txt)
I get the same result

can anyone help me


[web2py] Re: what other tools do you use with web2py

2011-09-10 Thread weheh
Indeed, you are right. I found with my first really big web2py project
that 80% of my time was in jQuery and getting various jQuery widgets
and tools to work properly. Of course, Firebug is essential when
debugging this kind of stuff. I also like Eclipse as an IDE. CSS has
always seemed like an abomination to me and I continue to hold that
opinion. Firebug is useful for combing through CSS.

On Sep 10, 2:09 pm, LightDot  wrote:
> You mean JavaScript and CSS? I guess there is no way past using CSS, but
> there are a lot of choices when it comes to JavaScript libraries. Although,
> jQuery is one of the best in my opinion.


[web2py] Re: what other tools do you use with web2py

2011-09-10 Thread LightDot
You mean JavaScript and CSS? I guess there is no way past using CSS, but 
there are a lot of choices when it comes to JavaScript libraries. Although, 
jQuery is one of the best in my opinion.


[web2py] what other tools do you use with web2py

2011-09-10 Thread apple
The two best things about web2py:
   Ability to achieve a lot with a very small number of lines of
code
   Being able to use python in the view templates

The worst thing:
   Finding that 2/3 of the time is now spent on jquery and CSS!

What tools are there to make this easier? Are jquery and CSS the best
available?


Re: [web2py] reading special chars from T dict

2011-09-10 Thread Carlos
It's me again.

In fact, they do appear ok in regular html (even if they appear strange in 
shell), but I'm having problems displaying them in other places.

Anyways, I guess this is 'ok', until I figure out the exact way to replicate 
my problem, considering they do appear correctly in regular html.

Thanks a lot !,

   Carlos



Re: [web2py] reading special chars from T dict

2011-09-10 Thread Carlos
Btw the following is what I get from shell:

   T.force('es')  >  ['es']

   print T('any')  >  Organizaci├│n

   str(T('any'))  >  'Organizaci\xc3\xb3n'

Thanks.


Re: [web2py] reading special chars from T dict

2011-09-10 Thread Carlos
Hi Bruno,

I have the following as the first line in my language file:

# coding: utf8

Is that the correct format?.

   Carlos



Re: [web2py] reading special chars from T dict

2011-09-10 Thread Bruno Rocha
Do you have
coding: utf-8?

I have no problem with portuguese pontuation.

Organização

http://zerp.ly/rochacbruno
Em 10/09/2011 10:30, "Carlos"  escreveu:
> Hi,
>
> (I asked this as a reply in another topic (html entities), but I'll move
it
> here to be on a separate thread)
>
> Why is it that my translations are not being read correctly from the T
> dict?.
>
> I have the following T value (notice the spanish accent): Organización
>
> But when read from web2py, it appears as: Organizaci\xc3\xb3n
>
> What can I do in order for T to read it properly?.
>
> Thanks,
>
> Carlos
>


[web2py] reading special chars from T dict

2011-09-10 Thread Carlos
Hi,

(I asked this as a reply in another topic (html entities), but I'll move it 
here to be on a separate thread)

Why is it that my translations are not being read correctly from the T 
dict?.

I have the following T value (notice the spanish accent): Organización

But when read from web2py, it appears as: Organizaci\xc3\xb3n

What can I do in order for T to read it properly?.

Thanks,

   Carlos



[web2py] Re: has anyone done web2py + google maps?

2011-09-10 Thread Anthony
There's this 
plugin: https://groups.google.com/d/topic/web2py/4RFAudXbt3s/discussion. 
Also, plugin_wiki includes a Google Maps widget similar to that plugin 
(http://web2py.com/book/default/chapter/13#Current-Widgets).

There's also https://github.com/relsi/web2pyople (see it running 
here: http://web2pyople.appspot.com/).

Anthony

On Saturday, September 10, 2011 1:47:53 AM UTC-4, niknok wrote:
>
> Any links to try out?



Re: [web2py] has anyone done web2py + google maps?

2011-09-10 Thread Bruno Rocha
http://web2py.com/appliances/default/show/71

On Sat, Sep 10, 2011 at 2:47 AM, niknok  wrote:

> Any links to try out?


[web2py] Re: RFC: New design for {{include file.html}} in views

2011-09-10 Thread Michael Toomim
Yes this is a much better design pattern.  I will just make a file of
these helpers and include them all at once.

Thanks massimo!

On Sep 9, 10:32 pm, Massimo Di Pierro 
wrote:
> Why not do:
>
> in friend_selector.html
>
> {{def selector(id=None):}}
>                 
>                         
>                          name="access_input"
> class="access_input" size="30" type="text" value="" />
>                 
> {{return}}
>
> and in the extending view {{include 'friend_selector.html'}}
> {{selector(id='main-access')}}
>
> This is already supported and allows to define more than one function
> in include. And it is more pythonic.
>
> On Sep 9, 10:12 pm, Michael Toomim  wrote:
>
>
>
>
>
>
>
> > I frequently write short snippets of HTML that I want to replicate in
> > many places, like:
>
> >                 
> >                         
> >                          > class="access_input" size="30" type="text" value="" />
> >                 
>
> > So I can put this into a .html file "friend_selector.html", and then
> > include it whenever I need this. But I often need to parameterize it.
> > For instance, I might want to set a different id each time.
>
> > So I do it like this:
>
> >         {{vars = {id : 'main_access_input'} }}
> >         {{include 'friend_selector.html'}}
> >         {{vars = {} }}
>
> > And then parameterize my html like this:
>
> >                 
> >                         
> >                          > vars['id']:}}id="{{=vars['id']}}"{{pass}}
> > name="access_input" class="access_input" size="30" type="text"
> > value="" />
> >                 
>
> > Basically, I'm re-inventing a function call via the {{include}}
> > feature. Wouldn't it be awesome if this just happened automatically???
> > Like this:
>
> >         {{include 'friend_selector.html' (id='main_access_input')}}
>
> > Would you like this feature? Does this sound hard to implement?
>
> > Appendix:
> > 1. You can also do this I think with template inheritance, but that's
> > just complicated. Or you could define and call parameterized functions
> > in python, but editing embedded html in python strings is gross.
> > 2. The (id='main_access_input') part would ideally be a full python-
> > style parameter list, supporting e.g. (a=1, b=3). This is simpler to
> > implement. But to support positional args, like (1,3,5, a=1), the html
> > blocks would need to declare their supported parameters. They could do
> > so with by including a "declare" snippet like this:
>
> >                 {{ declare (a, b, c, id=None): }}
> >                 
> >                         
> >                          > name="access_input"
> > class="access_input" size="30" type="text" value="" />
> >