Re: [web2py] Gigya - Janrain alternative

2011-05-13 Thread Martin Weissenboeck
Seems very interesting, I would like to use it!

Regards, Martin



2011/5/13 Bruno Rocha rochacbr...@gmail.com

 HI,

 I am not very satisfied with Janrain, so I started a search for a different
 solution, I already tried SimpleAuth but it is not finished yet.

 I guess I found a better solution than Janrain engage and this is
 http://developers.gigya.com/

 More than centralized login this provides better social plugins, now I am
 starting to write some web2py code to integrate, anyone working on this?

 --
 Bruno Rocha
 [ About me: http://zerp.ly/rochacbruno ]




Re: [web2py] Gigya - Janrain alternative

2011-05-13 Thread pbreit
I wonder if we'd be better off with direct twitter and Facebook integrations. 
Do we really need all those other ones?


[web2py] Re: Cherokee and fcgi

2011-05-13 Thread pbreit
Good to hear. I currently think ubuntu + nginx + uWSGI is the best setup but 
Cherokee is good too.


Re: [web2py] Gigya - Janrain alternative

2011-05-13 Thread Bruno Rocha
The better things are the widgets, i.e: 'invite your friends, chat etc..
take a look; http://developers.gigya.com/040_Demos


On Fri, May 13, 2011 at 3:46 AM, pbreit pbreitenb...@gmail.com wrote:

 I wonder if we'd be better off with direct twitter and Facebook
 integrations. Do we really need all those other ones?


[web2py] TABLIB - Would be a nice tool to integrate with DAL

2011-05-13 Thread Bruno Rocha
https://github.com/kennethreitz/tablib

Tablib: format-agnostic tabular dataset library


headers = ('first_name', 'last_name')

data = [
('John', 'Adams'),
('George', 'Washington')
]

data = tablib.Dataset(*data, headers=headers)


Exports

Drumroll please...
JSON!


 print data.json
[
  {
last_name: Adams,
age: 90,
first_name: John
  },
  {
last_name: Ford,
age: 83,
first_name: Henry
  }
]

YAML!


 print data.yaml
- {age: 90, first_name: John, last_name: Adams}
- {age: 83, first_name: Henry, last_name: Ford}

CSV...


 print data.csv
first_name,last_name,age
John,Adams,90
Henry,Ford,83

EXCEL!


 open('people.xls', 'wb').write(data.xls)

It's that easy.


*I am wondering something like*


data = tablib.Dataset(db(db.table.select().as_dict(), headers=headers)

Then we can have DAL Rows written in to Excel, YAML and JSON.

--
Bruno Rocha
[ About me: http://zerp.ly/rochacbruno ]


[web2py] Re: TABLIB - Would be a nice tool to integrate with DAL

2011-05-13 Thread Bruno Rocha
 docs
http://docs.tablib.org/en/latest/index.html
--
Bruno Rocha
[ About me: http://zerp.ly/rochacbruno ]



On Fri, May 13, 2011 at 4:13 AM, Bruno Rocha rochacbr...@gmail.com wrote:

 https://github.com/kennethreitz/tablib

 Tablib: format-agnostic tabular dataset library


 headers = ('first_name', 'last_name')

 data = [
 ('John', 'Adams'),
 ('George', 'Washington')
 ]

 data = tablib.Dataset(*data, headers=headers)


 Exports

 Drumroll please...
 JSON!


  print data.json
 [
   {
 last_name: Adams,
 age: 90,
 first_name: John
   },
   {
 last_name: Ford,
 age: 83,
 first_name: Henry
   }
 ]

 YAML!


  print data.yaml
 - {age: 90, first_name: John, last_name: Adams}
 - {age: 83, first_name: Henry, last_name: Ford}

 CSV...


  print data.csv
 first_name,last_name,age
 John,Adams,90
 Henry,Ford,83

 EXCEL!


  open('people.xls', 'wb').write(data.xls)

 It's that easy.


 *I am wondering something like*


 data = tablib.Dataset(db(db.table.select().as_dict(), headers=headers)

 Then we can have DAL Rows written in to Excel, YAML and JSON.

 --
 Bruno Rocha
 [ About me: http://zerp.ly/rochacbruno ]




Re: [web2py] Gigya - Janrain alternative

2011-05-13 Thread Martin Weissenboeck
I didn't find their prices?

2011/5/13 Bruno Rocha rochacbr...@gmail.com

 The better things are the widgets, i.e: 'invite your friends, chat etc..
 take a look; http://developers.gigya.com/040_Demos



 On Fri, May 13, 2011 at 3:46 AM, pbreit pbreitenb...@gmail.com wrote:

 I wonder if we'd be better off with direct twitter and Facebook
 integrations. Do we really need all those other ones?





[web2py] Re: login fails for ajax components

2011-05-13 Thread selecta
so what about fixing this issue?
should i create a issue on gcode?


[web2py] autocomplete widget a disaster on Internet Explorer

2011-05-13 Thread Johann Spies
This came to my attention when one of my users complained about an entry
form using the autocomplete widget frustrates her.  When i checked I saw the
following when using Internet Eplorer:

As soon as the autocomplete widget shows up on the screen you cannot type
any longer in the field and when you stop typing, the list with options
disappear.  The widget was set up to show after more than two characters
were typed.  So when the user type in two more characters the widget appears
again.

I suspect this might be a css-issue?  I am using ez-css which comes standard
with web2py as well as some additional css files used by jquery's jqplot.

How do I solve this problem?  I normally do not use Windows and I do not
really know Internet Explorer.

Regards
Johann

-- 
 May grace and peace be yours in abundance through the full knowledge of God
and of Jesus our Lord!  His divine power has given us everything we need for
life and godliness through the full knowledge of the one who called us by
his own glory and excellence.
2 Pet. 1:2b,3a


[web2py] select from db by list of id

2011-05-13 Thread cyber
Good day!

Is there a way to select rows from db if I have a list of id?
For example, there is a list [50, 45, 32, 11] and I want to make
selection by this list and save the result in one object.
How can I do that?

I tried:
 id_list = [50, 45, 32, 11]
 results=db(db.autos==id_list).select()
But there was an error no tables selected.

Thanks in advance!


Re: [web2py] select from db by list of id

2011-05-13 Thread Vasile Ermicioi
id_list = [50, 45, 32, 11]
rows=db(dv.autos.id.belongs(id_list)).select()


[web2py] Re: Multiple tables: update/insert/delete: in one form

2011-05-13 Thread Vineet
pbreit,
As you say, wherever possible or required, I have already denormalized
the table-structures.
Apart from normalization / denormalization issue, in many other forms,
I need to insert/update/delete records in multiple tables from one
form.
(as I mentioned earlier, there will be a mix of insert/update/delete
of record(s) in different tables.)

Massimo,
If you too haven't understood what I intend to do with these 5 tables,
I can elaborate the idea.
Pl. tell me accordingly.
The very success of developing my project using web2py hinges on this
functionality.

---Vineet


On May 11, 5:17 am, pbreit pbreitenb...@gmail.com wrote:
 Normalizing is not always the best approach. If the database has not yet
 been designed, perhaps reconsider. I still don't really understand what you
 are trying to do but 5 small tables might not be necessary.

 I would suggest getting some code working with 2 tables an then go from
 there.

 Some 
 options:http://web2py.com/book/default/chapter/07#One-form-for-multiple-tableshttp://web2py.com/book/default/chapter/07#Multiple-forms-per-page

 Another approach would to use FORM or SQLFORM.factory and then coding the
 database updates. You lose some of the Web2py features but it might still be
 the easiest way to do it.

 But my first suggestion would be to try and simplify what you are intending
 to do.


[web2py] Re: TABLIB - Would be a nice tool to integrate with DAL

2011-05-13 Thread selecta
very nice, just what i need, does it import xls too? xlsx even?

On May 13, 9:24 am, Bruno Rocha rochacbr...@gmail.com wrote:
  docshttp://docs.tablib.org/en/latest/index.html
 --
 Bruno Rocha
 [ About me:http://zerp.ly/rochacbruno]



 On Fri, May 13, 2011 at 4:13 AM, Bruno Rocha rochacbr...@gmail.com wrote:
 https://github.com/kennethreitz/tablib

  Tablib: format-agnostic tabular dataset library

  headers = ('first_name', 'last_name')

  data = [
      ('John', 'Adams'),
      ('George', 'Washington')
  ]

  data = tablib.Dataset(*data, headers=headers)

  Exports

  Drumroll please...
  JSON!

   print data.json
  [
    {
      last_name: Adams,
      age: 90,
      first_name: John
    },
    {
      last_name: Ford,
      age: 83,
      first_name: Henry
    }
  ]

  YAML!

   print data.yaml
  - {age: 90, first_name: John, last_name: Adams}
  - {age: 83, first_name: Henry, last_name: Ford}

  CSV...

   print data.csv
  first_name,last_name,age
  John,Adams,90
  Henry,Ford,83

  EXCEL!

   open('people.xls', 'wb').write(data.xls)

  It's that easy.

  *I am wondering something like*

  data = tablib.Dataset(db(db.table.select().as_dict(), headers=headers)

  Then we can have DAL Rows written in to Excel, YAML and JSON.

  --
  Bruno Rocha
  [ About me:http://zerp.ly/rochacbruno]


[web2py] Re: select from db by list of id

2011-05-13 Thread cyber
Hmm...
Very nice! It works perfectly. As a matter of fact it was very easy.
Thank you Vasile.
**

On 13 май, 13:41, Vasile Ermicioi elff...@gmail.com wrote:
 id_list = [50, 45, 32, 11]
 rows=db(dv.autos.id.belongs(id_list)).select()


[web2py] I found this poll

2011-05-13 Thread Massimo Di Pierro
https://py3ksupport.appspot.com/metrics/poll_count


[web2py] Re: autocomplete widget a disaster on Internet Explorer

2011-05-13 Thread Massimo Di Pierro
Is this a particular IE version? Do you know if it works with 7 and 8?
I have no easy way of testing it.
have you upgraded the jquery version?

On May 13, 3:29 am, Johann Spies johann.sp...@gmail.com wrote:
 This came to my attention when one of my users complained about an entry
 form using the autocomplete widget frustrates her.  When i checked I saw the
 following when using Internet Eplorer:

 As soon as the autocomplete widget shows up on the screen you cannot type
 any longer in the field and when you stop typing, the list with options
 disappear.  The widget was set up to show after more than two characters
 were typed.  So when the user type in two more characters the widget appears
 again.

 I suspect this might be a css-issue?  I am using ez-css which comes standard
 with web2py as well as some additional css files used by jquery's jqplot.

 How do I solve this problem?  I normally do not use Windows and I do not
 really know Internet Explorer.

 Regards
 Johann

 --
  May grace and peace be yours in abundance through the full knowledge of God
 and of Jesus our Lord!  His divine power has given us everything we need for
 life and godliness through the full knowledge of the one who called us by
 his own glory and excellence.
                                                     2 Pet. 1:2b,3a


Re: [web2py] Re: autocomplete widget a disaster on Internet Explorer

2011-05-13 Thread Johann Spies
On 13 May 2011 15:19, Massimo Di Pierro massimo.dipie...@gmail.com wrote:

 Is this a particular IE version? Do you know if it works with 7 and 8?
 I have no easy way of testing it.
 have you upgraded the jquery version?


I don't know which version the user was using but I have tested it on IE8
and it behaved similarly.

My jquery.js was 1.4.2.  I have upgraded it to 1.4.3 (which was in the
Welcome application) but it did not make any difference.

Should I upgrade jquery.

Regards
Johann
-- 
 May grace and peace be yours in abundance through the full knowledge of God
and of Jesus our Lord!  His divine power has given us everything we need for
life and godliness through the full knowledge of the one who called us by
his own glory and excellence.
2 Pet. 1:2b,3a


[web2py] Re: I found this poll

2011-05-13 Thread Anthony
The poll itself is in the top of the right sidebar on http://www.python.org-- 
you have to enter the name of the Python package (e.g., web2py) and 
click Vote.

On Friday, May 13, 2011 9:16:54 AM UTC-4, Massimo Di Pierro wrote:

 https://py3ksupport.appspot.com/metrics/poll_count



Re: [web2py] Gigya - Janrain alternative

2011-05-13 Thread Anthony
On Friday, May 13, 2011 4:24:24 AM UTC-4, mweissen wrote: 

 I didn't find their prices?

 
It just says Contact Sales -- that makes me think it's expensive.


[web2py] Lighter processing for AJAX requests ?

2011-05-13 Thread Alexandre Strzelewicz
Hi,

I use a lot of ajax requests to get data asynchronously but each
requests are heavy to handle on server side.

Indeed, when web2py receive an ajax request, it process :
- web2py python core files
- ...
- db.py
- controller.py

The result is that for each ajax requests one CPU is taken at 100%...
whereas node.js take less than 5%

Is there a solution in order to make ajax requests lighter to
process ?

Combining web2py and node.js ?

Thanks


[web2py] Re: autocomplete widget a disaster on Internet Explorer

2011-05-13 Thread villas
I had problems with AutoComplete when we changed the layout and I
opened an issue on google code (issue 193 -- still open).

I didn't try it again since,  but at that time, this was definitely
CSS related and this could be proven simply by switching the old and
new layout files.  I made some attempt to track down the problem
myself but my firebug skills were not good enough :(



On May 13, 2:19 pm, Massimo Di Pierro massimo.dipie...@gmail.com
wrote:
 Is this a particular IE version? Do you know if it works with 7 and 8?
 I have no easy way of testing it.
 have you upgraded the jquery version?

 On May 13, 3:29 am, Johann Spies johann.sp...@gmail.com wrote:

  This came to my attention when one of my users complained about an entry
  form using the autocomplete widget frustrates her.  When i checked I saw the
  following when using Internet Eplorer:

  As soon as the autocomplete widget shows up on the screen you cannot type
  any longer in the field and when you stop typing, the list with options
  disappear.  The widget was set up to show after more than two characters
  were typed.  So when the user type in two more characters the widget appears
  again.

  I suspect this might be a css-issue?  I am using ez-css which comes standard
  with web2py as well as some additional css files used by jquery's jqplot.

  How do I solve this problem?  I normally do not use Windows and I do not
  really know Internet Explorer.

  Regards
  Johann

  --
   May grace and peace be yours in abundance through the full knowledge of God
  and of Jesus our Lord!  His divine power has given us everything we need for
  life and godliness through the full knowledge of the one who called us by
  his own glory and excellence.
                                                      2 Pet. 1:2b,3a




[web2py] Re: Lighter processing for AJAX requests ?

2011-05-13 Thread Stodge
Tornado is Python and very lightweight.

On May 13, 9:59 am, Alexandre Strzelewicz
strzelewicz.alexan...@gmail.com wrote:
 Hi,

 I use a lot of ajax requests to get data asynchronously but each
 requests are heavy to handle on server side.

 Indeed, when web2py receive an ajax request, it process :
 - web2py python core files
 - ...
 - db.py
 - controller.py

 The result is that for each ajax requests one CPU is taken at 100%...
 whereas node.js take less than 5%

 Is there a solution in order to make ajax requests lighter to
 process ?

 Combining web2py and node.js ?

 Thanks


[web2py] Conditional Requirement For Form-Fields

2011-05-13 Thread ma...@rockiger.com
What is the most elegant solution to this problem:

I have a form for address information in an ecommerce application.
The user can optionally input a different delivery address - this is done 
via radio button.
In this case the requirement for the delivery address fields change - 
nothing special actually.

What I've done so far:

Model: 

db.define_table('customer',
   Field('name', requires=[IS_NOT_EMPTY()], required=True, notnull=True),
   Field('company',default=None),  
   Field('zip', requires=[IS_MATCH('^[0-9]{5}$', error_message='not a zip 
code')], required=True, notnull=True),
   Field('street', requires=[IS_MATCH([0-9a-zA-ZäöüÄÖÜ\- \.]+)], 
required=True, notnull=True),
   Field('city', requires=[IS_MATCH([a-zA-ZäöüÄÖÜ\- \.]+)], required=True, 
notnull=True),
   Field('country', requires=[IS_IN_SET([T('Deutschland'),T('Östereich'), 
T(Schweiz)])], default=Deutschland),
   Field('email',requires= [IS_NOT_EMPTY(), IS_EMAIL(),
   IS_NOT_IN_DB(db,'customer.email')],
   required=True, notnull=True),
   Field('email_confirmation',requires= [IS_NOT_EMPTY(), IS_EMAIL(),
   IS_NOT_IN_DB(db,'customer.email')],
   required=True, notnull=True),
   Field('delivery_address', 
requires=[IS_IN_SET([T('Yes'),T('No')])],widget=SQLFORM.widgets.radio.widget, 
 default=No),
   Field('delivery_name',default=None),
   Field('delivery_company',default=None),
   Field('delivery_zip', requires=[IS_EMPTY_OR(IS_MATCH('^[0-9]{0,5}$',
 error_message='not a zip code'))]),
   Field('delivery_street', requires=[IS_EMPTY_OR(IS_MATCH([a-zA-ZäöüÄÖ\- 
\.]+))],default=None),
   Field('delivery_city', requires=[IS_EMPTY_OR(IS_MATCH([a-zA-ZäöüÄÖ\- 
\.]+))],default=None),
   Field('delivery_country', 
requires=[IS_EMPTY_OR(IS_IN_SET([T('Deutschland'),T('Östereich'), 
T(Schweiz)]))],  default=Deutschland),
   Field('timestamp', 'datetime', default=request.now, readable=False, 
writable=False)
)

controller:

def address():
   crud.messages.submit_button = 'Weiter zur Bestätigungsseite' 
   crud.settings.formstyle='table2cols'
   form = crud.create(db.customer)
   if form.accepts(request.vars, session, onvalidation=__address_validator):
   response.flash = 'form accepted'
   return dict(form=form)


def __address_validator(form):
   if not form.vars.email == form.vars.email_confirmation:
   form.errors.email_confirmation = Email-Adressen stimmen nicht 
überein.
   if form.vars.delivery_address == T(Yes):
  if not form.vars.delivery_name:
 form.errors.delivery_name = Bitte gib einen Namen ein.
  if not form.vars.delivery_zip:
 form.errors.delivery_zip = Bitte gib eine Postleitzahl ein.
  if not form.vars.delivery_street:
 form.errors.delivery_street = Bitte gib eine Straße mit Hausnummer 
ein.
  if not form.vars.delivery_city:
 form.errors.delivery_city = Bitte gib eine Stadt ein.
  if not form.vars.delivery_country:
 form.errors.delivery_name = Bitte gib ein Land an.

This works! But it is not very nice to the user, because the check of the 
optional fields happens after the form is accepted.
Is there a better way to set the requirements for the optional fields?

Thanks for help


[web2py] Re: Gigya - Janrain alternative

2011-05-13 Thread Stodge
Why tie yourself to a third party provider? Maybe direct integration
with sites like Facebook and Twitter is the best direction.

On May 13, 1:08 am, Bruno Rocha rochacbr...@gmail.com wrote:
 HI,

 I am not very satisfied with Janrain, so I started a search for a different
 solution, I already tried SimpleAuth but it is not finished yet.

 I guess I found a better solution than Janrain engage and this 
 ishttp://developers.gigya.com/

 More than centralized login this provides better social plugins, now I am
 starting to write some web2py code to integrate, anyone working on this?

 --
 Bruno Rocha
 [ About me:http://zerp.ly/rochacbruno]


[web2py] Crontab with WSGI

2011-05-13 Thread luifran
I tried the following with the test server and it works
In crontab:
55 07 * * * root * default / limpiar_eventos
In the default controller
def limpiar_eventos ():
 totalFilas = db (db.auth_event.id 0). count ()
 totalFilas if 30:
for row in db (db.auth_event.id 0). select (limitby = (0,
2)):
db (db.auth_event.id == fila.id.) delete ()
db.commit ()
But this, in Cherokee web server with WSGI does not work.
why?


Re: [web2py] Re: Gigya - Janrain alternative

2011-05-13 Thread Bruno Rocha
On Fri, May 13, 2011 at 1:11 PM, Stodge sto...@gmail.com wrote:

 Why tie yourself to a third party provider? Maybe direct integration
 with sites like Facebook and Twitter is the best direction.


I am not talking about only Auth, this provides some widgets
http://developers.gigya.com/040_Demos

You can retrieve profiles, friends, invitations etc.

This can be done from the scratch but I have no time for doing this,
Janrain, Gigya or similars are ready options for going.


[web2py] Re: Crontab with WSGI

2011-05-13 Thread pbreit
Do you have those spaces in there? The cron line should be:

55 07 * * * root *default/limpiar_eventos

Are you able to run the function in your browser?

http://127.0.0.1:8000/myapp/default/limpiar_eventos


Re: [web2py] Lighter processing for AJAX requests ?

2011-05-13 Thread Bruno Rocha
On Fri, May 13, 2011 at 10:59 AM, Alexandre Strzelewicz 
strzelewicz.alexan...@gmail.com wrote:

 Hi,

 I use a lot of ajax requests to get data asynchronously but each
 requests are heavy to handle on server side.

 Indeed, when web2py receive an ajax request, it process :
 - web2py python core files
 - ...
 - db.py
 - controller.py


in trunk there is a change for this, web2py models now has subfolder
isolation, which means you can put your ajax callback functions under a
subfolder and web2py will execute only the models inside the subfolder.


[web2py] Re: Conditional Requirement For Form-Fields

2011-05-13 Thread pbreit
It's possible that onvalidation needs go in crud.create?

response.flash = 'form accepted' should be indented but I don't think that's 
the problem.


Re: [web2py] Re: I found this poll

2011-05-13 Thread Bruno Rocha
web2py http://pypi.python.org/pypi/web2py

This project *might or might not* support Python 3 .

The latest release is 1.95.6 with 0 downloads, at a rate of 0.0/day. The
largest release is 1.94.6 with 217 downloads.


On Fri, May 13, 2011 at 10:39 AM, Anthony abasta...@gmail.com wrote:

 The poll itself is in the top of the right sidebar on
 http://www.python.org -- you have to enter the name of the Python package
 (e.g., web2py) and click Vote.

 On Friday, May 13, 2011 9:16:54 AM UTC-4, Massimo Di Pierro wrote:

 https://py3ksupport.appspot.com/metrics/poll_count




Re: [web2py] Re: I found this poll

2011-05-13 Thread Ross Peoples
Does web2py support Python 3?

[web2py] Re: Lighter processing for AJAX requests ?

2011-05-13 Thread pbreit
That doesn't sound right. It's just an extra page view so should be 
relatively easy to handle. But I can see if you have several LOAD()s on most 
pages, that could triple or qudruple the load for the same number of 
visitors. But my old Mac barely breaks a sweat with several loads on a page. 
Caching might also help. And Bruno mentioned the new improvements in trunk 
that might help.

Re: [web2py] Re: Gigya - Janrain alternative

2011-05-13 Thread pbreit
That could be cool I guess. But you still have to program to an API so might 
as well be to the source.

Re: [web2py] Re: Gigya - Janrain alternative

2011-05-13 Thread Bruno Rocha
Forget about it! This is really cool, I love the widgets but they are crazy!

Gigya service cost for more than 1000 unique visitors/authentications per
month is $15,000 per year


Re: [web2py] Re: Gigya - Janrain alternative

2011-05-13 Thread Ross Peoples
$15,000?!?!? They are freaking insane. Most web sites prolly don't even pull 
that in profit a yearall just to login to a site with a Facebook/Twitter 
account? Web2py should prolly have its own auth method in that case.

[web2py] Re: Conditional Requirement For Form-Fields

2011-05-13 Thread Anthony
On Friday, May 13, 2011 12:10:58 PM UTC-4, ma...@rockiger.com wrote: 

 def address():
crud.messages.submit_button = 'Weiter zur Bestätigungsseite' 
crud.settings.formstyle='table2cols'
form = crud.create(db.customer)
if form.accepts(request.vars, session, 
 onvalidation=__address_validator):

 
crud.create handles accepting/validating the form, so you shouldn't need to 
call form.accepts separately. Instead, you can specify an onvalidation 
argument in crud.create. From the book:
 

CRUD creates an SQLFORM, but it simplifies the coding because it 
incorporates the creation of the form, the processing of the form, the 
notification, and the redirection, all in one single function.

 
Also, see http://web2py.com/book/default/chapter/07#Methods
 
Anthony


[web2py] Re: Crontab with WSGI

2011-05-13 Thread luifran
http://127.0.0.1:8000/myapp/default/limpiar_eventos work fine in
cherokee web server,
and crontab work fine in web2py´s server but not in cherokee web
server.

On 13 mayo, 10:08, pbreit pbreitenb...@gmail.com wrote:
 Do you have those spaces in there? The cron line should be:

 55 07 * * * root *default/limpiar_eventos

 Are you able to run the function in your browser?

 http://127.0.0.1:8000/myapp/default/limpiar_eventos


[web2py] Re: Conditional Requirement For Form-Fields

2011-05-13 Thread villas
If you want to do anything fancy with the form,  you may be better to
use SQLFORM. It is also convenient to use and gives more flexibility.

If you want to do any helpful processing on the client-side, you
should try javascript,  see Ajax Recipes in the book.

On May 13, 5:10 pm, ma...@rockiger.com rocki...@googlemail.com
wrote:
 What is the most elegant solution to this problem:

 I have a form for address information in an ecommerce application.
 The user can optionally input a different delivery address - this is done
 via radio button.
 In this case the requirement for the delivery address fields change -
 nothing special actually.

 What I've done so far:

 Model:

 db.define_table('customer',
    Field('name', requires=[IS_NOT_EMPTY()], required=True, notnull=True),
    Field('company',default=None),  
    Field('zip', requires=[IS_MATCH('^[0-9]{5}$', error_message='not a zip
 code')], required=True, notnull=True),
    Field('street', requires=[IS_MATCH([0-9a-zA-ZäöüÄÖÜ\- \.]+)],
 required=True, notnull=True),
    Field('city', requires=[IS_MATCH([a-zA-ZäöüÄÖÜ\- \.]+)], required=True,
 notnull=True),
    Field('country', requires=[IS_IN_SET([T('Deutschland'),T('Östereich'),
 T(Schweiz)])], default=Deutschland),
    Field('email',requires= [IS_NOT_EMPTY(), IS_EMAIL(),
    IS_NOT_IN_DB(db,'customer.email')],
    required=True, notnull=True),
    Field('email_confirmation',requires= [IS_NOT_EMPTY(), IS_EMAIL(),
    IS_NOT_IN_DB(db,'customer.email')],
    required=True, notnull=True),
    Field('delivery_address',
 requires=[IS_IN_SET([T('Yes'),T('No')])],widget=SQLFORM.widgets.radio.widget,
  default=No),
    Field('delivery_name',default=None),
    Field('delivery_company',default=None),
    Field('delivery_zip', requires=[IS_EMPTY_OR(IS_MATCH('^[0-9]{0,5}$',
  error_message='not a zip code'))]),
    Field('delivery_street', requires=[IS_EMPTY_OR(IS_MATCH([a-zA-ZäöüÄÖ\-
 \.]+))],default=None),
    Field('delivery_city', requires=[IS_EMPTY_OR(IS_MATCH([a-zA-ZäöüÄÖ\-
 \.]+))],default=None),
    Field('delivery_country',
 requires=[IS_EMPTY_OR(IS_IN_SET([T('Deutschland'),T('Östereich'),
 T(Schweiz)]))],  default=Deutschland),
    Field('timestamp', 'datetime', default=request.now, readable=False,
 writable=False)
 )

 controller:

 def address():
    crud.messages.submit_button = 'Weiter zur Bestätigungsseite'
    crud.settings.formstyle='table2cols'
    form = crud.create(db.customer)
    if form.accepts(request.vars, session, onvalidation=__address_validator):
    response.flash = 'form accepted'
    return dict(form=form)

 def __address_validator(form):
    if not form.vars.email == form.vars.email_confirmation:
        form.errors.email_confirmation = Email-Adressen stimmen nicht
 überein.
    if form.vars.delivery_address == T(Yes):
       if not form.vars.delivery_name:
          form.errors.delivery_name = Bitte gib einen Namen ein.
       if not form.vars.delivery_zip:
          form.errors.delivery_zip = Bitte gib eine Postleitzahl ein.
       if not form.vars.delivery_street:
          form.errors.delivery_street = Bitte gib eine Straße mit Hausnummer
 ein.
       if not form.vars.delivery_city:
          form.errors.delivery_city = Bitte gib eine Stadt ein.
       if not form.vars.delivery_country:
          form.errors.delivery_name = Bitte gib ein Land an.

 This works! But it is not very nice to the user, because the check of the
 optional fields happens after the form is accepted.
 Is there a better way to set the requirements for the optional fields?

 Thanks for help


Re: [web2py] Re: Lighter processing for AJAX requests ?

2011-05-13 Thread Vasile Ermicioi
gevent and uwsgi beats tornado, gevent even beats node.js :)

proof of what I said

http://nichol.as/benchmark-of-python-web-servers

and read comments of this article

http://entitycrisis.blogspot.com/2011/04/pyramid-vs-nodejs_08.html


[web2py] Re: Conditional Requirement For Form-Fields

2011-05-13 Thread ma...@rockiger.com
Thank, I will try this tomorow morning.


[web2py] Re: Conditional Requirement For Form-Fields

2011-05-13 Thread ma...@rockiger.com
Yeah, but server side is needed too :)


Re: [web2py] Lighter processing for AJAX requests ?

2011-05-13 Thread Martín Mulone
If you are interested in the new import-optimizitation-app

check the new entry of my blog:

http://martin.tecnodoc.com.ar/default/post/2011/05/13/20_optimize-your-web2py-app-using-the-new-import-method

2011/5/13 Alexandre Strzelewicz strzelewicz.alexan...@gmail.com

 Hi,

 I use a lot of ajax requests to get data asynchronously but each
 requests are heavy to handle on server side.

 Indeed, when web2py receive an ajax request, it process :
 - web2py python core files
 - ...
 - db.py
 - controller.py

 The result is that for each ajax requests one CPU is taken at 100%...
 whereas node.js take less than 5%

 Is there a solution in order to make ajax requests lighter to
 process ?

 Combining web2py and node.js ?

 Thanks




-- 
 http://martin.tecnodoc.com.ar


[web2py] [Off topic] Re: CarPool web2py anyone?

2011-05-13 Thread Tim Michelsen
 What is illegal?
If you havve to come to Germany use:
http://www.mitfahrgelegenheit.de/

Not illegal and widely used.

Safe trips to anyone!



[web2py] Re: Crontab with WSGI

2011-05-13 Thread pbreit
I doubt it's a Cherokee problem. Do you have a crontab set up on your 
server?

For example, this is what I have in my unix crontab (not web2py crontab). 
Cron is still a little confusing to me.

MAILTO=c...@myserver.com

0-59/1 * * * * cd /var/web2py  python web2py.py -C -D 1  /dev/null 21


Re: [web2py] Re: Gigya - Janrain alternative

2011-05-13 Thread ron_m
Pricing by an accountant, no offence to accountants - hmm 1000 people that's 
only $15/year per person I am sure is someone's way of thinking. I might see 
a mid size company going for it if they wanted to outsource authentication. 
Too much for my pockets. :-)


Re: [web2py] Lighter processing for AJAX requests ?

2011-05-13 Thread pbreit
Good writeup, thanks, Martin.

The things that still confuse me are:
1) when and why to user current
2) where to put imports. since in Python we've always been told to put 
them at top of file. But it looks like they need to go in the def function() 
in order to not be loaded when other functions run.


[web2py] Re: Crontab with WSGI

2011-05-13 Thread luifran
No , only in web2py, not in cherokee.
Where I write this code?
0-59/1 * * * * cd /var/web2py  python web2py.py -C -D 1  /dev/null
21


On 13 mayo, 15:02, pbreit pbreitenb...@gmail.com wrote:
 I doubt it's a Cherokee problem. Do you have a crontab set up on your
 server?

 For example, this is what I have in my unix crontab (not web2py crontab).
 Cron is still a little confusing to me.

 MAILTO=c...@myserver.com

 0-59/1 * * * * cd /var/web2py  python web2py.py -C -D 1  /dev/null 21


[web2py] Re: Crontab with WSGI

2011-05-13 Thread pbreit
I don't really understand how the web2py cron an external cron work 
together. I have a crontab in my application cron folder that appears to run 
when I'm running web2py on my Mac.

But on my server, I have a regular crontab file (set up with sudo -u 
www-data crontab -e) that executes web2py to run the crons.

http://web2py.com/book/default/chapter/04?search=crontab#Cron

It may be that when running Web2py with WSGI, web2py internal cron is 
disabled. I jsut don't really know for sure unfortunately.


[web2py] Re: Crontab with WSGI

2011-05-13 Thread pbreit
Actually I'm looking at my cron right now and am pretty confused. Does 
anyone know how external cron works exactly?

In my /etc/crontab, I have:
0-59/1 * * * * cd /var/web2py  python web2py.py -C -D 1  /dev/null 21

In /var/web2py/applications/init/cron/crontab, I have:
*/6 * * * * root *cron/release_pending_orders
*/1 * * * * root *cron/expire_items
*/1 * * * * root *cron/mail_queue
*/1 * * * * root *cron/email_watchlist
0 2 * * * root *cron/google_feed
30 2 * * * root *cron/bing_feed

My setup is Nginx + uWSGI + Ubuntu

The */1 jobs seem to be running but I'm not sure the other ones are.


[web2py] Re: login fails for ajax components

2011-05-13 Thread pbreit
This isn't fool-proof, though, right? Since anyone could add a cid arg to 
the URL?

I just ran into a security problem where a component is revealing a whole 
auth_user record!

See: http://pricetack.com/components/order_summary/1

How do I close up this problem? Do I need to specify the only fields I need 
in the select()? Other solution?


[web2py] Security problem with LOAD()

2011-05-13 Thread pbreit
I just ran into a security problem where a component is revealing a whole 
auth_user record!

See: http://pricetack.com/components/order_summary/1

What is the preferred way to avoid this? I could specify individual fields 
in my select(). There was a recommendation to decorate the component with 
@auth.requires(request http://web2py.com/book/default/docstring/request.
cid). Would that close up the loophole? Any other solutions?


[web2py] profiler: ImportError: No module named pstats?

2011-05-13 Thread Philip
I am trying to use the web2py profiler (which I haven't used before).
I tried starting web2py with the -F option and a filename, and I get
the following error:

ImportError: No module named pstats

Any ideas on why it isn't working? I couldn't find any documentation
for the profiler feature other than a few posts on this group and the
listing of -F as one of the command line options.

Thanks,
Philip


[web2py] Re: Security problem with LOAD()

2011-05-13 Thread pbreit
It looks like one solution is to get rid of the generic.load file. And I'm 
thinking that I don't want any of the generic.* files in production.

[web2py] Re: Crontab with WSGI

2011-05-13 Thread pbreit
Now I am wondering if I should just have crontab wget my cron functions into 
dev/null?

0-59/1 * * * * wget http://localhost/myapp/cron/cronjob  /dev/null 21

Seems kinda lo-tech. Will this cause any problems?


[web2py] Re: Security problem with LOAD()

2011-05-13 Thread pbreit
I closed up the hole so you won't see the problem anymore. But I feel like a 
need to rigorously review further potential problems.

[web2py] Re: login fails for ajax components

2011-05-13 Thread Anthony
On Friday, May 13, 2011 7:37:29 PM UTC-4, pbreit wrote: 

 This isn't fool-proof, though, right? Since anyone could add a cid arg to 
 the URL?

 
You're right, I don't think checking for request.cid is fool-proof, but it's 
not as easy as adding a cid argument to the URL (it checks for the 
existence of request.cid, not whether cid is in request.args). It appears 
that request.cid is filled in if there is a 'web2py-component-element' 
header in the incoming HTTP request (which would be put there by 
the 'web2py_ajax_page' function in web2py_ajax.html) -- so I think someone 
would have to hack the HTTP header before sending the request in order to 
defeat the @auth.requires(request.cid) check. I suppose requiring login is 
probably safest. Maybe I'm missing something, though.
 
Anthony
 


[web2py] Re: Security problem with LOAD()

2011-05-13 Thread Anthony
Since we can no longer see the problem, can you explain it in more detail?

On Friday, May 13, 2011 8:47:40 PM UTC-4, pbreit wrote:

 I closed up the hole so you won't see the problem anymore. But I feel like 
 a need to rigorously review further potential problems.



[web2py] web2py

2011-05-13 Thread msaddicted
Hello all,
I'm absolutely new to web2py and I'm trying to build an app to let web
users explore data views (ordering columns, search for content,
paginating rows) and have crud operations on specific tables (one or
more at the same time). I've checked out WebGrid for web2py or jqgrid,
but every solution have some tradeoffs.
Is out there some more complete example that use specific web2py
objects (SQLFORM, CRUD, etc.) I can follow?

Thank you, msaddicted


[web2py] Bug using plugin_mmodal and calendar widget

2011-05-13 Thread Jesús Martínez
Hello:

I am using plugin_mmodal to show a html form. This html form shows a
database table  which has two datatime fields.

When plugin_mmodal loads this html form and you clicks in a datetime field,
calendar widget is not showed.

This bug is caused by an inconsitence css parameter: z-index. plugin_mmodal
has z-index value greater or equal to 1000, but calendar has this value
greater or equal to 90. So that, the calendar widget is showed but it is
hidden by plugin_mmodal widget.

If you change the z-index value in plugin-mmodal using a value less than 90
(for example, changing 1001 by 81 and 1002 by 82) in plugin_mmodal.py, line
32, then calendar widget is showed.

I hope this will be usefull.

My first two cents :) .

Regards


[web2py] pass request.args(0) to sqlform

2011-05-13 Thread Andrew Evans
I am trying to pass request.args(0) to sqlform so it adds an entry when
submitted based on the project_id value any ideas?

my database code

db.define_table('tasks',
Field('userinfo', db.auth_user, default=auth.user_id, readable=False,
writable=False),
Field('project_id', db.project, requires = IS_IN_DB(db, db.project.id,
'%(project_title)s'), readable=False, writable=False),
Field('isFinished', 'boolean', default=False, readable=False,
writable=False),
Field('task_title', length=256, requires = IS_NOT_EMPTY()),
Field('task_description', 'text'),
Field('created_on', 'datetime', default=datetime.datetime.now(),
readable=False, writable=False))



My Link

a href={{=URL('tasks', 'add_task', args=row.id)}} Add Task /a


my tasks add_task function

@auth.requires_login()
def add_task():
form = SQLFORM(db.tasks,)
if form.accepts(request.vars, session):
session.flash = 'You successfully added a task'
return dict(form=form)
elif form.errors:
response.flash = 'Please correct highlighted fields'
return dict(form=form)
else:
response.flash = 'Please add images by filling out this form'
return dict(form=form)


Sorry I am having a hard time explaining it Let me know if you need better
info


[web2py] Re: New Import Method Incompatible with Python 2.4

2011-05-13 Thread Ross Peoples
I think I figured out how to make it work, but I don't know if it breaks 
anything. In conjunction with the change above, I also did this:

Changed custom_import.py line 49 from:

return self.std_python_importer(name, globals, locals, fromlist, level)

To this:

if sys.version_info[:2] == (2, 4):
return self.std_python_importer(name, globals, locals, fromlist)
else:
return self.std_python_importer(name, globals, locals, fromlist, level)


[web2py] Re: Security problem with LOAD()

2011-05-13 Thread pbreit
If you access a component without the .load extension, it automatically 
uses the generic.load view which is a BEAUTIFY of all the returned data. 
So since my data included an auth_user record, all the auth_user fields were 
displayed in the browser window, including the password (encrypted, but 
still!).

Are there any other situations where manipulating the extension or URL can 
lead to data disclosure like this?

Is it a best practice to lock down queries by only selecting fields that you 
need? I guess ordinarily it is suggested to avoid select * so maybe that's 
what I need to do.


[web2py] check if len error in view

2011-05-13 Thread 黄祥
hi,

i've just followed Post preview like you have in blogs. on
http://www.web2pyslices.com/main/slices/take_slice/90

model:
db.define_table('post',
Field('body',
  'text'
  )
)

controller:
def index():
posts = db(db.post.id  0).select(orderby=~db.post.id)
return dict(posts = posts)

view:
{{for post in posts:}}
{{if len(post.body)  1000:}}
{{index = post.body.find(/p, 1000, -1) + 4}}
{{post.body = post.body[0:index]}}
{{=post.body}}

when i tried to change the function on the view, it return an error :

Traceback (most recent call last):
  File /home/sugizo/web2py/gluon/rocket.py, line 1064, in run
self.run_app(conn)
  File /home/sugizo/web2py/gluon/rocket.py, line 1531, in run_app
self.environ = environ = self.build_environ(sock_file, conn)
  File /home/sugizo/web2py/gluon/rocket.py, line 1363, in
build_environ
request = self.read_request_line(sock_file)
  File /home/sugizo/web2py/gluon/rocket.py, line 1138, in
read_request_line
raise SocketTimeout(Socket timed out before request.)
SocketTimeout: Socket timed out before request.

is there any idea to solve this?
thank you so much before.


[web2py] Re: pass request.args(0) to sqlform

2011-05-13 Thread pbreit
I think this will do it:

def add_task():
form = SQLFORM(db.tasks)
form.vars.project_id = request.args(0)
if form.accepts(request.vars, session):
...


[web2py] Re: check if len error in view

2011-05-13 Thread pbreit
If you're going to do it in the view, you need some {{pass}} statements to 
close up the for and the if blocks.

[web2py] Should passwords be salted?

2011-05-13 Thread pbreit
Should passwords be salted? I get nervous when I look at my data and the 
same password encrypts to the same hash. How would I do that with CRYPT()?

[web2py] Re: Security problem with LOAD()

2011-05-13 Thread Anthony
On Friday, May 13, 2011 9:47:41 PM UTC-4, pbreit wrote: 

 If you access a component without the .load extension, it automatically 
 uses the generic.load view which is a BEAUTIFY of all the returned data. 
 So since my data included an auth_user record, all the auth_user fields were 
 displayed in the browser window, including the password (encrypted, but 
 still!).

 
Are you talking about calling the component via a regular URL (i.e., not via 
the LOAD function) without the .load extension? In that case, web2py should 
assume a .html extension, and assuming there is no func.html view, it will 
use generic.html (not generic.load). The only case in which it should use 
generic.load is if you explicitly call it with the .load extension and there 
is no func.load view.
 
In any case, you still have the same problem with generic.html, which also 
does a BEAUTIFY (and probably a similar problem with all the generic views). 
This is a good observation -- the generic views can be dangerous if your 
function returns more data than you really want to expose. All a user has to 
do is call your function with any extension for which you have not defined 
an explicit view, and they'll get the generic view, which may show more than 
you want. I've seen some people use return locals() instead of returning a 
dict with explicit values, which may be dangerous if locals() includes some 
other variables that you don't want to expose to the public. It may be wise 
to return in the dict only objects that you truly want exposed by the 
function.
 
Anthony
 


Re: [web2py] Re: check if len error in view

2011-05-13 Thread Stifan Kristi
it's my fault, thank you so much for corrected me pbreit.

On Sat, May 14, 2011 at 10:16 AM, pbreit pbreitenb...@gmail.com wrote:

 If you're going to do it in the view, you need some {{pass}} statements to
 close up the for and the if blocks.


[web2py] Install in hostgator

2011-05-13 Thread pepe_eloy
Hello!

Recently a customer bought a hosting plan (business) with hostgator.
I'm developing for him a web2py application, I have doubts of how to
deploy it. Somebody can help me? The application runs well in
localhost (ubuntu).

Thanks in advance



[web2py] Case sensitive email register

2011-05-13 Thread luis diaz
in the user registration process
the system take the following email as a user
different

use...@hotx.com
use...@hotx.com

this sharing is not to my liking.

I think it would be appropriate to add the email Requires
IS_LOWER the option ()


[web2py] Re: Case sensitive email register

2011-05-13 Thread pbreit
I would agree that email addresses should be handled as case-insensitive by 
default. The IS_LOWER() validator works when registering but I'm not sure 
what to do when logging in.

[web2py] Re: Install in hostgator

2011-05-13 Thread pbreit
Maybe have a look here:
https://groups.google.com/d/topic/web2py/h8uLiDCerx0/discussion

But I would definitely recommend Webfaction or Ubuntu in the cloud. Zero 
reason to mess around with lousy hosting providers.


[web2py] Re: Security problem with LOAD()

2011-05-13 Thread pbreit
Yeah, it looks like it is the generic.html file. Probably this loophole 
should be closed by default. Perhaps it could check if it's on localhost or 
something.

I was just returning someone's first name but the record included all 
auth_user fields.


[web2py] Discussion: Python 2.4 Support

2011-05-13 Thread Ross Peoples
I am developing a web2py app that uses a third party python module that only 
works on Python 2.4.4. Basically, we are using we2py as a front end for an API. 
Since recently updating to trunk, I noticed that several things didn't seem to 
work anymore. I submitted patches to Massimo and he told me that there was 
discussion before about dropping Python 2.4 support.

I am wondering who else is using Python under 2.4? I am hoping that we can 
continue to support 2.4. The latest patches I provided only make minor changes 
to support 2.4, so it's really not too bad to support it, even with the latest 
trunk.

Thought? Concerns?

Thanks


[web2py] Re: Discussion: Python 2.4 Support

2011-05-13 Thread pbreit
I'm curious why you are not able to move to a new version. I'm also curious 
why obfuscating the code is a requirement.

Both of these requirements are exceedingly rare so I think we need to 
understand what the situation is that leads to these requirements so that we 
can evaluate reasonably.


[web2py] Facebook community group for web2py and web2pyslices

2011-05-13 Thread Bruno Rocha
Hi,

I just created a new web2py group on facebook here:
http://www.facebook.com/home.php?sk=group_107564079311060

http://www.facebook.com/home.php?sk=group_107564079311060you can also
publish there bys ending a mail to web...@groups.facebook.com

web...@groups.facebook.comweb2pyslices 2.0 is comming so I created a
facebook page for this too:
http://www.facebook.com/pages/web2pyslices/200906586611483

BTW: I am testing wibiya toolbar so when you go to the
www.web2pyslices.comyou can see a footer toolbar with many social
links as a chat and some share
options, take a look!

Tks

Bruno Rocha
[ About me: http://zerp.ly/rochacbruno ]