[web2py] New web2py app: Airea.me

2011-05-27 Thread demetrio
Hi everyone,

i'm very proud to announce Airea.me (in english it's something like
aerate me).

This application was made into the challenge abredatos. A
competition held in Spain, based on the creation of an application
within 48 hours using open data.

Our team, decided to use web2py, jQuery, jQueryMobile and some of the
Google APIs (maps and charts).

We use the data available in the Basque Government in Spain about the
air quality.And the data are treated as measured by the World Health
Organization

All the code is available here: https://github.com/plexxoo/airea.me
And this is the development team: http://live.abredatos.es/teams/41

The application is forced to spanish, because it was imposible to us,
to make it multilingual (especially the big texts) in only 48 hours.
Although some text strings are in English using the translation system
web2py.

We know that there are several bugs, but we can not touch the code yet
to decide a winner of the challenge.

You can access the application here: http://airea.me from your
computer or from a mobile device ;)

Best Regards.
Daniel.


[web2py] csv file name and other...

2011-05-27 Thread Manuele Pesenti

Hi,

first question:

following what reported in the doc
http://www.web2py.com/book/default/chapter/09?search=export_to_csv

I have implemented my export view but I realized that apparently I have 
no file name control and it depends on the browser I use even if I 
called my view export.csv. With Google Chrome I get download and 
with iceweesel an arbitrary random characters sequence such as 
n5oP+nWj.csv.part.

How can I fix the file name?

second question:
what if I want firstly view the data extracted in a table (using 
SQLTABLE or powerTable plugin) and than download them without performing 
the query again?


I thought to save the query result in session but when I use it to write 
my csv it says:

AttributeError: 'list' object has no attribute 'export_to_csv_file'

Thank you
Cheers

Manuele


[web2py] HINT: Use DROP ... CASCADE to drop the dependent objects too.

2011-05-27 Thread Johann Spies
How do I do that using DAL?

Using db.executesql() does not update web2py/app/dabases/

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] Login button should say Login...

2011-05-27 Thread Phyo Arkar
Should be fixed at default too

On Fri, May 27, 2011 at 2:57 AM, Bruno Rocha rochacbr...@gmail.com wrote:

   def user():

   *form = auth() form.element(_type='submit')['value'] = 'Login'*
 return dict(form=form)


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



 On Thu, May 26, 2011 at 4:52 PM, Jason Brower encomp...@gmail.com wrote:

 Don't you think the Login button should say Login rather than Submit?  It
 makes more sence and I got 4 people that told me they were confused when
 they saw the button say that.  So with Auth, could we change the name of the
 button to Login?
 Is there a quick fix for that?

 Best Regards,
 Jason Brower





[web2py] How do I check if a user account is blocked/disabled?

2011-05-27 Thread Carl
I know I can use this code:
users = db(db.auth_user.id==userId).select(db.auth_user.ALL)
if users:
return users[0]['registration_key'] not in ['disabled',
'blocked']
return False

to check if an account is disabled.

Is there a function/method I can call to check this instead? It feels
odd to be writing code so intimate with under the hood details.
Similarly, do I write directly to the db to update 'registration_key'
to disabled or is there a method for that too?


[web2py] Re: How do I check if a user account is blocked/disabled?

2011-05-27 Thread Ross Peoples
That is how I do it. As far as I know, setting registration_key to 
'disabled' is the only way for web2py to deny a log in for someone using 
Auth. When I need to set this or check it, I just wrap the code into a 
generic is_disabled() method to do the checking in case a better way 
presents it self in the future, I only need to change that method.

You could do something like this at the end of your model:

db.auth_user.is_enabled = lambda r: r.registration_key != 'disabled'

Then whenever you need to check if a user account is enabled:

rows = db().select(db.auth_user.ALL)
for row in rows:
if db.auth_user.is_enabled(row):
# account is enabled
else:
# account is disabled

By the way, I noticed that you used 'users[0]' in your code. I don't know if 
you are aware of this, but web2py has a cleaner method of selecting a single 
row:

user = db(db.auth_user.id==userId).select().first()

Using first() is the same thing as users[0], it's just a lot cleaner and 
allows you to easily check for None in case there were no records found.


[web2py] Re: New web2py app: Airea.me

2011-05-27 Thread Massimo Di Pierro
:-)

On May 27, 3:11 am, demetrio dgzabal...@gmail.com wrote:
 Hi everyone,

 i'm very proud to announce Airea.me (in english it's something like
 aerate me).

 This application was made into the challenge abredatos. A
 competition held in Spain, based on the creation of an application
 within 48 hours using open data.

 Our team, decided to use web2py, jQuery, jQueryMobile and some of the
 Google APIs (maps and charts).

 We use the data available in the Basque Government in Spain about the
 air quality.And the data are treated as measured by the World Health
 Organization

 All the code is available here:https://github.com/plexxoo/airea.me
 And this is the development team:http://live.abredatos.es/teams/41

 The application is forced to spanish, because it was imposible to us,
 to make it multilingual (especially the big texts) in only 48 hours.
 Although some text strings are in English using the translation system
 web2py.

 We know that there are several bugs, but we can not touch the code yet
 to decide a winner of the challenge.

 You can access the application here:http://airea.mefrom your
 computer or from a mobile device ;)

 Best Regards.
 Daniel.


[web2py] Re: csv file name and other...

2011-05-27 Thread Massimo Di Pierro
response.headers['Content-Disposition'] =
'attachment;filename=thisfile.csv'

On May 27, 4:21 am, Manuele Pesenti manuele.pese...@gmail.com wrote:
 Hi,

 first question:

 following what reported in the 
 dochttp://www.web2py.com/book/default/chapter/09?search=export_to_csv

 I have implemented my export view but I realized that apparently I have
 no file name control and it depends on the browser I use even if I
 called my view export.csv. With Google Chrome I get download and
 with iceweesel an arbitrary random characters sequence such as
 n5oP+nWj.csv.part.
 How can I fix the file name?

 second question:
 what if I want firstly view the data extracted in a table (using
 SQLTABLE or powerTable plugin) and than download them without performing
 the query again?

 I thought to save the query result in session but when I use it to write
 my csv it says:
 AttributeError: 'list' object has no attribute 'export_to_csv_file'

 Thank you
 Cheers

         Manuele


[web2py] Re: HINT: Use DROP ... CASCADE to drop the dependent objects too.

2011-05-27 Thread Massimo Di Pierro
Are you doing this from a shell or script? You neeb db.commit()

On May 27, 5:47 am, Johann Spies johann.sp...@gmail.com wrote:
 How do I do that using DAL?

 Using db.executesql() does not update web2py/app/dabases/

 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: How do I check if a user account is blocked/disabled?

2011-05-27 Thread Carl Roach
Thanks. And thanks for .first()



On 27 May 2011, at 13:14, Ross Peoples ross.peop...@gmail.com wrote:

 That is how I do it. As far as I know, setting registration_key to 'disabled' 
 is the only way for web2py to deny a log in for someone using Auth. When I 
 need to set this or check it, I just wrap the code into a generic 
 is_disabled() method to do the checking in case a better way presents it self 
 in the future, I only need to change that method.
 
 You could do something like this at the end of your model:
 
 db.auth_user.is_enabled = lambda r: r.registration_key != 'disabled'
 
 Then whenever you need to check if a user account is enabled:
 
 rows = db().select(db.auth_user.ALL)
 for row in rows:
 if db.auth_user.is_enabled(row):
 # account is enabled
 else:
 # account is disabled
 
 By the way, I noticed that you used 'users[0]' in your code. I don't know if 
 you are aware of this, but web2py has a cleaner method of selecting a single 
 row:
 
 user = db(db.auth_user.id==userId).select().first()
 
 Using first() is the same thing as users[0], it's just a lot cleaner and 
 allows you to easily check for None in case there were no records found.


[web2py] Re: Login button should say Login...

2011-05-27 Thread Massimo Di Pierro
if auth.messages.submit_button = 'Login'

On May 27, 6:26 am, Phyo Arkar phyo.arkarl...@gmail.com wrote:
 Should be fixed at default too







 On Fri, May 27, 2011 at 2:57 AM, Bruno Rocha rochacbr...@gmail.com wrote:
    def user():

    *form = auth() form.element(_type='submit')['value'] = 'Login'*
  return dict(form=form)

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

  On Thu, May 26, 2011 at 4:52 PM, Jason Brower encomp...@gmail.com wrote:

  Don't you think the Login button should say Login rather than Submit?  It
  makes more sence and I got 4 people that told me they were confused when
  they saw the button say that.  So with Auth, could we change the name of 
  the
  button to Login?
  Is there a quick fix for that?

  Best Regards,
  Jason Brower


Re: [web2py] Re: HINT: Use DROP ... CASCADE to drop the dependent objects too.

2011-05-27 Thread Johann Spies
On 27 May 2011 14:25, Massimo Di Pierro massimo.dipie...@gmail.com wrote:

 Are you doing this from a shell or script? You neeb db.commit()


In the shell.

Yes I know that, but when I have  dropped a table in this way still have to
delete the related file in app/databases before web2py will create it
again.

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: csv file name and other...

2011-05-27 Thread Manuele Pesenti

On 27/05/2011 14:25, Massimo Di Pierro wrote:

response.headers['Content-Disposition'] =
'attachment;filename=thisfile.csv'



thankyou Massimo... I had just found the answer in the list archives.

Any suggestion about the second question?

Is it possible to store somewhere the query in order to pass it first to 
SQLTABLE and let the user save it results in a csv file?


thank you again
Cheers

Manuele


Re: [web2py] Re: New web2py app: Airea.me

2011-05-27 Thread Stifan Kristi
great, nice application, hope you win the competition
\(^o^)/


[web2py] Background process not working...

2011-05-27 Thread Jason Brower

I am running this:

python web2py.py -S welcome -M -N -R 
applications/welcome/private/email_sender.py


I am trying to send email with this...

import time
while True:
print Checking for new mails...
rows = db(db.invitations.sent_email == False).select()
for invite in rows:
if mail.send(to=invite.email,
subject=invite.subject,
message=invite.message):
row.update_record(sent_email = True)
print Sent the email!
else:
row.update_record(sent_email = False)
db.commit()
time.sleep(10) # check every minute
---
But it seems that I don't mail object imported... but I do...
mail = Mail()  # mailer
in my 0db.py file --- it does have a 0 yes. :)

What am I missing?  I am trying to do this...
http://web2py.com/book/default/chapter/04#Background-Processes-and-Task-Queues
---
Best Regards,
Jason Brower


[web2py] Re: Background process not working...

2011-05-27 Thread Anthony
Are you sure you have configured Mail properly? See 
http://web2py.com/book/default/chapter/08#Auth-and-Mail. Are you able to 
send an email from a controller?
 

On Friday, May 27, 2011 9:05:00 AM UTC-4, encompass wrote:

 I am running this:
 
 python web2py.py -S welcome -M -N -R 
 applications/welcome/private/email_sender.py
 
 I am trying to send email with this...
 
 import time
 while True:
  print Checking for new mails...
  rows = db(db.invitations.sent_email == False).select()
  for invite in rows:
  if mail.send(to=invite.email,
  subject=invite.subject,
  message=invite.message):
  row.update_record(sent_email = True)
  print Sent the email!
  else:
  row.update_record(sent_email = False)
  db.commit()
  time.sleep(10) # check every minute
 ---
 But it seems that I don't mail object imported... but I do...
 mail = Mail()  # mailer
 in my 0db.py file --- it does have a 0 yes. :) 

 What am I missing?  I am trying to do this...

 http://web2py.com/book/default/chapter/04#Background-Processes-and-Task-Queues
 ---
 Best Regards,
 Jason Brower



[web2py] Re: New web2py app: Airea.me

2011-05-27 Thread Anthony
Very nice. Just added it to http://web2py.com/poweredby. :-)
 
Anthony

On Friday, May 27, 2011 4:11:09 AM UTC-4, demetrio wrote:

 Hi everyone, 

 i'm very proud to announce Airea.me (in english it's something like 
 aerate me). 

 This application was made into the challenge abredatos. A 
 competition held in Spain, based on the creation of an application 
 within 48 hours using open data. 

 Our team, decided to use web2py, jQuery, jQueryMobile and some of the 
 Google APIs (maps and charts). 

 We use the data available in the Basque Government in Spain about the 
 air quality.And the data are treated as measured by the World Health 
 Organization 

 All the code is available here: https://github.com/plexxoo/airea.me 
 And this is the development team: http://live.abredatos.es/teams/41 

 The application is forced to spanish, because it was imposible to us, 
 to make it multilingual (especially the big texts) in only 48 hours. 
 Although some text strings are in English using the translation system 
 web2py. 

 We know that there are several bugs, but we can not touch the code yet 
 to decide a winner of the challenge. 

 You can access the application here: http://airea.me from your 
 computer or from a mobile device ;) 

 Best Regards. 
 Daniel.



Re: [web2py] Re: csv file name and other...

2011-05-27 Thread Anthony
On Friday, May 27, 2011 8:39:02 AM UTC-4, Manuele wrote: 

 On 27/05/2011 14:25, Massimo Di Pierro wrote:
  response.headers['Content-Disposition'] =
  'attachment;filename=thisfile.csv' 


 thankyou Massimo... I had just found the answer in the list archives. 

 Any suggestion about the second question? 

 Is it possible to store somewhere the query in order to pass it first to 
 SQLTABLE and let the user save it results in a csv file?

You could cache the query: 
http://web2py.com/book/default/chapter/06#Caching-Selects
 


[web2py] Re: domain and download function problem

2011-05-27 Thread Joseph.Piron
So I tried adding c='default' in the URL call or default_controller in
the BASE router, that does not work.
I also tried with host=True in the call, does not either.

Now I activated the server logging and I can see it looks for /
download/stock etc in another directory ... :s I really don't
understand ??

On May 26, 3:31 pm, Anthony abasta...@gmail.com wrote:
 On Wednesday, May 25, 2011 5:24:49 AM UTC-4, Joseph.Piron wrote:

  routers = dict(
  BASE = dict(
  domains = {
  'stock': 'stock'
  }
  )
  )

  and now, I can access this application athttp://stock, but...
  Now the link to download the images aren't correct anymore:

  the link accessed fromhttp://stock/stock: img src=/stock/download/
  stockItems.photo.bc4b40cb067d4cb8.696d677265732e6a706567.jpeg
  class=photo

  the link accessed fromhttp://stock: img src=/download/
  stockItems.photo.bc4b40cb067d4cb8.696d677265732e6a706567.jpeg
  class=photo

 Are you saying the image doesn't appear when src=/download/...? If so,
 what happens if you add default_controller='default' to your BASE router, or
 if you specify c='default' in your URL call?


[web2py] Re: domain and download function problem

2011-05-27 Thread Joseph.Piron
Ok
I'm not alone on this server and someone had created an alias /
download in the conf.d apache directory...
Life's tough sometimes.. :)

On May 26, 3:31 pm, Anthony abasta...@gmail.com wrote:
 On Wednesday, May 25, 2011 5:24:49 AM UTC-4, Joseph.Piron wrote:

  routers = dict(
  BASE = dict(
  domains = {
  'stock': 'stock'
  }
  )
  )

  and now, I can access this application athttp://stock, but...
  Now the link to download the images aren't correct anymore:

  the link accessed fromhttp://stock/stock: img src=/stock/download/
  stockItems.photo.bc4b40cb067d4cb8.696d677265732e6a706567.jpeg
  class=photo

  the link accessed fromhttp://stock: img src=/download/
  stockItems.photo.bc4b40cb067d4cb8.696d677265732e6a706567.jpeg
  class=photo

 Are you saying the image doesn't appear when src=/download/...? If so,
 what happens if you add default_controller='default' to your BASE router, or
 if you specify c='default' in your URL call?


[web2py] Versioning bug with wsgi

2011-05-27 Thread Joseph.Piron
Hi all,

a little annoying bug I encountered a minute ago:

I tried the commit in mercurial versioning for an application running
apache+wgsi_mod, and I got a ticket and this error embedded:

IOError: sys.stdout access restricted by mod_wsgi: sys.stdout access
restricted by mod_wsgi

A quick check in the documentation explains:

IOError: sys.stdout access restricted by mod_wsgi
This is because portable WSGI applications should not write to
sys.stdout or use the 'print' statement without specifying an
alternate file object besides sys.stdout as the target. This
restriction can be disabled for the whole server using the
WSGIRestrictStdout directive, or by mapping sys.stdout to sys.stderr
at global scope within in the WSGI application script file.

Should not this issue be handled ?


[web2py] Re: Versioning bug with wsgi

2011-05-27 Thread Massimo Di Pierro
In wsgihandler if you add:

sys.stdout=sys.stderr

does it solve the problem? If so I will add this to trunk.


On May 27, 9:04 am, Joseph.Piron joseph.pi...@gmail.com wrote:
 Hi all,

 a little annoying bug I encountered a minute ago:

 I tried the commit in mercurial versioning for an application running
 apache+wgsi_mod, and I got a ticket and this error embedded:

 IOError: sys.stdout access restricted by mod_wsgi: sys.stdout access
 restricted by mod_wsgi

 A quick check in the documentation explains:

 IOError: sys.stdout access restricted by mod_wsgi
 This is because portable WSGI applications should not write to
 sys.stdout or use the 'print' statement without specifying an
 alternate file object besides sys.stdout as the target. This
 restriction can be disabled for the whole server using the
 WSGIRestrictStdout directive, or by mapping sys.stdout to sys.stderr
 at global scope within in the WSGI application script file.

 Should not this issue be handled ?


[web2py] Re: New web2py app: Airea.me

2011-05-27 Thread JorgeRpo
Very cool

How did you manage to do the statistical graphics??


Re: [web2py] Re: experimental... .pdf

2011-05-27 Thread Mariano Reingart
Regarding PyFPDF:

Headers should be rendered.

Tables need at least a first  TH, prior any TD, who indicates column
width (and it is wise to use THEAD and TBODY when you have multiple
pages), see:
http://code.google.com/p/pyfpdf/wiki/WriteHTML

table border=0 align=center width=50%
theadtrth width=30%Header 1/thth width=70%header
2/th/tr/thead
tbody
trtdcell 1/tdtdcell 2/td/tr
trtdcell 2/tdtdcell 3/td/tr
/tbody
/table

I'm planning to fix this issues, to cover more basic html conversions.

You can see what can do pyfpdf in this file:
http://pyfpdf.googlecode.com/files/html.pdf

BTW, did you see the new visual designer of pdf templates?

http://code.google.com/p/pyfpdf/wiki/Templates?ts=1306512231updated=Templates#Designer

It is a wx application, and I'm planning to connect it using DAL to
ease template/report generation (I think this is much easier and
manageable way  than converting html).

Best regards,

Mariano Reingart
http://www.sistemasagiles.com.ar
http://reingart.blogspot.com



On Fri, May 27, 2011 at 1:35 AM, Massimo Di Pierro
massimo.dipie...@gmail.com wrote:
 There are still problems...it does not render headers and tables...

 On May 26, 11:06 pm, Massimo Di Pierro massimo.dipie...@gmail.com
 wrote:
 I just made a change to trunk about. the new generic.pdf uses pyfpdf
 and it is smart in locating files for including images.

 massimo

 On May 26, 10:44 pm, Christopher Steel chris.st...@gmail.com wrote:







  I think report.pdf required reportlab? Massimo had an application for
  creating forms that used markmin and latex.

  This web2py app includes a plugin that implements an assortment of pdf
  stuff (mostly your implementation of pyfpdf and the report.pdf, was
  that a Google thing?.

  Anyway the plugin is handy for testing and experimenting and includes
  some other PDF examples, one with a different font.

 http://code.google.com/p/uc-pyfpdf/

  If you need some testing let me know, I love PDF's

  Cheers,

  Chris

  On May 26, 3:48 pm, Mariano Reingart reing...@gmail.com wrote:

   Putting the following code in generic.pdf and getting report.pdf does 
   not work?
   (also, per default there is a generic.pdf made by massimo that uses
   markmin and latex if I remember it correctly)

   from gluon.contrib.pyfpdf import FPDF, HTMLMixin
   from gluon.sanitizer import sanitize

   class MyFPDF(FPDF, HTMLMixin):
      pass

   pdf=MyFPDF()
   pdf.add_page()
   html=response.render('%s/%s.html' %
   (request.controller,request.function))
   html = sanitize(html, escape=False)
   pdf.write_html(html)
   response.headers['Content-Type']='application/pdf'
   response.write(pdf.output(dest='S'), escape=False)

   Mariano 
   Reingarthttp://www.sistemasagiles.com.arhttp://reingart.blogspot.comOnThu,
May 26, 2011 at 4:30 PM, luifran lbernalhernan...@yahoo.es wrote:
if I have a view , for example report.html, how I render this view in
pdf with the generic pdf?

On 4 oct 2010, 17:08, Mariano Reingart reing...@gmail.com wrote:
On Sun, Oct 3, 2010 at 1:10 AM, mdipierro mdipie...@cs.depaul.edu 
wrote:

 I am sure this can also be done and better with pyfpdf but I have 
 not
 tried. Perhaps Mariano can help us

Having latest web2py versions (including pyfpdf), write in a 
views/generic.pdf:

 begin file 
{{

from gluon.contrib.pyfpdf import FPDF, HTMLMixin
from gluon.sanitizer import sanitize

class MyFPDF(FPDF, HTMLMixin):
    pass

pdf=MyFPDF()pdf.add_page()
html=response.render('%s/%s.html' %
(request.controller,request.function))
html = sanitize(html, escape=False)pdf.write_html(html)
response.headers['Content-Type']='application/pdf'
response.write(pdf.output(dest='S'), escape=False)

}}

 end file---

At MyFPDF class you can add headers and footers.

The sanitize part is to strip some HTML tags that cannot be rendered
(ie. javascript).

As some DIVs contents and similar may still pass (like menus), a
better alternative may be render only certains portions of the page in
a custom view:

pdf.write_html(str(XML(CENTER(section), sanitize=False)))

Best regards,

Mariano 
Reingarthttp://www.sistemasagiles.com.arhttp://reingart.blogspot.com


Re: [web2py] Re: New web2py app: Airea.me

2011-05-27 Thread Daniel Gonzalez
With the Google APIs

In this case with these two:
http://code.google.com/apis/ajax/playground/?type=visualization#line_chart
http://code.google.com/apis/ajax/playground/?type=visualization#motion_chart


El vie, 27-05-2011 a las 09:06 -0700, JorgeRpo escribió:
 Very cool
 
 How did you manage to do the statistical graphics??




[web2py] Where is LOAD?

2011-05-27 Thread David J.

I am looking for the LOAD helper?
I checked gluon/http.py and all other files; but I cant seem to locate it.

I wanted to see how to modify the text that says Loading...
I wanted to include one of those mac like scrollers gifs.

Any ideas?




[web2py] Re: Best way to sync development and production sites.

2011-05-27 Thread pbreit
There are a couple approaches to consider. What I do is set up a central 
repo on Bitbucket, hg push changes from my PC to Bitbucket and hg pull 
changes from Bitbucket to my production server.

You can do the updates manually but I like using Fabric so you don't have to 
SSH in to your server all the time.


[web2py] Re: Where is LOAD?

2011-05-27 Thread Massimo Di Pierro
It is in compileapp.py called LoadFactory.

Anyway, I just added to trunk

LOAD(...,content=IMG(_src='myanimated.gif'))

On May 27, 3:29 pm, David J. da...@styleflare.com wrote:
 I am looking for the LOAD helper?
 I checked gluon/http.py and all other files; but I cant seem to locate it.

 I wanted to see how to modify the text that says Loading...
 I wanted to include one of those mac like scrollers gifs.

 Any ideas?


Re: [web2py] Re: Background process not working...

2011-05-27 Thread Jason Brower
At least requesting a new password works.  I assume it uses those 
settings as well.

BR,
Jason Brower

On 05/27/2011 04:30 PM, Anthony wrote:
Are you sure you have configured Mail properly? See 
http://web2py.com/book/default/chapter/08#Auth-and-Mail. Are you able 
to send an email from a controller?


On Friday, May 27, 2011 9:05:00 AM UTC-4, encompass wrote:

I am running this:

python web2py.py -S welcome -M -N -R
applications/welcome/private/email_sender.py

I am trying to send email with this...

import time
while True:
 print Checking for new mails...
 rows = db(db.invitations.sent_email == False).select()
 for invite in rows:
 if mail.send(to=invite.email,
 subject=invite.subject,
 message=invite.message):
 row.update_record(sent_email = True)
 print Sent the email!
 else:
 row.update_record(sent_email = False)
 db.commit()
 time.sleep(10) # check every minute
---
But it seems that I don't mail object imported... but I do...
mail = Mail()  # mailer
in my 0db.py file --- it does have a 0 yes. :)

What am I missing?  I am trying to do this...

http://web2py.com/book/default/chapter/04#Background-Processes-and-Task-Queues

http://web2py.com/book/default/chapter/04#Background-Processes-and-Task-Queues
---
Best Regards,
Jason Brower





[web2py] Re: Where is LOAD?

2011-05-27 Thread pbreit
Class LoadFactory in compileapp.py

[web2py] Re: Where is LOAD?

2011-05-27 Thread Anthony
LOAD is just a name defined in the request environment that refers to a 
LoadFactory object, which is defined in compileapp.py.
 
The LOAD name is assigned here: 
http://code.google.com/p/web2py/source/browse/gluon/compileapp.py#240
 
And LoadFactory is defined here: 
http://code.google.com/p/web2py/source/browse/gluon/compileapp.py#88
 
Anthony


[web2py] Re: Best way to sync development and production sites.

2011-05-27 Thread ra3don
Great, that is what I will try. I just wasn't sure what the best way
to go about that was.

I saw your fabric script. Looked excellent, just a little complex for
my needs. I may use it in the future. Thanks!

On May 27, 3:30 pm, pbreit pbreitenb...@gmail.com wrote:
 There are a couple approaches to consider. What I do is set up a central
 repo on Bitbucket, hg push changes from my PC to Bitbucket and hg pull
 changes from Bitbucket to my production server.

 You can do the updates manually but I like using Fabric so you don't have to
 SSH in to your server all the time.


[web2py] Re: Create an email queing feature...

2011-05-27 Thread mattgorecki
What about using something like Sendgrid (http://sendgrid.com)? Or
Postmark (http://postmarkapp.com/)?

Let somebody else worry about throttling and blacklists and all of the
headaches of smtp servers.

Matt

On May 26, 10:50 pm, Jason Brower encomp...@gmail.com wrote:
 Yes, I practically have that now.  The issue is how do I create the cron
 task and script to execute it?
 One way I am taking this further is, as long as the conference is
 alive I can compair this list with who has signed into the conference
 to get an idea of how many people have reacted to the email and are now
 attending the conference. Like an RSVP list so to say. :)
 There is a lot of information actually, that I think I can gather from this.
 BR,
 Jason Brower
 On 05/27/2011 04:11 AM, ron_m wrote:







  A possible idea, each email insert into a table. When the cron job
  wakes up have it read X number of emails with the smallest ID value
  from the table and process them. Delete the row as each one is completed.


[web2py] Re: Create an email queing feature...

2011-05-27 Thread Massimo Di Pierro
+1

On May 27, 4:02 pm, mattgorecki m...@goelephant.com wrote:
 What about using something like Sendgrid (http://sendgrid.com)?Or
 Postmark (http://postmarkapp.com/)?

 Let somebody else worry about throttling and blacklists and all of the
 headaches of smtp servers.

 Matt

 On May 26, 10:50 pm, Jason Brower encomp...@gmail.com wrote:







  Yes, I practically have that now.  The issue is how do I create the cron
  task and script to execute it?
  One way I am taking this further is, as long as the conference is
  alive I can compair this list with who has signed into the conference
  to get an idea of how many people have reacted to the email and are now
  attending the conference. Like an RSVP list so to say. :)
  There is a lot of information actually, that I think I can gather from this.
  BR,
  Jason Brower
  On 05/27/2011 04:11 AM, ron_m wrote:

   A possible idea, each email insert into a table. When the cron job
   wakes up have it read X number of emails with the smallest ID value
   from the table and process them. Delete the row as each one is completed.


Re: [web2py] Re: Background process not working...

2011-05-27 Thread pbreit
I like to try to get my crons and background processes working in a 
controller first since it's easier to debug. Also, you might try writing the 
response to mail.send to the DB to see if there are any errors.

I'm not sure that == False is the best way to query since False has 
special properties. You might consider something like (
db.invitations.status=='pending')


[web2py] Re: Create an email queing feature...

2011-05-27 Thread pbreit
I'd also suggest SendGrid (200/day free, 10 cents for 1,000).

It looks like you are now trying it as a background process. I've had better 
luck with cron. And since you only want to send every hour or so, you could 
set the cron to run hourly.


[web2py] Re: Best way to sync development and production sites.

2011-05-27 Thread pbreit
For doing updates, this is all you need:

from fabric.api import *

def prod():
env.hosts = ['1.1.1.1']
env.user = 'user'
env.password = 'password'

def update():
run('cd /var/web2py/applications/init; hg pull')
run('cd /var/web2py/applications/init; hg update')


Then at the command line: $ fab prod update


Re: [web2py] Re: csv file name and other...

2011-05-27 Thread Manuele Pesenti

On 27/05/2011 15:53, Anthony wrote:

You could cache the query:
http://web2py.com/book/default/chapter/06#Caching-Selects


good to know :)

many thanks

Manuele


[web2py] store user and time stamp

2011-05-27 Thread Manuele Pesenti
what's the way to store in db the user that perform the insert in db and 
the actual time stamp? I thought to resolve with the subsequant solution 
but with no success:


# db model
db.define_table('main_post',
Field('title', required=True, notnull=True, label=T('Title')),
Field('description', 'text', label=T('description')),
Field('timeref', 'datetime',
compute=lambda r: request.now,
requires = IS_DATETIME(format=T('%Y-%m-%d %H:%M:%S'),
   error_message=T('must be -MM-DD HH:MM:SS!'))
)
Field('owner', db.auth_user, required=True, notnull=True,
compute=lambda r: auth.user.id,
requires=IS_IN_DB(db, 'auth_user.id', '%(first_name)s')
)
)

# controller
def index():
form = SQLFORM(db.main_post)
return dict(form=form)

on the submit it responds with a missing owner error message

thank you
cheers

Manuele


Re: [web2py] Re: Where is LOAD?

2011-05-27 Thread David J
Thanks.

I was searching for LOAD and I couldn't find it.

Thanks Massimo for the enhancement.
On May 27, 2011 4:49 PM, Anthony abasta...@gmail.com wrote:
 LOAD is just a name defined in the request environment that refers to a
 LoadFactory object, which is defined in compileapp.py.

 The LOAD name is assigned here:
 http://code.google.com/p/web2py/source/browse/gluon/compileapp.py#240

 And LoadFactory is defined here:
 http://code.google.com/p/web2py/source/browse/gluon/compileapp.py#88

 Anthony


[web2py] Hack attempt?

2011-05-27 Thread pbreit
I'm seeing these in my server logs. Are these hack attempts?

41.142.150.108 - - [27/May/2011:10:12:27 -0700] GET /).hide().html( 
HTTP/1.1 303 132 - Java/1.6.0_04
41.142.150.108 - - [27/May/2011:10:12:21 -0700] GET /\x22 + 
((document.location.protocol==\x22https:\x22)?\x22https://snapabug.appspot.com\x22:\x22http://www.snapengage.com\x22)
 
+ \x22/snapabug.js HTTP/1.1 303 132 - Java/1.6.0_04



[web2py] Re: store user and time stamp

2011-05-27 Thread pbreit
Try taking them out of the table definition. When you are referencing fields 
in the same table, they sometimes need to go outside the table definition.

db.main_post.owner.compute = lambda r: auth.user.id
db.main_post.owner.requires = IS_IN_DB(db, 'auth_user.id')

Or do this;
Field('created_by', db.auth_user, default=auth.user_id)


[web2py] Re: store user and time stamp

2011-05-27 Thread Massimo Di Pierro
You can just do:

db.define_table('main_post',
 Field('title', required=True, notnull=True, label=T('Title')),
 Field('description', 'text', label=T('description')),
 auth.signature)

and you get

db.main_post.created_by
db.main_post.created_on

On May 27, 4:34 pm, Manuele Pesenti manuele.pese...@gmail.com wrote:
 what's the way to store in db the user that perform the insert in db and
 the actual time stamp? I thought to resolve with the subsequant solution
 but with no success:

 # db model
 db.define_table('main_post',
      Field('title', required=True, notnull=True, label=T('Title')),
      Field('description', 'text', label=T('description')),
      Field('timeref', 'datetime',
          compute=lambda r: request.now,
          requires = IS_DATETIME(format=T('%Y-%m-%d %H:%M:%S'),
                         error_message=T('must be -MM-DD HH:MM:SS!'))
      )
      Field('owner', db.auth_user, required=True, notnull=True,
          compute=lambda r: auth.user.id,
          requires=IS_IN_DB(db, 'auth_user.id', '%(first_name)s')
      )
 )

 # controller
 def index():
      form = SQLFORM(db.main_post)
      return dict(form=form)

 on the submit it responds with a missing owner error message

 thank you
 cheers

         Manuele


[web2py] Re: Best way to sync development and production sites.

2011-05-27 Thread ra3don
Awesome, that's exactly the kind of solution I was looking for. That
will work perfectly.

Thanks!

On May 27, 4:24 pm, pbreit pbreitenb...@gmail.com wrote:
 For doing updates, this is all you need:

 from fabric.api import *

 def prod():
     env.hosts = ['1.1.1.1']
     env.user = 'user'
     env.password = 'password'

 def update():
     run('cd /var/web2py/applications/init; hg pull')
     run('cd /var/web2py/applications/init; hg update')

 Then at the command line: $ fab prod update


[web2py] Re: Where is LOAD?

2011-05-27 Thread mikech
This blog post, 
http://rhettinger.wordpress.com/2011/01/28/open-your-source-more/, got me 
thinking how nice it would be to link from the book to the source.  I'm just 
beginning with Python and it took me a while to find where Request, Session 
and Response were defined.  

[web2py] Missing paramenter?

2011-05-27 Thread mikech
Is this code in globals.py missing a parameter?

def stream(
self,
stream,
chunk_size = DEFAULT_CHUNK_SIZE,
request=None,
): missing a parameter after request=None, ? Also in def connect( 
self, request, response, db=None, tablename='web2py_session', 
masterapp=None, migrate=True, separate = None, check_client=False, ): 


[web2py] Re: What if Massimo got hit by a Bus?

2011-05-27 Thread Christopher Steel
Swet!



On May 26, 11:31 pm, Anthony abasta...@gmail.com wrote:
 On Thursday, May 26, 2011 11:24:35 PM UTC-4, Christopher Steel wrote:

  10. Not a problem really, it's merely a flesh wound...

 Nice Monty Python reference. Here's another 
 one:http://www.google.com/codesearch/p?hl=en#uyCl3L51_dI/gluon/rocket.py;...

 :-)

 Anthony


[web2py] table.requires question

2011-05-27 Thread Cesar Bustios
Hello, i want to know i this behaviour is correct: Sometimes if I
define the .requires outside the table definition like:

db.define_table('mytable', ...)

db.mytable.myfield.requires = IS_IN_DB(..)

It just doesn't show the dropdown list in appadmin for reference
fields, but if I put the .requires inside the table definition then it
does show the dropdown list. I have the latest stable version of
web2py. Is this normal behaviour? In that case, which validators can i
use inside table definition and which ones not.

Thanks in advance

Cesar B.



[web2py] Re: Missing paramenter?

2011-05-27 Thread pbreit
It's not uncommon to include a comma after the last item.

Re: [web2py] table.requires question

2011-05-27 Thread Bruno Rocha
db.table.field.requires = IS_IN_DB(...) # should build the dropdown widget
in form

db.table.field.requires = [ IS_IN_DB(...) ] # should not build the dropdown
widget when requires inside a list.

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



On Fri, May 27, 2011 at 8:53 PM, Cesar Bustios cesarbust...@gmail.comwrote:

 Hello, i want to know i this behaviour is correct: Sometimes if I
 define the .requires outside the table definition like:

 db.define_table('mytable', ...)

 db.mytable.myfield.requires = IS_IN_DB(..)

 It just doesn't show the dropdown list in appadmin for reference
 fields, but if I put the .requires inside the table definition then it
 does show the dropdown list. I have the latest stable version of
 web2py. Is this normal behaviour? In that case, which validators can i
 use inside table definition and which ones not.

 Thanks in advance

 Cesar B.




[web2py] validate_and_update ?

2011-05-27 Thread Bruno Rocha
Hi, I am building a test to create an ORM kind functionality using just
modules (to avoid models)

I am doing something like this: https://gist.github.com/996421 (that is
working well)

That uses 'validade_and_insert' which validate the FORM level validators and
return a Row object with r.id and r.errors, now I want to create update
methods,
is there a 'validade_and_update' ? or another hack for doing that ?

Thanks


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


[web2py] Re: table.requires question

2011-05-27 Thread Cesar Bustios
Thanks! Didn't know that, it was inside a list. Its working now :)

On 27 mayo, 19:03, Bruno Rocha rochacbr...@gmail.com wrote:
 db.table.field.requires = IS_IN_DB(...) # should build the dropdown widget
 in form

 db.table.field.requires = [ IS_IN_DB(...) ] # should not build the dropdown
 widget when requires inside a list.

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

 On Fri, May 27, 2011 at 8:53 PM, Cesar Bustios cesarbust...@gmail.comwrote:







  Hello, i want to know i this behaviour is correct: Sometimes if I
  define the .requires outside the table definition like:

  db.define_table('mytable', ...)

  db.mytable.myfield.requires = IS_IN_DB(..)

  It just doesn't show the dropdown list in appadmin for reference
  fields, but if I put the .requires inside the table definition then it
  does show the dropdown list. I have the latest stable version of
  web2py. Is this normal behaviour? In that case, which validators can i
  use inside table definition and which ones not.

  Thanks in advance

  Cesar B.


[web2py] django-and-sqlalchemy-on-web2py

2011-05-27 Thread Massimo Di Pierro
I wrote this long ago but got lost in the list:

http://code.google.com/p/django-and-sqlalchemy-on-web2py/


[web2py] Google app engine

2011-05-27 Thread Resa
 Can someone assist me in deploying google app engine.. I am getting
this error:

File /usr/lib/python2.6/urllib2.py, line 1169, in https_open
return self.do_open(httplib.HTTPSConnection, req)
  File /home/tara/Downloads/google_appengine/lib/fancy_urllib/
fancy_urllib/__init__.py, line 367, in do_open
raise url_error
urllib2.URLError: urlopen error [Errno -2] Name or service not known

This is what i did:

 1locate dev_appser
  2  /home/tara/Downloads/google_appengine/dev_appserver.py
  3  /home/tara/Downloads/google_appengine/appcfg.py update ~/
Documents/web2py

I also specified the application in the routes file


[web2py] Re: Google app engine

2011-05-27 Thread Massimo Di Pierro
From your traceback:

File /usr/lib/python2.6/urllib2.py

GAE requires python 2.5.


On May 27, 11:22 pm, Resa taratbr...@gmail.com wrote:
  Can someone assist me in deploying google app engine.. I am getting
 this error:

 File /usr/lib/python2.6/urllib2.py, line 1169, in https_open
     return self.do_open(httplib.HTTPSConnection, req)
   File /home/tara/Downloads/google_appengine/lib/fancy_urllib/
 fancy_urllib/__init__.py, line 367, in do_open
     raise url_error
 urllib2.URLError: urlopen error [Errno -2] Name or service not known

 This is what i did:

      1locate dev_appser
   2  /home/tara/Downloads/google_appengine/dev_appserver.py
   3  /home/tara/Downloads/google_appengine/appcfg.py update ~/
 Documents/web2py

 I also specified the application in the routes file


[web2py] How to display a multi-line string variable properly?

2011-05-27 Thread Luis Goncalves

I have a string variable, message_body,  which is multiline (has
newlines or \n characters).

How do I get it to display properly in an HTML view?

simply using  {{=message_body}}  displays the text all on the same
line, ignoring the carriage returns.

{{=TEXTAREA(message_body)}} displays properly, but is ugly (unless I
can control the number of lines to fit tightly, and make the are non-
editable).

Thanks in advance!

Luis.


[web2py] Re: How to display a multi-line string variable properly?

2011-05-27 Thread pbreit
I think you have to search/replace:

{{=XML(str(message_body).replace('\n', 'br'), sanitize=True)}}

I'm not sure if str() is always necessary or if sanitize needs to be True.