Re: [web2py] Reverse table look up in GAE

2010-09-09 Thread b vivek
Ok so if i have a table in my db named homepage as below:-
--
id  | data |
---
1   | vivek|
--
2  | andrew|
---

Now if I want to retrieve only the last row .. i can do this
homepage=db().select(db.homepage.ALL,orderby=~db.homepage.id,limitby=(0,1))

Now let me point out that this works prefectly on localhost using the normal
rdbms like mysql or sqlite. However when I use the local development GAE
environ or even when I upload it to GAE,it just returns the first row. Seems
like it totally ignores the tilde.

The same command when used on GAE gives me the first row,rather than the
last one.

Thanks
Vivek

On Thu, Sep 9, 2010 at 11:27 AM, Andrew Thompson andre...@aktzero.comwrote:

  On 9/9/2010 12:24 AM, b vivek wrote:

 Hi I wanted to retrieve the latest data entered in a table and thus used
 the below syntax for data look up

 homepage=db().select(db.homepage.ALL,orderby=~db.homepage.id
 ,limitby=(0,1))

  This is expected to retrieve the last row entered in the table homepage .
 While this works perfectly, it does not work on GAE. It would be really
 helpful, if someone could please help me with this..


 While I'm not familiar with GAE, I can say for sure that you've not
 provided enough information.

 How does it not work?

 For example, can you make any .select() work? If you remove the orderby or
 the limitby does it change how it doesn't work?

 --
 Andrew Thompsonhttp://aktzero.com/




[web2py] How to insert only new items in db as fast as possible?

2010-09-09 Thread Miguel
Hi

I have the following table:
db.define_table(products,
Field(categoryID, db.productCategory, writable=False,
readable=False, requires=IS_IN_DB(db, productCategory.id,
productCategory.name) ), # reference field
Field(productName, 'string',length=512,  default=None),
Field(description, 'text',default=None)
)

- I have a list of (2) rows that might contain products and I
would like to update my table. However some products might already be
in the db while others are completely new.
- I want to insert a row if it does not exist in the db (productName
could play the role of the identifier here) is already there AND
update a row in the case the product already exists in the DB


I can do it pretty easily if I go item by item and check if it already
exits in the db and then take the appropriate action (insert or
update). What I am looking for is the most efficient way to do this
(especially on GAE).

thanks
Miguel


[web2py] Re: custom validation, was: Re: IS_IN_DB referencing linked tables

2010-09-09 Thread annet
Something like this in the controller:

eventtyperows=db(db.event.eventtype==db.eventtype.id).\
select(db.event.eventtype,db.eventtype.eventtype,\
distinct=True,orderby=db.eventtype.eventtype)

a=[e.event.eventtype for e in eventtyperows]
b=[e.eventtype.eventtype for e in eventtyperows]

form=SQLFORM.factory(SQLField('eventtype',requires=IS_IN_SET(a,b))


Annet.


[web2py] split rows object in view.

2010-09-09 Thread annet
I have the following code in a view:

ul
  {{for row in rows:}}
li{{=row.facility}}/li
  {{pass}}
/ul

The length of rows varies. I would like to split the list in two list
and display it in two columns instead of one. Is it possible to do
this in the view, or should the function return rows_1 and rows_2?


Kind regards,

Annet.


Re: [web2py] split rows object in view.

2010-09-09 Thread Kenneth Lundström



One way of solving this would be like this:

table

{{counter = 1}}

{{for row in rows:}}

  {{if counter == 1:}}

trtd{{=row.facility}}/td

{{counter = 2}}

  {{else:}}

td{{=row.facility}}/td/tr

{{counter = 1}}

  {{pass}}

{{pass}}

/table


Kenneth



I have the following code in a view:

ul
   {{for row in rows:}}
 li{{=row.facility}}/li
   {{pass}}
/ul

The length of rows varies. I would like to split the list in two list
and display it in two columns instead of one. Is it possible to do
this in the view, or should the function return rows_1 and rows_2?


Kind regards,

Annet.




[web2py] Re: lazy virtualfields

2010-09-09 Thread Niphlod
Perfect

I think this can be added to the relevant section of the book, I
didn't find anything about that, also on the internet...

Thanks a lot, though.

Niphlod

On 8 Set, 03:08, mdipierro mdipie...@cs.depaul.edu wrote:
 Sorry for the lat reply. This is not a bug. This is a design issue and
 tradeoff.

 In fact there is a single virtualfields instance, the one you create
 in:

    db.test.virtualfields.append(TestLazy())

 and not one instance per record. There are two reasons for this:
 1) allows cumulative virtualfields (values that depends on previous
 records)
 2) save memory

 You can replace your code

 class TestLazy:
     def lazy_test_field(self):
         def lazy(self=self):
             return self.test.name
         return lazy

 with

 class TestLazy:
     def lazy_test_field(self):
         from copy import copy
         def lazy(self=copy(self)):
             return self.test.name
         return lazy

 and this would work as you expect. It is just that DAL leaves to you
 the responsibility of making the copy and using the extra memory and
 does not do it automatically because most of the cases it would be a
 waste.

 Massimo

 On Aug 21, 6:22 pm, Niphlod niph...@gmail.com wrote:



  so, I read the docs and.

  I think either there's a bug or I'm doing something wrong

  in db.py

  ---
  .

  db.define_table('test',
                  Field('name', length=5)
                  )

  class TestLazy:
      def lazy_test_field(self):
          deflazy(self=self):
              return self.test.name
          returnlazy

  class TestNotLazy:
      def not_lazy_test_field(self):
          return self.test.name

  db.test.virtualfields.append(TestLazy())
  db.test.virtualfields.append(TestNotLazy())

  

  Testing in the shell

  web2py Shell Version 1.83.2 (2010-08-15 08:16:30)
  In[0]:  set = db(db.test.id0).select()

  Out[0]:
  In[1]:  set.as_dict()

  Out[1]: {1: {'name': 'miao', 'id': 1, 'not_lazy_test_field': 'miao'},
  2: {'name': 'bau', 'id': 2, 'not_lazy_test_field': 'bau'}}

  In[2]:for row in set:
      print row.id, row.name, row.not_lazy_test_field

  Out[2]:
  1 miao miao
  2 bau bau

  In[3]:
  for row in set:
      print row.id, row.name, row.not_lazy_test_field,
  row.lazy_test_field

  Out[3]:
  1 miao miao functionlazyat 0x2e5c2a8
  2 bau bau functionlazyat 0x308ec80

  In[4]:
  for row in set:
      print row.id, row.name, row.not_lazy_test_field,
  row.lazy_test_field()

  Out[4]:
  1 miao miao bau
  2 bau bau bau

  sorry for the unmeaning data in the set, but...seems thatlazy
  virtualfield is evaluated every line (different hash function when you
  try to print row.lazy_test_field without parenthesis, In[3]) but it
  returns data computed for the last line in the set...in all the rows
  of the set itself (In[4])

  Can somebody point me in the right direction ?
  Thanks- Nascondi testo citato

 - Mostra testo citato -


[web2py] Re: split rows object in view.

2010-09-09 Thread annet
Hi Kenneth,

Thanks for your instant reply, problem solved!


Kind regards,

Annet


[web2py] Re: Reverse table look up in GAE

2010-09-09 Thread Martin.Mulone
Yes but i think this is gae thing. You try? with max(id) or add some
datetime field and order by this field like Field('created_on',
'datetime',
default=datetime.datetime.today(),writable=False,readable=False)

On 9 sep, 03:06, b vivek bvivek1...@gmail.com wrote:
 Ok so if i have a table in my db named homepage as below:-
 --
 id  | data |
 ---
 1   | vivek|
 --
 2  | andrew|
 ---

 Now if I want to retrieve only the last row .. i can do this
 homepage=db().select(db.homepage.ALL,orderby=~db.homepage.id,limitby=(0,1))

 Now let me point out that this works prefectly on localhost using the normal
 rdbms like mysql or sqlite. However when I use the local development GAE
 environ or even when I upload it to GAE,it just returns the first row. Seems
 like it totally ignores the tilde.

 The same command when used on GAE gives me the first row,rather than the
 last one.

 Thanks
 Vivek

 On Thu, Sep 9, 2010 at 11:27 AM, Andrew Thompson andre...@aktzero.comwrote:



   On 9/9/2010 12:24 AM, b vivek wrote:

  Hi I wanted to retrieve the latest data entered in a table and thus used
  the below syntax for data look up

  homepage=db().select(db.homepage.ALL,orderby=~db.homepage.id
  ,limitby=(0,1))

   This is expected to retrieve the last row entered in the table homepage .
  While this works perfectly, it does not work on GAE. It would be really
  helpful, if someone could please help me with this..

  While I'm not familiar with GAE, I can say for sure that you've not
  provided enough information.

  How does it not work?

  For example, can you make any .select() work? If you remove the orderby or
  the limitby does it change how it doesn't work?

  --
  Andrew Thompsonhttp://aktzero.com/


[web2py] cherokee problem with fastcgi and uWSGI

2010-09-09 Thread salbefe
Hello,

I'm trying to deploy web2py with cherokee on a fedora core 13 distro
but I have several problems on it. I have read  the slice web2py with
Cherokee via uWSGI: a simple, easy guide that it could be found in
web2pyslices but this guide is outdated because it seems to be done
for an older cherokee version than 1.X.X. Current cherokee version is
1.0.8

Some things are not clear to me:

1.- For example where should be web2py: on /var/web2py or /var/www/
web2py. After reading the slice it seems that it should be on /var/
web2py.
2.- www-data user does not exist on fedora distro so where it says
sudo chown -hR www-data\: /var/web2py I did sudo chown -hR root\: /
var/web2py
3.- Its impossible to follow steps E throught G because options
described there does not exists anymore in cherokee admin interface
and I could not find other places where they could be.

After trying to setup following more or less these steps when I point
to http://localhost I always get the cherokee test page.


The same problem with the steps that are on the online book to setup
cherokee with fastcgi interface. The steps described there should be
now a bit different to setup web2py with cherokee.


I need some help, please.
Thanks in advance!





[web2py] Making asynchronous request in web2py

2010-09-09 Thread Adi
Hi,

I have this test case:

1. User registers in app.
2. App sends him greeting email (Welcome to so-and-so app).
3. App adds his email/name etc to mailing application (like Mailchimp)
for auto-subscribing to newsletter.

Now user expects steps 1 completion to take him to the next 'default/
index' page, and we don't want steps 2 and 3 to prevent completion of
step 1. Is there a way to make step 2 and 3 complete independently, in
a way that user's experience is not slowed down?

Think of it as being equivalent of asynchronous ajax request, which
doesn't wait for response before moving to the next piece of
javascript.

Any help on this? I know we should not create threads because web2py
handles that for us (read in some older post long long ago).

-- Adi


[web2py] Why Django Sucks (slides)

2010-09-09 Thread Adi
http://www.scribd.com/doc/37113340/Why-Django-Sucks-and-How-we-Can-Fix-it

It would be interesting to head community's thoughts on some of the
problems there. :)


Re: [web2py] cherokee problem with fastcgi and uWSGI

2010-09-09 Thread Roberto De Ioris

Il giorno 09/set/2010, alle ore 12.42, salbefe ha scritto:

 Hello,
 
 I'm trying to deploy web2py with cherokee on a fedora core 13 distro
 but I have several problems on it. I have read  the slice web2py with
 Cherokee via uWSGI: a simple, easy guide that it could be found in
 web2pyslices but this guide is outdated because it seems to be done
 for an older cherokee version than 1.X.X. Current cherokee version is
 1.0.8
 
 Some things are not clear to me:
 
 1.- For example where should be web2py: on /var/web2py or /var/www/
 web2py. After reading the slice it seems that it should be on /var/
 web2py.
 2.- www-data user does not exist on fedora distro so where it says
 sudo chown -hR www-data\: /var/web2py I did sudo chown -hR root\: /
 var/web2py
 3.- Its impossible to follow steps E throught G because options
 described there does not exists anymore in cherokee admin interface
 and I could not find other places where they could be.
 
 After trying to setup following more or less these steps when I point
 to http://localhost I always get the cherokee test page.
 
 
 The same problem with the steps that are on the online book to setup
 cherokee with fastcgi interface. The steps described there should be
 now a bit different to setup web2py with cherokee.
 
 
 I need some help, please.
 Thanks in advance!
 
 


Hi, first of all read the web2py related examples here:

http://projects.unbit.it/uwsgi/wiki/Example

choose the one you like and add --http :9090

(or substitute :9090 with whatever port you want)

now go to http://localhost:9090 with your webbrowser.

If all works well remove the --http option and restart the uwsgi server.

Now go to the cherokee admin and map your resource (probably the default one)
to the address of your uwsgi server.

I suggest you to use TCP sockets instead of UNIX to avoid permission problems.

--
Roberto De Ioris
http://unbit.it
JID: robe...@jabber.unbit.it



[web2py] Re: web2py_vs_others missing T() section!

2010-09-09 Thread mdipierro
Thank you!

On Sep 8, 11:45 pm, Relsi Hur relsi.ram...@gmail.com wrote:
 Hi Massimo,

 I have here an editable version of the document which I will translate
 to Portuguese soon, if you want to catch:

 https://docs.google.com/document/edit?id=14jfi7HUf-F41N6HHvqx87S3GTHQ...

 Relsihttp://www.tuxtilt.com

 On 8 set, 23:13, mdipierro mdipie...@cs.depaul.edu wrote:

  thanks. can you take charge and post it on a google doc? I can help
  editing.

  On Sep 8, 9:08 pm, weheh richard_gor...@verizon.net wrote:

   Here's the text of the pdf document, courtesy one of my websites,
   YAKiToMe!http://www.yakitome.com.

   ---

   web frameworks design comparison
   draft - please help me improve it focus on Model-View-Controller
   frameworks

   Controllers
   In Rails class MyTestController  ApplicationController def index
   render_text Hello World end end

   The name of the class has to match the name of the controller file.

   Controllers
   In Django from django.http import HttpResponse def index(request):
   return HttpResponse(Hello World)

   Django is explicit, you need to import all functions you use.

   Controllers
   In Cherrypy and TurboGears 1.0 import cherrypy class MyRoot:
   @cherrypy.expose() def index(self): return Hello World

   Cherrypy, Turbogears, and Pylons are also explicit. You need to import
   all functions you want to use.

   Controllers
   In web2py def index(): return Hello World

   web2py is similar to Rails. It imports for you all the web2py keyword.
   Often, like in this case, you do not need any.

   Get/Post requests
   In Rails class MyTestController  ApplicationController def index
   render_text Hello +params[:who] end end

   GET and POST variables are passed via params but other request
   parameters (client ip for example) are passed via a different
   mechanism.

   Get/Post requests
   In Django from django.http import HttpResponse def index(request):
   return HttpResponse(Hello World %s % request.REQUEST[`who’])

   Nice, simple. The request contains all the info. You can use .GET
   or .POST instead of .REQUEST to be more specific.

   Get/Post requests
   In Cherrypy and TurboGears 1.0 import cherrypy class MyRoot:
   @cherrypy.expose() def index(self,who): return Hello %s % who

   GET and POST variables are passed via arguments of the action, but
   other request parameters (client ip for example) are passed via a
   different mechanism.

   Get/Post requests
   In web2py def index(): return Hello %s % request.vars.who

   Similar to Django. All request data is in one place. You can
   use .get_vars and .post_vars instead of .vars to be more specific.

   Dispatching
   In Rails URLhttp://hostname/MyTest/indexgetsmappedinto class
   MyTestController  ApplicationController def index render_text Hello
   World end end

   By default Rails does not allow running multiple apps without running
   multiple copies of Rails, since the name of the app is not in the URL,
   only the controller name (MyTest) and the action name (index) appear.
   This can be changed by configuring routes.

   Dispatching
   In Django you need to edit url.py to map URLs into actions from
   django.conf.urls.defaults import * urlpatterns = patterns(’’, (r’^index
   $’, myapp.mycontroller.index), )

   This is the equivalent of Rails’ routes and it requires using regular
   expressions. There is no default. You need one entry in url.py for
   every action.

   Dispatching
   In Cherrypy and TurboGears 1.0 import cherrypy class MyRoot:
   @cherrypy.expose() def index(self,who): return Hello %s % who

   Works very much like Rails and default mapping between URL and action
   can be overwritten.

   Dispatching
   In web2py a URL likehttp://hostname/myapp/mycontroller/indexcalls
   def index(): return Hello %s % request.vars.who

   Similar to Rails and Charrypy but, by default the URL requires that
   you specify the name of the app. This allows web2py to run multiple
   apps without using routes. Web2py has its own version of routes that
   supports two different syntaxes (with and without regular expression)
   to overwrite the mapping and reverse mapping as well.

   Calling Views
   In Rails class MyTestController  ApplicationController def index
   @message=Hello World end end

   It calls the default view (MyTest/index) which renders the page. The
   variables marked by @ are global vars and are passed to the view.
   Notice that if the view is not defined, this results in an error
   message.

   Calling Views
   In Django from django.shortcuts import render_to_response def
   index(request): return render_to_response(index.html,
   {`message’:’Hello World’})

   This is the short way of doing it in Django. You have to specify the
   view name index.html since there is no default. Parameters are
   passed via a dictionary. You get an error message if the view is not
   defined. Notice that in Django a view is called a template and a
   controller is called a 

[web2py] intercepting SQLFORM delete

2010-09-09 Thread Richard
I want to do some preprocessing before permitting SQLFORM to delete a
record:

topic = db.topic[topic_id]
form = SQLFORM(db.topic, topic)
if form.accepts(request.vars, session, dbio=False):
if form.vars.get('delete_this_record'):
response.flash = 'Delete intercepted'
else:
response.flash = 'Update intercepted'

However I found dbio only applies to insert/update and doesn't affect
delete (sqlhtml.py: 952, 1031).
Why doesn't dbio apply to all databases operations?
Is there an alternative way to intercept SQLFORM deletion?

thanks,
Richard


[web2py] Re: Routes.py on GAE

2010-09-09 Thread Richard
I am using the following simple routes.py and find it works fine on
GAE with latest trunk:

routes_in = (
('/', '/init/default/index'),
('/topics', '/init/topics/index'),
)
routes_out = [(second, first) for (first, second) in routes_in]




On Sep 9, 9:49 pm, mdipierro mdipie...@cs.depaul.edu wrote:
 i cannot reproduce this problem. Can you send me your routes?

 On Sep 7, 1:28 am, Miguel Goncalves goncalvesmig...@gmail.com wrote:

  Hi

  I guess this bug has not been fixed yet?

  I am getting the following error:

  unable to import Rocket
  Your routes.py has a syntax error Please fix it before you restart web2py
  Traceback (most recent call last):
    File 
  /base/data/home/apps/reviewround/1.344628390884008259/gluon/rewrite.py,
  line 106, in load
      exec routesfp.read() in symbols
    File string, line 3

     ^
  SyntaxError: invalid syntax

  type 'exceptions.SyntaxError': invalid syntax (string, line 3)
  Traceback (most recent call last):
    File 
  /base/data/home/apps/reviewround/1.344628390884008259/gaehandler.py,
  line 52, in module
      import gluon.main
    File 
  /base/data/home/apps/reviewround/1.344628390884008259/gluon/main.py,
  line 66, in module
      rewrite.load()
    File 
  /base/data/home/apps/reviewround/1.344628390884008259/gluon/rewrite.py,
  line 114, in load
      raise e
  type 'exceptions.SyntaxError': invalid syntax (string, line 3)

  The routes.py looks like :
  #!/usr/bin/python
  # -*- coding: utf-8 -*-

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

  routes_in = ( ('/', '/reviewround/default/index'),)
  routes_out = ( ('/reviewround/default/index', '/'),)

  thanks
  Miguel




[web2py] Re: intercepting SQLFORM delete

2010-09-09 Thread mdipierro
oops. fixed in trunk

On Sep 9, 7:50 am, Richard richar...@gmail.com wrote:
 I want to do some preprocessing before permitting SQLFORM to delete a
 record:

 topic = db.topic[topic_id]
 form = SQLFORM(db.topic, topic)
 if form.accepts(request.vars, session, dbio=False):
     if form.vars.get('delete_this_record'):
         response.flash = 'Delete intercepted'
     else:
         response.flash = 'Update intercepted'

 However I found dbio only applies to insert/update and doesn't affect
 delete (sqlhtml.py: 952, 1031).
 Why doesn't dbio apply to all databases operations?
 Is there an alternative way to intercept SQLFORM deletion?

 thanks,
 Richard


[web2py] Re: Routes.py on GAE

2010-09-09 Thread mdipierro
I do not understand where unable to import Rocket comes from.

On Sep 9, 8:03 am, Richard richar...@gmail.com wrote:
 I am using the following simple routes.py and find it works fine on
 GAE with latest trunk:

 routes_in = (
     ('/', '/init/default/index'),
     ('/topics', '/init/topics/index'),
 )
 routes_out = [(second, first) for (first, second) in routes_in]

 On Sep 9, 9:49 pm, mdipierro mdipie...@cs.depaul.edu wrote:

  i cannot reproduce this problem. Can you send me your routes?

  On Sep 7, 1:28 am, Miguel Goncalves goncalvesmig...@gmail.com wrote:

   Hi

   I guess this bug has not been fixed yet?

   I am getting the following error:

   unable to import Rocket
   Your routes.py has a syntax error Please fix it before you restart web2py
   Traceback (most recent call last):
     File 
   /base/data/home/apps/reviewround/1.344628390884008259/gluon/rewrite.py,
   line 106, in load
       exec routesfp.read() in symbols
     File string, line 3

      ^
   SyntaxError: invalid syntax

   type 'exceptions.SyntaxError': invalid syntax (string, line 3)
   Traceback (most recent call last):
     File 
   /base/data/home/apps/reviewround/1.344628390884008259/gaehandler.py,
   line 52, in module
       import gluon.main
     File 
   /base/data/home/apps/reviewround/1.344628390884008259/gluon/main.py,
   line 66, in module
       rewrite.load()
     File 
   /base/data/home/apps/reviewround/1.344628390884008259/gluon/rewrite.py,
   line 114, in load
       raise e
   type 'exceptions.SyntaxError': invalid syntax (string, line 3)

   The routes.py looks like :
   #!/usr/bin/python
   # -*- coding: utf-8 -*-

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

   routes_in = ( ('/', '/reviewround/default/index'),)
   routes_out = ( ('/reviewround/default/index', '/'),)

   thanks
   Miguel




[web2py] Re: cherokee problem with fastcgi and uWSGI

2010-09-09 Thread Jose


On 9 sep, 07:42, salbefe salb...@gmail.com wrote:
 Hello,

 I'm trying to deploy web2py with cherokee on a fedora core 13 distro
 but I have several problems on it. I have read  the slice web2py with
 Cherokee via uWSGI: a simple, easy guide that it could be found in
 web2pyslices but this guide is outdated because it seems to be done
 for an older cherokee version than 1.X.X. Current cherokee version is
 1.0.8

 Some things are not clear to me:

 1.- For example where should be web2py: on /var/web2py or /var/www/
 web2py. After reading the slice it seems that it should be on /var/
 web2py.

This should not be important, I have it in /home/web2py


 2.- www-data user does not exist on fedora distro so where it says
 sudo chown -hR www-data\: /var/web2py I did sudo chown -hR root\: /
 var/web2py
in my case (freebsd), user=www and group=www


 3.- Its impossible to follow steps E throught G because options
 described there does not exists anymore in cherokee admin interface
 and I could not find other places where they could be.

GUI has changed but little, are looking to see that things are in the
new user interface.




 The same problem with the steps that are on the online book to setup
 cherokee with fastcgi interface. The steps described there should be
 now a bit different to setup web2py with cherokee.

FastCGI is similar to uwsgi. But I think the problem is that the GUI
was changed in Cherokee.



 I need some help, please.

In a few days I can write as I have configured my server, including
screenshots of the new GUI Cherokee

Regards,
Jose



Re: [web2py] Re: Routes.py on GAE

2010-09-09 Thread Jonathan Lundell
On Sep 9, 2010, at 6:27 AM, mdipierro wrote:
 
 I do not understand where unable to import Rocket comes from.

That's a strange error. Also, the syntax error on routes.py is on line 3, which 
is empty; there's no code until line 4.

My advice is to resolve the first error (Rocket) before worrying about the 
routes error.

 
 On Sep 9, 8:03 am, Richard richar...@gmail.com wrote:
 I am using the following simple routes.py and find it works fine on
 GAE with latest trunk:
 
 routes_in = (
 ('/', '/init/default/index'),
 ('/topics', '/init/topics/index'),
 )
 routes_out = [(second, first) for (first, second) in routes_in]
 
 On Sep 9, 9:49 pm, mdipierro mdipie...@cs.depaul.edu wrote:
 
 i cannot reproduce this problem. Can you send me your routes?
 
 On Sep 7, 1:28 am, Miguel Goncalves goncalvesmig...@gmail.com wrote:
 
 Hi
 
 I guess this bug has not been fixed yet?
 
 I am getting the following error:
 
 unable to import Rocket
 Your routes.py has a syntax error Please fix it before you restart web2py
 Traceback (most recent call last):
   File 
 /base/data/home/apps/reviewround/1.344628390884008259/gluon/rewrite.py,
 line 106, in load
 exec routesfp.read() in symbols
   File string, line 3
 
^
 SyntaxError: invalid syntax
 
 type 'exceptions.SyntaxError': invalid syntax (string, line 3)
 Traceback (most recent call last):
   File 
 /base/data/home/apps/reviewround/1.344628390884008259/gaehandler.py,
 line 52, in module
 import gluon.main
   File 
 /base/data/home/apps/reviewround/1.344628390884008259/gluon/main.py,
 line 66, in module
 rewrite.load()
   File 
 /base/data/home/apps/reviewround/1.344628390884008259/gluon/rewrite.py,
 line 114, in load
 raise e
 type 'exceptions.SyntaxError': invalid syntax (string, line 3)
 
 The routes.py looks like :
 #!/usr/bin/python
 # -*- coding: utf-8 -*-
 
 default_application = 'reviewround' # ordinarily set in base routes.py
 default_controller = 'default'  # ordinarily set in app-specific
 routes.py
 default_function = 'index'
 
 routes_in = ( ('/', '/reviewround/default/index'),)
 routes_out = ( ('/reviewround/default/index', '/'),)
 
 thanks
 Miguel
 
 




[web2py] Re: Routes.py on GAE

2010-09-09 Thread mdipierro
gaehanlder.py does not import Rocket. Is it possible gaehandler.py or
app.yaml were modified?

On Sep 9, 9:40 am, Jonathan Lundell jlund...@pobox.com wrote:
 On Sep 9, 2010, at 6:27 AM, mdipierro wrote:



  I do not understand where unable to import Rocket comes from.

 That's a strange error. Also, the syntax error on routes.py is on line 3, 
 which is empty; there's no code until line 4.

 My advice is to resolve the first error (Rocket) before worrying about the 
 routes error.



  On Sep 9, 8:03 am, Richard richar...@gmail.com wrote:
  I am using the following simple routes.py and find it works fine on
  GAE with latest trunk:

  routes_in = (
      ('/', '/init/default/index'),
      ('/topics', '/init/topics/index'),
  )
  routes_out = [(second, first) for (first, second) in routes_in]

  On Sep 9, 9:49 pm, mdipierro mdipie...@cs.depaul.edu wrote:

  i cannot reproduce this problem. Can you send me your routes?

  On Sep 7, 1:28 am, Miguel Goncalves goncalvesmig...@gmail.com wrote:

  Hi

  I guess this bug has not been fixed yet?

  I am getting the following error:

  unable to import Rocket
  Your routes.py has a syntax error Please fix it before you restart web2py
  Traceback (most recent call last):
    File 
  /base/data/home/apps/reviewround/1.344628390884008259/gluon/rewrite.py,
  line 106, in load
      exec routesfp.read() in symbols
    File string, line 3

     ^
  SyntaxError: invalid syntax

  type 'exceptions.SyntaxError': invalid syntax (string, line 3)
  Traceback (most recent call last):
    File 
  /base/data/home/apps/reviewround/1.344628390884008259/gaehandler.py,
  line 52, in module
      import gluon.main
    File 
  /base/data/home/apps/reviewround/1.344628390884008259/gluon/main.py,
  line 66, in module
      rewrite.load()
    File 
  /base/data/home/apps/reviewround/1.344628390884008259/gluon/rewrite.py,
  line 114, in load
      raise e
  type 'exceptions.SyntaxError': invalid syntax (string, line 3)

  The routes.py looks like :
  #!/usr/bin/python
  # -*- coding: utf-8 -*-

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

  routes_in = ( ('/', '/reviewround/default/index'),)
  routes_out = ( ('/reviewround/default/index', '/'),)

  thanks
  Miguel




Re: [web2py] Re: Routes.py on GAE

2010-09-09 Thread Jonathan Lundell
On Sep 9, 2010, at 7:49 AM, mdipierro wrote:
 
 gaehanlder.py does not import Rocket.

main imports Rocket

 Is it possible gaehandler.py or
 app.yaml were modified?
 
 On Sep 9, 9:40 am, Jonathan Lundell jlund...@pobox.com wrote:
 On Sep 9, 2010, at 6:27 AM, mdipierro wrote:
 
 
 
 I do not understand where unable to import Rocket comes from.
 
 That's a strange error. Also, the syntax error on routes.py is on line 3, 
 which is empty; there's no code until line 4.
 
 My advice is to resolve the first error (Rocket) before worrying about the 
 routes error.
 
 
 
 On Sep 9, 8:03 am, Richard richar...@gmail.com wrote:
 I am using the following simple routes.py and find it works fine on
 GAE with latest trunk:
 
 routes_in = (
 ('/', '/init/default/index'),
 ('/topics', '/init/topics/index'),
 )
 routes_out = [(second, first) for (first, second) in routes_in]
 
 On Sep 9, 9:49 pm, mdipierro mdipie...@cs.depaul.edu wrote:
 
 i cannot reproduce this problem. Can you send me your routes?
 
 On Sep 7, 1:28 am, Miguel Goncalves goncalvesmig...@gmail.com wrote:
 
 Hi
 
 I guess this bug has not been fixed yet?
 
 I am getting the following error:
 
 unable to import Rocket
 Your routes.py has a syntax error Please fix it before you restart web2py
 Traceback (most recent call last):
   File 
 /base/data/home/apps/reviewround/1.344628390884008259/gluon/rewrite.py,
 line 106, in load
 exec routesfp.read() in symbols
   File string, line 3
 
^
 SyntaxError: invalid syntax
 
 type 'exceptions.SyntaxError': invalid syntax (string, line 3)
 Traceback (most recent call last):
   File 
 /base/data/home/apps/reviewround/1.344628390884008259/gaehandler.py,
 line 52, in module
 import gluon.main
   File 
 /base/data/home/apps/reviewround/1.344628390884008259/gluon/main.py,
 line 66, in module
 rewrite.load()
   File 
 /base/data/home/apps/reviewround/1.344628390884008259/gluon/rewrite.py,
 line 114, in load
 raise e
 type 'exceptions.SyntaxError': invalid syntax (string, line 3)
 
 The routes.py looks like :
 #!/usr/bin/python
 # -*- coding: utf-8 -*-
 
 default_application = 'reviewround' # ordinarily set in base 
 routes.py
 default_controller = 'default'  # ordinarily set in app-specific
 routes.py
 default_function = 'index'
 
 routes_in = ( ('/', '/reviewround/default/index'),)
 routes_out = ( ('/reviewround/default/index', '/'),)
 
 thanks
 Miguel
 
 




[web2py] Re: Routes.py on GAE

2010-09-09 Thread mdipierro
try:
import rocket
except:
logging.warn('unable to import Rocket')

True. This is supposed to fail on GAE. I will change it. No need to
try the import and issue a warning on GAE.



On Sep 9, 9:57 am, Jonathan Lundell jlund...@pobox.com wrote:
 On Sep 9, 2010, at 7:49 AM, mdipierro wrote:



  gaehanlder.py does not import Rocket.

 main imports Rocket

  Is it possible gaehandler.py or
  app.yaml were modified?

  On Sep 9, 9:40 am, Jonathan Lundell jlund...@pobox.com wrote:
  On Sep 9, 2010, at 6:27 AM, mdipierro wrote:

  I do not understand where unable to import Rocket comes from.

  That's a strange error. Also, the syntax error on routes.py is on line 3, 
  which is empty; there's no code until line 4.

  My advice is to resolve the first error (Rocket) before worrying about the 
  routes error.

  On Sep 9, 8:03 am, Richard richar...@gmail.com wrote:
  I am using the following simple routes.py and find it works fine on
  GAE with latest trunk:

  routes_in = (
      ('/', '/init/default/index'),
      ('/topics', '/init/topics/index'),
  )
  routes_out = [(second, first) for (first, second) in routes_in]

  On Sep 9, 9:49 pm, mdipierro mdipie...@cs.depaul.edu wrote:

  i cannot reproduce this problem. Can you send me your routes?

  On Sep 7, 1:28 am, Miguel Goncalves goncalvesmig...@gmail.com wrote:

  Hi

  I guess this bug has not been fixed yet?

  I am getting the following error:

  unable to import Rocket
  Your routes.py has a syntax error Please fix it before you restart 
  web2py
  Traceback (most recent call last):
    File 
  /base/data/home/apps/reviewround/1.344628390884008259/gluon/rewrite.py,
  line 106, in load
      exec routesfp.read() in symbols
    File string, line 3

     ^
  SyntaxError: invalid syntax

  type 'exceptions.SyntaxError': invalid syntax (string, line 3)
  Traceback (most recent call last):
    File 
  /base/data/home/apps/reviewround/1.344628390884008259/gaehandler.py,
  line 52, in module
      import gluon.main
    File 
  /base/data/home/apps/reviewround/1.344628390884008259/gluon/main.py,
  line 66, in module
      rewrite.load()
    File 
  /base/data/home/apps/reviewround/1.344628390884008259/gluon/rewrite.py,
  line 114, in load
      raise e
  type 'exceptions.SyntaxError': invalid syntax (string, line 3)

  The routes.py looks like :
  #!/usr/bin/python
  # -*- coding: utf-8 -*-

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

  routes_in = ( ('/', '/reviewround/default/index'),)
  routes_out = ( ('/reviewround/default/index', '/'),)

  thanks
  Miguel




Re: [web2py] Re: Routes.py on GAE

2010-09-09 Thread Jonathan Lundell
On Sep 9, 2010, at 9:17 AM, mdipierro wrote:
 
 try:
import rocket
 except:
logging.warn('unable to import Rocket')
 
 True. This is supposed to fail on GAE. I will change it. No need to
 try the import and issue a warning on GAE.

...which leaves the mystery of the routes syntax error. 

I'd try it with the first three lines (two comments and blank line) removed, 
and see what happens.

I'd also carefully check routes.py for invisible garbage characters, perhaps 
from some word processor. Word's idea of a non-breaking space, for example. 

If possible, zip the routes.py that you're uploading to GAE, and send me a copy.

 
 
 
 On Sep 9, 9:57 am, Jonathan Lundell jlund...@pobox.com wrote:
 On Sep 9, 2010, at 7:49 AM, mdipierro wrote:
 
 
 
 gaehanlder.py does not import Rocket.
 
 main imports Rocket
 
 Is it possible gaehandler.py or
 app.yaml were modified?
 
 On Sep 9, 9:40 am, Jonathan Lundell jlund...@pobox.com wrote:
 On Sep 9, 2010, at 6:27 AM, mdipierro wrote:
 
 I do not understand where unable to import Rocket comes from.
 
 That's a strange error. Also, the syntax error on routes.py is on line 3, 
 which is empty; there's no code until line 4.
 
 My advice is to resolve the first error (Rocket) before worrying about the 
 routes error.
 
 On Sep 9, 8:03 am, Richard richar...@gmail.com wrote:
 I am using the following simple routes.py and find it works fine on
 GAE with latest trunk:
 
 routes_in = (
 ('/', '/init/default/index'),
 ('/topics', '/init/topics/index'),
 )
 routes_out = [(second, first) for (first, second) in routes_in]
 
 On Sep 9, 9:49 pm, mdipierro mdipie...@cs.depaul.edu wrote:
 
 i cannot reproduce this problem. Can you send me your routes?
 
 On Sep 7, 1:28 am, Miguel Goncalves goncalvesmig...@gmail.com wrote:
 
 Hi
 
 I guess this bug has not been fixed yet?
 
 I am getting the following error:
 
 unable to import Rocket
 Your routes.py has a syntax error Please fix it before you restart 
 web2py
 Traceback (most recent call last):
   File 
 /base/data/home/apps/reviewround/1.344628390884008259/gluon/rewrite.py,
 line 106, in load
 exec routesfp.read() in symbols
   File string, line 3
 
^
 SyntaxError: invalid syntax
 
 type 'exceptions.SyntaxError': invalid syntax (string, line 3)
 Traceback (most recent call last):
   File 
 /base/data/home/apps/reviewround/1.344628390884008259/gaehandler.py,
 line 52, in module
 import gluon.main
   File 
 /base/data/home/apps/reviewround/1.344628390884008259/gluon/main.py,
 line 66, in module
 rewrite.load()
   File 
 /base/data/home/apps/reviewround/1.344628390884008259/gluon/rewrite.py,
 line 114, in load
 raise e
 type 'exceptions.SyntaxError': invalid syntax (string, line 3)
 
 The routes.py looks like :
 #!/usr/bin/python
 # -*- coding: utf-8 -*-
 
 default_application = 'reviewround' # ordinarily set in base 
 routes.py
 default_controller = 'default'  # ordinarily set in 
 app-specific
 routes.py
 default_function = 'index'
 
 routes_in = ( ('/', '/reviewround/default/index'),)
 routes_out = ( ('/reviewround/default/index', '/'),)
 
 thanks
 Miguel
 
 




[web2py] web2py windows service problems

2010-09-09 Thread marktie
I tried to execute web2py as windows service, using following command:
C:\web2py python web2py.py -W install

the response was:

web2py Enterprise Web Framework
Created by Massimo Di Pierro, Copyright 2007-2010
Version 1.81.5 (2010-07-22 23:56:21)
Database drivers available: SQLite3, MSSQL/DB2
Starting hardcron...
Installing service web2py
Changing service configuration
Service updated

Succeding, to start web2py service, I executed following command with
errors:
C:\web2py NET START web2py

the response was:

Servizio web2py Service in fase di avvio .
Impossibile avviare il servizio web2py Service.
Il servizio non ha riportato alcun errore.
Ulteriori informazioni sono disponibili digitando NET HELPMSG 3534.




[web2py] Re: Parent - Child Models in a single form

2010-09-09 Thread RipRyness
Thinking about this I can't picture it.  So do you render the parent-
child form on the server?  If so do you just render inputs for one
child?  Or do you pick n number of child forms to render with the
parent?

I've done parent - child on one form.  At least it looked that way
to the user.  But it was actually two .load forms loaded into a
containing .html page using ajax to avoid page refreshes.

-Rip

On Sep 3, 4:07 pm, portly.shor...@googlemail.com
portly.shor...@googlemail.com wrote:
 I completely agree - one of the really nice things about Django is
 that it allows you to have parent - child models in a single form.

 The example from Dominic seems quite complex. Could anyone suggest
 some ideas of how we could implement this functionality within Web2Py
 - I'm happy to try and code something but as I'm new to Web2Py I'm not
 even sure where to start.

 any help at all would be appreciated.

 Kind Regards

 Portly

 On Sep 3, 9:39 pm, mart msenecal...@gmail.com wrote:



  This sounds a lot like sub-forms (ends up being part of the form, but
  can be managed separately, even at run time). I worked on Adobe's Form
  designer (which is bundled with a full version of Acrobat)... if we we
  don't have sub-forms in web2py, I would strongly recommend we create
  them :)

  Mart

  On Sep 3, 4:14 pm, mdipierro mdipie...@cs.depaul.edu wrote:

   you are right it would not but it may be a way to store multiple
   addresses (as a list of strings) without creating a table of
   addresses.

   On Sep 3, 1:10 pm, portly.shor...@googlemail.com

   portly.shor...@googlemail.com wrote:
Hi Mdipierro

firstly thank you so much for Web2Py - the more I look into it the
more I love it.

I'm slightly confused by your answer however - how would list:string
help me input data for two models at once?

kind regards

Portly

On Sep 3, 5:38 pm, mdipierro mdipie...@cs.depaul.edu wrote:

 With the new list:string it should be easy to create a widget for it.
 WIll look into it.

 On Sep 3, 10:14 am, portly.shor...@googlemail.com

 portly.shor...@googlemail.com wrote:
  Thank you very much for this Dominic. I've had a quick look and 
  there
  is a lot to take in (I guess I was hoping for a much simpler 
  solution
  lol).

  regards

  Portly

  On Sep 3, 1:28 pm, Dominic dominic.koe...@googlemail.com wrote:

   We (Sahana-Eden) use to do such things with web2py, in connection 
   with
   a RESTful API.

   See for 
   example:http://vita.sahanafoundation.org/eden/pr/person/1http://vita.sahanafo...

   It can also speak several XML formats, of course, and 
   JSON;http://vita.sahanafoundation.org/eden/pr/person/1.xmlhttp://vita.saha...

   The code behind that looks like:

   Person 
   Model:http://bazaar.launchpad.net/~flavour/sahana-eden/trunk/annotate/head%..

   The actual Person 
   controller:http://bazaar.launchpad.net/~flavour/sahana-eden/trunk/annotate/head%...

   HTML frontend 
   controller:http://bazaar.launchpad.net/~flavour/sahana-eden/trunk/annotate/head%...

   Backend 
   extensions:http://bazaar.launchpad.net/~flavour/sahana-eden/trunk/annotate/head%...

   Regards,
   Dominic

   On 3 Sep, 13:38, portly.shor...@googlemail.com

   portly.shor...@googlemail.com wrote:
Is it possible to edit a parent + child model as a single form 
and
automatically create both the parent and respective children in 
the
database.

As an example, say I have a Person model and the person can have
multiple Addresses. Is it possible to create a Person and add 
several
addresses on a single form at the same time.

Out of the box with Web2Py I know this is not possible but as 
it is a
common situation I'm sure someone has already solved this 
particular
problem.

Many Thanks in advance for any help.

Portly.- Hide quoted text -

   - Show quoted text -- Hide quoted text -

  - Show quoted text -


[web2py] Re: cherokee problem with fastcgi and uWSGI

2010-09-09 Thread salbefe
Hello,

This works fine:

uwsgi --pythonpath /var/web2py --module wsgihandler -s /tmp/
we2py.sock  --http :9090

If I point to localhost:9090 works ok and I see the welcome
application.

After that:

If I make a config.xml file as is described on 
http://projects.unbit.it/uwsgi/wiki/Example
and I try with the virtualserver wizard to creat a uWSGI server I get
the following error:

/var/web2py/config.xml seems not to be a valid uWSGI xml configuration
file.

To get these step ok my config.xml file has to be the same as this:

uwsgi

pythonpath/var/web2py//pythonpath

app mountpoint=/

scriptwsgihandler/script

/app

/uwsgi


With this I unterstand that the new virtual server (called web2py)
is working because it's active and there is a green circle near the
name of the virtual server.

On the sources section, cherokee has created a new source with nick is
uWSGI 1
On the interpreter box the following: /usr/local/bin/uwsgi -s
127.0.0.1:57527 -t 10 -M -p 1 -C  -x /var/web2py/config.xml -H /var
On connection box: 127.0.0.1:57527
and Inherit Environment is enabled.


With all of this if I point to localhost...I get the cherokee test
page and not the welcome application.

Anyone has any idea?

Thanks in advance



On 9 sep, 15:30, Jose jjac...@gmail.com wrote:
 On 9 sep, 07:42, salbefe salb...@gmail.com wrote:

  Hello,

  I'm trying to deploy web2py with cherokee on a fedora core 13 distro
  but I have several problems on it. I have read  the slice web2py with
  Cherokee via uWSGI: a simple, easy guide that it could be found in
  web2pyslices but this guide is outdated because it seems to be done
  for an older cherokee version than 1.X.X. Current cherokee version is
  1.0.8

  Some things are not clear to me:

  1.- For example where should be web2py: on /var/web2py or /var/www/
  web2py. After reading the slice it seems that it should be on /var/
  web2py.

 This should not be important, I have it in /home/web2py

  2.- www-data user does not exist on fedora distro so where it says
  sudo chown -hR www-data\: /var/web2py I did sudo chown -hR root\: /
  var/web2py

 in my case (freebsd), user=www and group=www

  3.- Its impossible to follow steps E throught G because options
  described there does not exists anymore in cherokee admin interface
  and I could not find other places where they could be.

 GUI has changed but little, are looking to see that things are in the
 new user interface.

  The same problem with the steps that are on the online book to setup
  cherokee with fastcgi interface. The steps described there should be
  now a bit different to setup web2py with cherokee.

 FastCGI is similar to uwsgi. But I think the problem is that the GUI
 was changed in Cherokee.

  I need some help, please.

 In a few days I can write as I have configured my server, including
 screenshots of the new GUI Cherokee

 Regards,
 Jose


Re: [web2py] Re: cherokee problem with fastcgi and uWSGI

2010-09-09 Thread Roberto De Ioris

 Hello,

 This works fine:

 uwsgi --pythonpath /var/web2py --module wsgihandler -s /tmp/
 we2py.sock  --http :9090

 If I point to localhost:9090 works ok and I see the welcome
 application.

 After that:

 If I make a config.xml file as is described on
 http://projects.unbit.it/uwsgi/wiki/Example
 and I try with the virtualserver wizard to creat a uWSGI server I get
 the following error:

 /var/web2py/config.xml seems not to be a valid uWSGI xml configuration
 file.

 To get these step ok my config.xml file has to be the same as this:

 uwsgi

 pythonpath/var/web2py//pythonpath

 app mountpoint=/

 scriptwsgihandler/script

 /app

 /uwsgi




I fear that Cherokee has an outdated wizard, you should be able
to load every valid uWSGI xml file in it.

I will try to send a patch to the Cherokee team ASAP.

In the mean time do not use its wizard but simply add a remote source
specifying the address of the uWSGI server

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



[web2py] Problem with crud.create and duplicate _formname

2010-09-09 Thread Álvaro J . Iradier
Hi, I think I found a problem (bug?) with crud.create and
form.custom.end:

I have the following model:

db.define_table('contents',
   Field('name', 'string', required=True, notnull=True,
requires=IS_NOT_EMPTY()),
   Field('ordering', 'integer', required=True,
requires=IS_NOT_EMPTY()),
   Field('duration', 'integer', required=True,
requires=IS_NOT_EMPTY()),
   Field('enabled', 'boolean', required=True),
   Field('file', 'upload', required=True, requires=IS_NOT_EMPTY(),
autodelete=True)
)

The following controller:

def index():
   form = crud.create(db.contents)
   if form.accepts(request.vars):
   response.flash='Inserted'
   return dict(form=form)

and the serialization of form.custom.end is:

div class=hiddeninput name=_next type=hidden /input
name=_formkey type=hidden
value=b1b19180-5226-48da-8d26-da29ed904177 /input name=_formname
type=hidden value=contents_create //divdiv
class=hiddeninput name=_next type=hidden /input
name=_formkey type=hidden
value=b1b19180-5226-48da-8d26-da29ed904177 /input name=_formname
type=hidden value=contents/None //div/form

Notice the output is duplicated, specially _formname is repeated
with a value of contents/None, which makes the form not working.

Am I doing something wrong, or is this a bug?

Thanks very much.

--
(:=:)
 Alvaro J. Iradier Muro - airad...@gmail.com


[web2py] sql.as_dict() handling of NULL datetime and other NULLs

2010-09-09 Thread Michele Comitini
Hi Massimo,


in sql.py and dal.py

def as_dict(self,datetime_to_str=False):
d = dict(self)
for k in copy.copy(d.keys()):
v=d[k]
if isinstance(v,Row):
d[k]=v.as_dict()
elif isinstance(v,Reference):
d[k]=int(v)
elif isinstance(v, (datetime.date, datetime.datetime,
datetime.time)):
if datetime_to_str:
d[k] = v.isoformat().replace('T',' ')[:19]
elif not isinstance(v,(str,unicode,int,long,float,bool)):
del d[k]
return d

if I understand correctly this code swallows NULL datetimes (and
probably other nulls), wouldn't be better to
have the following?

if d[k] is not None: del d[k]

mic


[web2py] Re: Problem with crud.create and duplicate _formname

2010-09-09 Thread mdipierro
because you cannot .accepts a crud forms. It is implicit. You can do

def index():
   form = crud.create(db.contents,message='Inserted')
   return dict(form=form)



On Sep 9, 2:51 pm, Álvaro J. Iradier airad...@gmail.com wrote:
 Hi, I think I found a problem (bug?) with crud.create and
 form.custom.end:

 I have the following model:

 db.define_table('contents',
    Field('name', 'string', required=True, notnull=True,
 requires=IS_NOT_EMPTY()),
    Field('ordering', 'integer', required=True,
 requires=IS_NOT_EMPTY()),
    Field('duration', 'integer', required=True,
 requires=IS_NOT_EMPTY()),
    Field('enabled', 'boolean', required=True),
    Field('file', 'upload', required=True, requires=IS_NOT_EMPTY(),
 autodelete=True)
 )

 The following controller:

 def index():
    form = crud.create(db.contents)
    if form.accepts(request.vars):
        response.flash='Inserted'
    return dict(form=form)

 and the serialization of form.custom.end is:

 div class=hiddeninput name=_next type=hidden /input
 name=_formkey type=hidden
 value=b1b19180-5226-48da-8d26-da29ed904177 /input name=_formname
 type=hidden value=contents_create //divdiv
 class=hiddeninput name=_next type=hidden /input
 name=_formkey type=hidden
 value=b1b19180-5226-48da-8d26-da29ed904177 /input name=_formname
 type=hidden value=contents/None //div/form

 Notice the output is duplicated, specially _formname is repeated
 with a value of contents/None, which makes the form not working.

 Am I doing something wrong, or is this a bug?

 Thanks very much.

 --
 (:=:)
  Alvaro J. Iradier Muro - airad...@gmail.com


[web2py] Re: Why Django Sucks (slides)

2010-09-09 Thread johntynan
Nice mention of web2py about the application object.

I've run into a snag with web2py by not knowing I should have have
UUID primary keys... Is this something that could be handled at the
web2py level and not within the app/model itself?  Would this be
similar to what the author means by late binding FKs?



On Sep 9, 1:13 pm, Adi aditya.sa...@gmail.com wrote:
 http://www.scribd.com/doc/37113340/Why-Django-Sucks-and-How-we-Can-Fi...

 It would be interesting to head community's thoughts on some of the
 problems there. :)


[web2py] Re: Making asynchronous request in web2py

2010-09-09 Thread Michael Ellis
Others may have more experience with this, but it sounds like your
example could be handled with a cron job that periodically checks for
newly registered users.  On GAE, you also have the option to use a
task queue.

On Sep 9, 7:05 am, Adi aditya.sa...@gmail.com wrote:
 Hi,

 I have this test case:

 1. User registers in app.
 2. App sends him greeting email (Welcome to so-and-so app).
 3. App adds his email/name etc to mailing application (like Mailchimp)
 for auto-subscribing to newsletter.

 Now user expects steps 1 completion to take him to the next 'default/
 index' page, and we don't want steps 2 and 3 to prevent completion of
 step 1. Is there a way to make step 2 and 3 complete independently, in
 a way that user's experience is not slowed down?

 Think of it as being equivalent of asynchronous ajax request, which
 doesn't wait for response before moving to the next piece of
 javascript.

 Any help on this? I know we should not create threads because web2py
 handles that for us (read in some older post long long ago).

 -- Adi


[web2py] Re: cherokee problem with fastcgi and uWSGI

2010-09-09 Thread salbefe
looking at /var/log/cherokee/error_log that is what I get:


[uWSGI] parsing config file /var/web2py/config.xml
*** Starting uWSGI 0.9.6 (32bit) on [Thu Sep  9 23:37:45 2010] ***
compiled with version: 4.4.4 20100630 (Red Hat 4.4.4-10)
Python version: 2.6.4 (r264:75706, Jun  4 2010, 18:20:16)
[GCC 4.4.4 20100503 (Red Hat 4.4.4-2)]
uWSGI running as root, you can use --uid/--gid/--chroot options
 *** WARNING: you are running uWSGI as root !!! (use the --uid flag)
***
your memory page size is 4096 bytes
 *** WARNING: you have enabled harakiri without post buffering. Slow
upload could be rejected on post-unbuffered webservers ***
allocated 404 bytes (0 KB) for 1 request's buffer.
Setting PythonHome to /var...
'import site' failed; use -v for traceback
binding on TCP port: 36986
your server socket listen backlog is limited to 64 connections
initializing hooks...done.
'import site' failed; use -v for traceback
added /var/web2py/ to pythonpath.
interpreter for app 0 initialized.
Traceback (most recent call last):
  File /var/web2py/wsgihandler.py, line 20, in module
import os
ImportError: No module named os
*** uWSGI is running in multiple interpreter mode ***
spawned uWSGI master process (pid: 3360)
spawned uWSGI worker 1 (pid: 3361)
'import site' failed; use -v for traceback
added /var/web2py/ to pythonpath.
interpreter for app 0 initialized.
ImportError: No module named �O�^H^P^G�^H^P
[pid: 3361|app: -1|req: -1/1] 127.0.0.1 () {54 vars in 879 bytes} [Thu
Sep  9 23:37:46 2010] GET / = generated 46 bytes in 2 msecs (HTTP/1.1
500) 2 headers in 63 bytes (0 async switches on async core 0)


Perhaps this could help.
Thanks

On 9 sep, 19:44, Roberto De Ioris robe...@unbit.it wrote:
  Hello,

  This works fine:

  uwsgi --pythonpath /var/web2py --module wsgihandler -s /tmp/
  we2py.sock  --http :9090

  If I point to localhost:9090 works ok and I see the welcome
  application.

  After that:

  If I make a config.xml file as is described on
 http://projects.unbit.it/uwsgi/wiki/Example
  and I try with the virtualserver wizard to creat a uWSGI server I get
  the following error:

  /var/web2py/config.xml seems not to be a valid uWSGI xml configuration
  file.

  To get these step ok my config.xml file has to be the same as this:

  uwsgi

      pythonpath/var/web2py//pythonpath

      app mountpoint=/

      scriptwsgihandler/script

      /app

  /uwsgi

 I fear that Cherokee has an outdated wizard, you should be able
 to load every valid uWSGI xml file in it.

 I will try to send a patch to the Cherokee team ASAP.

 In the mean time do not use its wizard but simply add a remote source
 specifying the address of the uWSGI server

 --
 Roberto De Iorishttp://unbit.it


Re: [web2py] Re: Why Django Sucks (slides)

2010-09-09 Thread Bruno Rocha
The mention was about web.py not web2py

2010/9/9 johntynan jgty...@gmail.com

 Nice mention of web2py about the application object.

 I've run into a snag with web2py by not knowing I should have have
 UUID primary keys... Is this something that could be handled at the
 web2py level and not within the app/model itself?  Would this be
 similar to what the author means by late binding FKs?



 On Sep 9, 1:13 pm, Adi aditya.sa...@gmail.com wrote:
  http://www.scribd.com/doc/37113340/Why-Django-Sucks-and-How-we-Can-Fi...
 
  It would be interesting to head community's thoughts on some of the
  problems there. :)


--

http://rochacbruno.com.br


[web2py] Re: Why Django Sucks (slides)

2010-09-09 Thread mdipierro
Where do you see the reference to web2py in the document. I did not
see it.

web2py allows for keyed tables (not on all supported database) and a
key can be uuid.
yes forms will not work well with it (at least I never tried) and
web2py was designed with an integer ID in mind.

This is not a fundamental design issue but more of a constraint that
is imposed in various parts of the code. For example db.table[x] if x
is integer assumes you want a record with id==x and if x is a string,
it assumes you want the field object with that name.

In retrospect assuming id was integer was a mistake (we copied Django
and we should not have) and this is the main obstacle to port web2py
DAL API on top of NoSQL databases.

Eventually this constraint will be relaxed.

Massimo

On Sep 9, 4:07 pm, johntynan jgty...@gmail.com wrote:
 Nice mention of web2py about the application object.

 I've run into a snag with web2py by not knowing I should have have
 UUID primary keys... Is this something that could be handled at the
 web2py level and not within the app/model itself?  Would this be
 similar to what the author means by late binding FKs?

 On Sep 9, 1:13 pm, Adi aditya.sa...@gmail.com wrote:

 http://www.scribd.com/doc/37113340/Why-Django-Sucks-and-How-we-Can-Fi...

  It would be interesting to head community's thoughts on some of the
  problems there. :)




[web2py] Re: Making asynchronous request in web2py

2010-09-09 Thread mdipierro
This app

   http://vizworkshop.cct.lsu.edu/viz2010

Stored here:

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

Does what you asked. Look into the lola function:

   http://code.google.com/p/hevw/source/browse/models/db.py

On Sep 9, 6:05 am, Adi aditya.sa...@gmail.com wrote:
 Hi,

 I have this test case:

 1. User registers in app.
 2. App sends him greeting email (Welcome to so-and-so app).
 3. App adds his email/name etc to mailing application (like Mailchimp)
 for auto-subscribing to newsletter.

 Now user expects steps 1 completion to take him to the next 'default/
 index' page, and we don't want steps 2 and 3 to prevent completion of
 step 1. Is there a way to make step 2 and 3 complete independently, in
 a way that user's experience is not slowed down?

 Think of it as being equivalent of asynchronous ajax request, which
 doesn't wait for response before moving to the next piece of
 javascript.

 Any help on this? I know we should not create threads because web2py
 handles that for us (read in some older post long long ago).

 -- Adi


[web2py] Re: Expando and Polymodel on GAE?

2010-09-09 Thread Dave
Using the test code you provided before, I now get this error:

---
Traceback (most recent call last):
  File C:\Users\Dave\Documents\Python\web2py\gluon\restricted.py,
line 188, in restricted
exec ccode in environment
  File C:\Users\Dave\Documents\Python\web2py\applications\welcome/
models/db.py, line 79, in module
db.define_table('person',Field('first_name'),
polymodel=db.contact)
  File C:\Users\Dave\Documents\Python\web2py\gluon\contrib\gql.py,
line 128, in define_table
fields.insert(0,args['polymodel'])
AttributeError: 'tuple' object has no attribute 'insert'
---

That points to one of the new lines of code you added in rev 854.

~Dave

On Sep 8, 9:36 am, mdipierro mdipie...@cs.depaul.edu wrote:
 Can you please try again using latest trunk?

 Massimo

   Can you help testingpolymodel? In trunk:

   db=DAL('gae')
   db.define_table('contact',Field('address'),polymodel=True)
   db.define_table('person',Field('first_name'),polymodel=db.contact)
   db.define_table('company',Field('business_name'),
  polymodel=db.contact)

   db.person.insert(first_name=John, address=here')
   db.company.insert(business_name=John Inc, address=there')
   contacts = db(db.contact.id0).select() # should lists both persons
   and conpanies

   Massimo


Re: [web2py] Re: cherokee problem with fastcgi and uWSGI

2010-09-09 Thread Roberto De Ioris

 looking at /var/log/cherokee/error_log that is what I get:


 [uWSGI] parsing config file /var/web2py/config.xml
 *** Starting uWSGI 0.9.6 (32bit) on [Thu Sep  9 23:37:45 2010] ***
 compiled with version: 4.4.4 20100630 (Red Hat 4.4.4-10)
 Python version: 2.6.4 (r264:75706, Jun  4 2010, 18:20:16)
 [GCC 4.4.4 20100503 (Red Hat 4.4.4-2)]
 uWSGI running as root, you can use --uid/--gid/--chroot options
  *** WARNING: you are running uWSGI as root !!! (use the --uid flag)
 ***
 your memory page size is 4096 bytes
  *** WARNING: you have enabled harakiri without post buffering. Slow
 upload could be rejected on post-unbuffered webservers ***
 allocated 404 bytes (0 KB) for 1 request's buffer.
 Setting PythonHome to /var...
 'import site' failed; use -v for traceback
 binding on TCP port: 36986
 your server socket listen backlog is limited to 64 connections
 initializing hooks...done.
 'import site' failed; use -v for traceback
 added /var/web2py/ to pythonpath.
 interpreter for app 0 initialized.
 Traceback (most recent call last):
   File /var/web2py/wsgihandler.py, line 20, in module
 import os
 ImportError: No module named os
 *** uWSGI is running in multiple interpreter mode ***
 spawned uWSGI master process (pid: 3360)
 spawned uWSGI worker 1 (pid: 3361)
 'import site' failed; use -v for traceback
 added /var/web2py/ to pythonpath.
 interpreter for app 0 initialized.
 ImportError: No module named �O�^H^P^G�^H^P
 [pid: 3361|app: -1|req: -1/1] 127.0.0.1 () {54 vars in 879 bytes} [Thu
 Sep  9 23:37:46 2010] GET / = generated 46 bytes in 2 msecs (HTTP/1.1
 500) 2 headers in 63 bytes (0 async switches on async core 0)






Please run uWSGI independently from cherokee (its wizard is broken) with
one of the configuration you find on the official uWSGI site.

Then simply add a 'remote source' that point to the socket you have
choosen and map it to the directory /

All of your pythonpath and virtualenv are wrong.

In one of the previous post you managed to run flawlessly with the
embedded http server. Simply substitute --http with --socket

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



Re: [web2py] Re: Routes.py on GAE

2010-09-09 Thread Miguel Goncalves
in my case I was using the following routes.py

#!/usr/bin/python
# -*- coding: utf-8 -*-

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


routes_in = ( ('/', '/reviewround/default/index'),)
routes_out = ( ('/reviewround/default/index', '/'),)

-Miguel


On Thu, Sep 9, 2010 at 9:28 AM, Jonathan Lundell jlund...@pobox.com wrote:

 On Sep 9, 2010, at 9:17 AM, mdipierro wrote:
 
  try:
 import rocket
  except:
 logging.warn('unable to import Rocket')
 
  True. This is supposed to fail on GAE. I will change it. No need to
  try the import and issue a warning on GAE.

 ...which leaves the mystery of the routes syntax error.

 I'd try it with the first three lines (two comments and blank line)
 removed, and see what happens.

 I'd also carefully check routes.py for invisible garbage characters,
 perhaps from some word processor. Word's idea of a non-breaking space, for
 example.

 If possible, zip the routes.py that you're uploading to GAE, and send me a
 copy.

 
 
 
  On Sep 9, 9:57 am, Jonathan Lundell jlund...@pobox.com wrote:
  On Sep 9, 2010, at 7:49 AM, mdipierro wrote:
 
 
 
  gaehanlder.py does not import Rocket.
 
  main imports Rocket
 
  Is it possible gaehandler.py or
  app.yaml were modified?
 
  On Sep 9, 9:40 am, Jonathan Lundell jlund...@pobox.com wrote:
  On Sep 9, 2010, at 6:27 AM, mdipierro wrote:
 
  I do not understand where unable to import Rocket comes from.
 
  That's a strange error. Also, the syntax error on routes.py is on line
 3, which is empty; there's no code until line 4.
 
  My advice is to resolve the first error (Rocket) before worrying about
 the routes error.
 
  On Sep 9, 8:03 am, Richard richar...@gmail.com wrote:
  I am using the following simple routes.py and find it works fine on
  GAE with latest trunk:
 
  routes_in = (
  ('/', '/init/default/index'),
  ('/topics', '/init/topics/index'),
  )
  routes_out = [(second, first) for (first, second) in routes_in]
 
  On Sep 9, 9:49 pm, mdipierro mdipie...@cs.depaul.edu wrote:
 
  i cannot reproduce this problem. Can you send me your routes?
 
  On Sep 7, 1:28 am, Miguel Goncalves goncalvesmig...@gmail.com
 wrote:
 
  Hi
 
  I guess this bug has not been fixed yet?
 
  I am getting the following error:
 
  unable to import Rocket
  Your routes.py has a syntax error Please fix it before you restart
 web2py
  Traceback (most recent call last):
File
 /base/data/home/apps/reviewround/1.344628390884008259/gluon/rewrite.py,
  line 106, in load
  exec routesfp.read() in symbols
File string, line 3
 
 ^
  SyntaxError: invalid syntax
 
  type 'exceptions.SyntaxError': invalid syntax (string, line 3)
  Traceback (most recent call last):
File
 /base/data/home/apps/reviewround/1.344628390884008259/gaehandler.py,
  line 52, in module
  import gluon.main
File
 /base/data/home/apps/reviewround/1.344628390884008259/gluon/main.py,
  line 66, in module
  rewrite.load()
File
 /base/data/home/apps/reviewround/1.344628390884008259/gluon/rewrite.py,
  line 114, in load
  raise e
  type 'exceptions.SyntaxError': invalid syntax (string, line 3)
 
  The routes.py looks like :
  #!/usr/bin/python
  # -*- coding: utf-8 -*-
 
  default_application = 'reviewround' # ordinarily set in base
 routes.py
  default_controller = 'default'  # ordinarily set in
 app-specific
  routes.py
  default_function = 'index'
 
  routes_in = ( ('/', '/reviewround/default/index'),)
  routes_out = ( ('/reviewround/default/index', '/'),)
 
  thanks
  Miguel
 
 





Re: [web2py] Re: Routes.py on GAE

2010-09-09 Thread Jonathan Lundell
On Sep 9, 2010, at 9:07 PM, Miguel Goncalves wrote:
 in my case I was using the following routes.py

What I'm looking for is the file itself (preferably zipped). I'm wondering if 
there might be something in it that isn't surviving a paste into email, because 
I don' t seen anything in line 3 that would cause a syntax error. (Notice that 
this is a Python syntax error, not a complaint from the rewrite code.)

 
 #!/usr/bin/python
 # -*- coding: utf-8 -*-
 
 default_application = 'reviewround' # ordinarily set in base routes.py
 default_controller = 'default'  # ordinarily set in app-specific 
 routes.py
 default_function = 'index' 
 
 
 routes_in = ( ('/', '/reviewround/default/index'),)
 routes_out = ( ('/reviewround/default/index', '/'),)
 
 -Miguel
 
 
 On Thu, Sep 9, 2010 at 9:28 AM, Jonathan Lundell jlund...@pobox.com wrote:
 On Sep 9, 2010, at 9:17 AM, mdipierro wrote:
 
  try:
 import rocket
  except:
 logging.warn('unable to import Rocket')
 
  True. This is supposed to fail on GAE. I will change it. No need to
  try the import and issue a warning on GAE.
 
 ...which leaves the mystery of the routes syntax error.
 
 I'd try it with the first three lines (two comments and blank line) removed, 
 and see what happens.
 
 I'd also carefully check routes.py for invisible garbage characters, perhaps 
 from some word processor. Word's idea of a non-breaking space, for example.
 
 If possible, zip the routes.py that you're uploading to GAE, and send me a 
 copy.
 
 
 
 
  On Sep 9, 9:57 am, Jonathan Lundell jlund...@pobox.com wrote:
  On Sep 9, 2010, at 7:49 AM, mdipierro wrote:
 
 
 
  gaehanlder.py does not import Rocket.
 
  main imports Rocket
 
  Is it possible gaehandler.py or
  app.yaml were modified?
 
  On Sep 9, 9:40 am, Jonathan Lundell jlund...@pobox.com wrote:
  On Sep 9, 2010, at 6:27 AM, mdipierro wrote:
 
  I do not understand where unable to import Rocket comes from.
 
  That's a strange error. Also, the syntax error on routes.py is on line 
  3, which is empty; there's no code until line 4.
 
  My advice is to resolve the first error (Rocket) before worrying about 
  the routes error.
 
  On Sep 9, 8:03 am, Richard richar...@gmail.com wrote:
  I am using the following simple routes.py and find it works fine on
  GAE with latest trunk:
 
  routes_in = (
  ('/', '/init/default/index'),
  ('/topics', '/init/topics/index'),
  )
  routes_out = [(second, first) for (first, second) in routes_in]
 
  On Sep 9, 9:49 pm, mdipierro mdipie...@cs.depaul.edu wrote:
 
  i cannot reproduce this problem. Can you send me your routes?
 
  On Sep 7, 1:28 am, Miguel Goncalves goncalvesmig...@gmail.com wrote:
 
  Hi
 
  I guess this bug has not been fixed yet?
 
  I am getting the following error:
 
  unable to import Rocket
  Your routes.py has a syntax error Please fix it before you restart 
  web2py
  Traceback (most recent call last):
File 
  /base/data/home/apps/reviewround/1.344628390884008259/gluon/rewrite.py,
  line 106, in load
  exec routesfp.read() in symbols
File string, line 3
 
 ^
  SyntaxError: invalid syntax
 
  type 'exceptions.SyntaxError': invalid syntax (string, line 3)
  Traceback (most recent call last):
File 
  /base/data/home/apps/reviewround/1.344628390884008259/gaehandler.py,
  line 52, in module
  import gluon.main
File 
  /base/data/home/apps/reviewround/1.344628390884008259/gluon/main.py,
  line 66, in module
  rewrite.load()
File 
  /base/data/home/apps/reviewround/1.344628390884008259/gluon/rewrite.py,
  line 114, in load
  raise e
  type 'exceptions.SyntaxError': invalid syntax (string, line 3)
 
  The routes.py looks like :
  #!/usr/bin/python
  # -*- coding: utf-8 -*-
 
  default_application = 'reviewround' # ordinarily set in base 
  routes.py
  default_controller = 'default'  # ordinarily set in 
  app-specific
  routes.py
  default_function = 'index'
 
  routes_in = ( ('/', '/reviewround/default/index'),)
  routes_out = ( ('/reviewround/default/index', '/'),)
 
  thanks
  Miguel
 
 
 
 
 




[web2py] Re: intercepting SQLFORM delete

2010-09-09 Thread Richard
Wow so fast. Massimo you are amazing!


On Sep 9, 11:26 pm, mdipierro mdipie...@cs.depaul.edu wrote:
 oops. fixed in trunk

 On Sep 9, 7:50 am, Richard richar...@gmail.com wrote:

  I want to do some preprocessing before permitting SQLFORM to delete a
  record:

  topic = db.topic[topic_id]
  form = SQLFORM(db.topic, topic)
  if form.accepts(request.vars, session, dbio=False):
      if form.vars.get('delete_this_record'):
          response.flash = 'Delete intercepted'
      else:
          response.flash = 'Update intercepted'

  However I found dbio only applies to insert/update and doesn't affect
  delete (sqlhtml.py: 952, 1031).
  Why doesn't dbio apply to all databases operations?
  Is there an alternative way to intercept SQLFORM deletion?

  thanks,
  Richard




[web2py] Re: How to insert only new items in db as fast as possible?

2010-09-09 Thread Richard
I don't know a good general solution for web2py, but if just targeting
GAE:
1) request all existing products
2) find which of your products are new
3) insert new products in a single operation using the GAE API:
db.put(list_of_models)

And if you have timeouts then break it up with Task Queues.




On Sep 9, 4:37 pm, Miguel goncalvesmig...@gmail.com wrote:
 Hi

 I have the following table:
 db.define_table(products,
     Field(categoryID, db.productCategory, writable=False,
 readable=False, requires=IS_IN_DB(db, productCategory.id,
 productCategory.name) ), # reference field
     Field(productName, 'string',length=512,  default=None),
     Field(description, 'text',default=None)
 )

 - I have a list of (2) rows that might contain products and I
 would like to update my table. However some products might already be
 in the db while others are completely new.
 - I want to insert a row if it does not exist in the db (productName
 could play the role of the identifier here) is already there AND
 update a row in the case the product already exists in the DB

 I can do it pretty easily if I go item by item and check if it already
 exits in the db and then take the appropriate action (insert or
 update). What I am looking for is the most efficient way to do this
 (especially on GAE).

 thanks
 Miguel


[web2py] Re: Making asynchronous request in web2py

2010-09-09 Thread Adi
Question: Will the function lola execute in a different thread or
something?

On Sep 10, 2:50 am, mdipierro mdipie...@cs.depaul.edu wrote:
 This app

    http://vizworkshop.cct.lsu.edu/viz2010

 Stored here:

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

 Does what you asked. Look into the lola function:

    http://code.google.com/p/hevw/source/browse/models/db.py

 On Sep 9, 6:05 am, Adi aditya.sa...@gmail.com wrote:



  Hi,

  I have this test case:

  1. User registers in app.
  2. App sends him greeting email (Welcome to so-and-so app).
  3. App adds his email/name etc to mailing application (like Mailchimp)
  for auto-subscribing to newsletter.

  Now user expects steps 1 completion to take him to the next 'default/
  index' page, and we don't want steps 2 and 3 to prevent completion of
  step 1. Is there a way to make step 2 and 3 complete independently, in
  a way that user's experience is not slowed down?

  Think of it as being equivalent of asynchronous ajax request, which
  doesn't wait for response before moving to the next piece of
  javascript.

  Any help on this? I know we should not create threads because web2py
  handles that for us (read in some older post long long ago).

  -- Adi


[web2py] Re: Making asynchronous request in web2py

2010-09-09 Thread Adi
Want to avoid cron. Crons need to run in a separate web2py instance,
and there are some issues we've faced in keeping that alive and
running without memory issues.

-- Aditya

On Sep 10, 2:16 am, Michael Ellis michael.f.el...@gmail.com wrote:
 Others may have more experience with this, but it sounds like your
 example could be handled with a cron job that periodically checks for
 newly registered users.  On GAE, you also have the option to use a
 task queue.

 On Sep 9, 7:05 am, Adi aditya.sa...@gmail.com wrote:



  Hi,

  I have this test case:

  1. User registers in app.
  2. App sends him greeting email (Welcome to so-and-so app).
  3. App adds his email/name etc to mailing application (like Mailchimp)
  for auto-subscribing to newsletter.

  Now user expects steps 1 completion to take him to the next 'default/
  index' page, and we don't want steps 2 and 3 to prevent completion of
  step 1. Is there a way to make step 2 and 3 complete independently, in
  a way that user's experience is not slowed down?

  Think of it as being equivalent of asynchronous ajax request, which
  doesn't wait for response before moving to the next piece of
  javascript.

  Any help on this? I know we should not create threads because web2py
  handles that for us (read in some older post long long ago).

  -- Adi


Re: [web2py] Re: intercepting SQLFORM delete

2010-09-09 Thread bally boy
Ya that is true..  Have been following the mailing list closely and will
definitely agree with you..Massimo is amazing. In fact Massimo is to
web2py what Guido is to python... wow that does sound good! :-)

On Fri, Sep 10, 2010 at 9:58 AM, Richard richar...@gmail.com wrote:

 Wow so fast. Massimo you are amazing!


 On Sep 9, 11:26 pm, mdipierro mdipie...@cs.depaul.edu wrote:
  oops. fixed in trunk
 
  On Sep 9, 7:50 am, Richard richar...@gmail.com wrote:
 
   I want to do some preprocessing before permitting SQLFORM to delete a
   record:
 
   topic = db.topic[topic_id]
   form = SQLFORM(db.topic, topic)
   if form.accepts(request.vars, session, dbio=False):
   if form.vars.get('delete_this_record'):
   response.flash = 'Delete intercepted'
   else:
   response.flash = 'Update intercepted'
 
   However I found dbio only applies to insert/update and doesn't affect
   delete (sqlhtml.py: 952, 1031).
   Why doesn't dbio apply to all databases operations?
   Is there an alternative way to intercept SQLFORM deletion?
 
   thanks,
   Richard
 
 



Re: [web2py] Re: Install pyodbc in standalone web2py

2010-09-09 Thread David Mitchell
Thanks Massimo - that'd be very welcome.  I've installed pyodbc on several
occasions to use with web2py, and it'd be very handy to have it bundled

Now about that CouchDB interface... ;-

Regards

Dave M.


On 4 September 2010 02:40, mdipierro mdipie...@cs.depaul.edu wrote:

 We are considering making pyodbc part of the standard distribution. It
 is going to take a little way since the process of building binary
 distribution and is a little cumbersome.

 On Sep 3, 11:27 am, jrpfinch jrpfi...@gmail.com wrote:
  I am using web2py.exe from the command line instead of a proper
  installation of python as I have no access to my registry.  Is it
  possible to install pyodbc to such an instance of web2py?



[web2py] Re: Problem with crud.create and duplicate _formname

2010-09-09 Thread Álvaro J . Iradier
Thanks Massimo.

It's impossible to have better support than web2py, you and this
community are impressing, five stars!

So, assumming I'm doing other things between the crud.create and the
return:

def index():
   form = crud.create(db.contents,message='Inserted')
   ... #other code
   return dict(form=form, other_variables...)

Question is: what's the best way for checking if the crud accepted
the input, and a new record was created? I just got it working by
checking if form.vars.id != None, but is there a better or official
way of doing it?

Thanks.

On 9 sep, 22:31, mdipierro mdipie...@cs.depaul.edu wrote:
 because you cannot .accepts a crud forms. It is implicit. You can do

 def index():
    form = crud.create(db.contents,message='Inserted')
    return dict(form=form)

 On Sep 9, 2:51 pm, Álvaro J. Iradier airad...@gmail.com wrote:



  Hi, I think I found a problem (bug?) with crud.create and
  form.custom.end:

  I have the following model:

  db.define_table('contents',
     Field('name', 'string', required=True, notnull=True,
  requires=IS_NOT_EMPTY()),
     Field('ordering', 'integer', required=True,
  requires=IS_NOT_EMPTY()),
     Field('duration', 'integer', required=True,
  requires=IS_NOT_EMPTY()),
     Field('enabled', 'boolean', required=True),
     Field('file', 'upload', required=True, requires=IS_NOT_EMPTY(),
  autodelete=True)
  )

  The following controller:

  def index():
     form = crud.create(db.contents)
     if form.accepts(request.vars):
         response.flash='Inserted'
     return dict(form=form)

  and the serialization of form.custom.end is:

  div class=hiddeninput name=_next type=hidden /input
  name=_formkey type=hidden
  value=b1b19180-5226-48da-8d26-da29ed904177 /input name=_formname
  type=hidden value=contents_create //divdiv
  class=hiddeninput name=_next type=hidden /input
  name=_formkey type=hidden
  value=b1b19180-5226-48da-8d26-da29ed904177 /input name=_formname
  type=hidden value=contents/None //div/form

  Notice the output is duplicated, specially _formname is repeated
  with a value of contents/None, which makes the form not working.

  Am I doing something wrong, or is this a bug?

  Thanks very much.

  --
  (:=:)
   Alvaro J. Iradier Muro - airad...@gmail.com