[web2py] EditableGrid

2010-09-10 Thread Mathieu Clabaut
Hello,

 It may be of interest to some of you :
http://www.webismymind.be/editablegrid/

-Mathieu


[web2py] jqgrid (plugin_wiki) button and other info

2010-09-10 Thread ceriox
hi all,
i'm learning jqgrid and i have some question:

1) how i can make a column with a button or image for do some stuff
like insert new record, delete record etc

2) how i can change column header or take it from label of a field?

3) how i setup width with a % and not with a fixed pixel number?

4) how i can hidden the id column? (if i don't show it the dable don't
work)

5) how i can setup multi line field?

6) how i can replace the value of a field with an image (for boolean
field i want a green V for true value and a red X for false value)

7) how i can use the double click event on a table row and call a
function sending id of the cliccked row?

thanks for help


[web2py] Re: EditableGrid

2010-09-10 Thread ceriox
cute,
u can post an easy working web2py example?


On 10 Set, 09:02, Mathieu Clabaut mathieu.clab...@gmail.com wrote:
 Hello,

  It may be of interest to some of you :http://www.webismymind.be/editablegrid/

 -Mathieu


Re: [web2py] Re: EditableGrid

2010-09-10 Thread Mathieu Clabaut
Alas not, I didn't try it with web2py..;

-Mathieu

On Fri, Sep 10, 2010 at 10:08, ceriox cer...@gmail.com wrote:

 cute,
 u can post an easy working web2py example?


 On 10 Set, 09:02, Mathieu Clabaut mathieu.clab...@gmail.com wrote:
  Hello,
 
   It may be of interest to some of you :
 http://www.webismymind.be/editablegrid/
 
  -Mathieu



[web2py] Re: cherokee problem with fastcgi and uWSGI

2010-09-10 Thread salbefe
Roberto, thank you for all your responses by I can't make this thing
working.

As you told me I did the following:

In a new terminal and as root I did :uwsgi --pythonpath /var/web2py --
module wsgihandler -s /tmp/
we2bpy.sock  --socket :9092 and this one too:

uwsgi --pythonpath /var/web2py --module wsgihandler --socket :9092

Then in cherokee-admin I created a new source as follows:


Type: remote host.
Nick: web2py
Connection : 127.0.0.1:9092

And then I have Virtual Sever - default and rule - Directory /

with all this config when I point to localhos I get: uWSGI Error, wsgi
application not found.


On 10 sep, 01:31, Roberto De Ioris robe...@unbit.it wrote:
  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 Iorishttp://unbit.it


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

2010-09-10 Thread Roberto De Ioris

Il giorno 10/set/2010, alle ore 10.36, salbefe ha scritto:

 Roberto, thank you for all your responses by I can't make this thing
 working.
 
 As you told me I did the following:
 
 In a new terminal and as root I did :uwsgi --pythonpath /var/web2py --
 module wsgihandler -s /tmp/
 we2bpy.sock  --socket :9092 and this one too:
 
 uwsgi --pythonpath /var/web2py --module wsgihandler --socket :9092
 
 Then in cherokee-admin I created a new source as follows:
 
 
 Type: remote host.
 Nick: web2py
 Connection : 127.0.0.1:9092
 
 And then I have Virtual Sever - default and rule - Directory /
 
 with all this config when I point to localhos I get: uWSGI Error, wsgi
 application not found.
 


That is a step forward :)

You should fix the SCRIPT_NAME, but it is an annoying task.

Download the current mercurial tip (it is stable as it will be the 0.9.6.1) and 
it will
automagically manage the SCRIPT_NAME issue.

In the mean time i have written an updated cherokee wizard that supports 
xml,python,wsgi and ini files.
--
Roberto De Ioris
http://unbit.it
JID: robe...@jabber.unbit.it



[web2py] Re: cherokee problem with fastcgi and uWSGI

2010-09-10 Thread salbefe
After downloading the current mercurial tip and after trying to
compile I get the following error:

[r...@tango uwsgi]# make -f Makefile.Py26
python2.6 uwsgiconfig.py --build
Traceback (most recent call last):
  File uwsgiconfig.py, line 83, in module
gcc_version = str(spcall2(%s -v % GCC)).split('\n')[-1].split()
[2]
  File uwsgiconfig.py, line 79, in spcall2
return p.stderr.read().rstrip().decode()
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position
787: ordinal not in range(128)
make: *** [all] Error 1


:((



On 10 sep, 10:49, Roberto De Ioris robe...@unbit.it wrote:
 Il giorno 10/set/2010, alle ore 10.36, salbefe ha scritto:





  Roberto, thank you for all your responses by I can't make this thing
  working.

  As you told me I did the following:

  In a new terminal and as root I did :uwsgi --pythonpath /var/web2py --
  module wsgihandler -s /tmp/
  we2bpy.sock  --socket :9092 and this one too:

  uwsgi --pythonpath /var/web2py --module wsgihandler --socket :9092

  Then in cherokee-admin I created a new source as follows:

  Type: remote host.
  Nick: web2py
  Connection : 127.0.0.1:9092

  And then I have Virtual Sever - default and rule - Directory /

  with all this config when I point to localhos I get: uWSGI Error, wsgi
  application not found.

 That is a step forward :)

 You should fix the SCRIPT_NAME, but it is an annoying task.

 Download the current mercurial tip (it is stable as it will be the 0.9.6.1) 
 and it will
 automagically manage the SCRIPT_NAME issue.

 In the mean time i have written an updated cherokee wizard that supports 
 xml,python,wsgi and ini files.
 --
 Roberto De Iorishttp://unbit.it
 JID: robe...@jabber.unbit.it


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

2010-09-10 Thread Roberto De Ioris

Il giorno 10/set/2010, alle ore 11.17, salbefe ha scritto:

 After downloading the current mercurial tip and after trying to
 compile I get the following error:
 
 [r...@tango uwsgi]# make -f Makefile.Py26
 python2.6 uwsgiconfig.py --build
 Traceback (most recent call last):
  File uwsgiconfig.py, line 83, in module
gcc_version = str(spcall2(%s -v % GCC)).split('\n')[-1].split()
 [2]
  File uwsgiconfig.py, line 79, in spcall2
return p.stderr.read().rstrip().decode()
 UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position
 787: ordinal not in range(128)
 make: *** [all] Error 1
 
 
 :((



Can you post the output of 

gcc -v

?

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



[web2py] Re: cherokee problem with fastcgi and uWSGI

2010-09-10 Thread salbefe
gcc -v

Usando especificaciones internas.
Objetivo: i686-redhat-linux
Configurado con: ../configure --prefix=/usr --mandir=/usr/share/man --
infodir=/usr/share/info --with-bugurl=http://bugzilla.redhat.com/
bugzilla --enable-bootstrap --enable-shared --enable-threads=posix --
enable-checking=release --with-system-zlib --enable-__cxa_atexit --
disable-libunwind-exceptions --enable-gnu-unique-object --enable-
languages=c,c++,objc,obj-c++,java,fortran,ada --enable-java-awt=gtk --
disable-dssi --with-java-home=/usr/lib/jvm/java-1.5.0-gcj-1.5.0.0/jre
--enable-libgcj-multifile --enable-java-maintainer-mode --with-ecj-
jar=/usr/share/java/eclipse-ecj.jar --disable-libjava-multilib --with-
ppl --with-cloog --with-tune=generic --with-arch=i686 --build=i686-
redhat-linux
Modelo de hilos: posix
gcc versión 4.4.4 20100630 (Red Hat 4.4.4-10) (GCC)



On 10 sep, 11:32, Roberto De Ioris robe...@unbit.it wrote:
 Il giorno 10/set/2010, alle ore 11.17, salbefe ha scritto:





  After downloading the current mercurial tip and after trying to
  compile I get the following error:

  [r...@tango uwsgi]# make -f Makefile.Py26
  python2.6 uwsgiconfig.py --build
  Traceback (most recent call last):
   File uwsgiconfig.py, line 83, in module
     gcc_version = str(spcall2(%s -v % GCC)).split('\n')[-1].split()
  [2]
   File uwsgiconfig.py, line 79, in spcall2
     return p.stderr.read().rstrip().decode()
  UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position
  787: ordinal not in range(128)
  make: *** [all] Error 1

  :((

 Can you post the output of

 gcc -v

 ?

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


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

2010-09-10 Thread Roberto De Ioris

Il giorno 10/set/2010, alle ore 12.07, salbefe ha scritto:

 gcc -v
 
 Usando especificaciones internas.
 Objetivo: i686-redhat-linux
 Configurado con: ../configure --prefix=/usr --mandir=/usr/share/man --
 infodir=/usr/share/info --with-bugurl=http://bugzilla.redhat.com/
 bugzilla --enable-bootstrap --enable-shared --enable-threads=posix --
 enable-checking=release --with-system-zlib --enable-__cxa_atexit --
 disable-libunwind-exceptions --enable-gnu-unique-object --enable-
 languages=c,c++,objc,obj-c++,java,fortran,ada --enable-java-awt=gtk --
 disable-dssi --with-java-home=/usr/lib/jvm/java-1.5.0-gcj-1.5.0.0/jre
 --enable-libgcj-multifile --enable-java-maintainer-mode --with-ecj-
 jar=/usr/share/java/eclipse-ecj.jar --disable-libjava-multilib --with-
 ppl --with-cloog --with-tune=generic --with-arch=i686 --build=i686-
 redhat-linux
 Modelo de hilos: posix
 gcc versión 4.4.4 20100630 (Red Hat 4.4.4-10) (GCC)


Ok, retry with the latest tip (it was a problem with python3.k compatibility)


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



Re: [web2py] Re: Reverse table look up in GAE

2010-09-10 Thread b vivek
Sorry for the late reply Martin, but even if I add the datetime field in
here,and order by the datetime field , wont I get the data
in ascending order . However I did what you had suggested , But i still am
able to retrive the data in ascending order rather than descending.
Could there be any other method ..
(A quick recap-- I am trying to get the data ordered in descending order
from the dbase. It can be done by using a tilde , but the GAE seems to
ignore the tilde all together.. Please help)

On Thu, Sep 9, 2010 at 3:46 PM, Martin.Mulone mulone.mar...@gmail.comwrote:

 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.com
 wrote:
 
 
 
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/



Re: [web2py] Re: Reverse table look up in GAE

2010-09-10 Thread b vivek
It would be great if somebody could please let me know how to find the id of
the last inserted row in a table using DAL

On Fri, Sep 10, 2010 at 4:09 PM, b vivek bvivek1...@gmail.com wrote:

 Sorry for the late reply Martin, but even if I add the datetime field in
 here,and order by the datetime field , wont I get the data
 in ascending order . However I did what you had suggested , But i still am
 able to retrive the data in ascending order rather than descending.
 Could there be any other method ..
 (A quick recap-- I am trying to get the data ordered in descending order
 from the dbase. It can be done by using a tilde , but the GAE seems to
 ignore the tilde all together.. Please help)


 On Thu, Sep 9, 2010 at 3:46 PM, Martin.Mulone mulone.mar...@gmail.comwrote:

 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.com
 wrote:
 
 
 
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] Re: cherokee problem with fastcgi and uWSGI

2010-09-10 Thread salbefe
Yes !! It's working now ! Thank you very much :)

Only one question more: because I'm running uWSGI independently from
cherokee, how can I do to start uWSGI at system startup?

Thanks a lot!

On 10 sep, 12:15, Roberto De Ioris robe...@unbit.it wrote:
 Il giorno 10/set/2010, alle ore 12.07, salbefe ha scritto:





  gcc -v

  Usando especificaciones internas.
  Objetivo: i686-redhat-linux
  Configurado con: ../configure --prefix=/usr --mandir=/usr/share/man --
  infodir=/usr/share/info --with-bugurl=http://bugzilla.redhat.com/
  bugzilla --enable-bootstrap --enable-shared --enable-threads=posix --
  enable-checking=release --with-system-zlib --enable-__cxa_atexit --
  disable-libunwind-exceptions --enable-gnu-unique-object --enable-
  languages=c,c++,objc,obj-c++,java,fortran,ada --enable-java-awt=gtk --
  disable-dssi --with-java-home=/usr/lib/jvm/java-1.5.0-gcj-1.5.0.0/jre
  --enable-libgcj-multifile --enable-java-maintainer-mode --with-ecj-
  jar=/usr/share/java/eclipse-ecj.jar --disable-libjava-multilib --with-
  ppl --with-cloog --with-tune=generic --with-arch=i686 --build=i686-
  redhat-linux
  Modelo de hilos: posix
  gcc versión 4.4.4 20100630 (Red Hat 4.4.4-10) (GCC)

 Ok, retry with the latest tip (it was a problem with python3.k compatibility)

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


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

2010-09-10 Thread Roberto De Ioris

 Yes !! It's working now ! Thank you very much :)

 Only one question more: because I'm running uWSGI independently from
 cherokee, how can I do to start uWSGI at system startup?


You can put the commandline in /etc/rc.local or if your system uses
upstart you can use this script:

http://projects.unbit.it/uwsgi/browser/contrib/upstart/uwsgi.conf

you have to customize it for your needs but ALWAYS remember to pass
the --uid and --gid options (otherwise uWSGI will run as root)

--

Roberto De Ioris
http://unbit.it




Re: [web2py] Re: Reverse table look up in GAE

2010-09-10 Thread b vivek
Oh Thanks I got it ... the solution suggested by Martin works perfectly
instead of ordering by record id ,it should be ordered by datetime field and
the tilde works fine!

On Fri, Sep 10, 2010 at 4:23 PM, b vivek bvivek1...@gmail.com wrote:

 It would be great if somebody could please let me know how to find the id
 of the last inserted row in a table using DAL


 On Fri, Sep 10, 2010 at 4:09 PM, b vivek bvivek1...@gmail.com wrote:

 Sorry for the late reply Martin, but even if I add the datetime field in
 here,and order by the datetime field , wont I get the data
 in ascending order . However I did what you had suggested , But i still am
 able to retrive the data in ascending order rather than descending.
 Could there be any other method ..
 (A quick recap-- I am trying to get the data ordered in descending order
 from the dbase. It can be done by using a tilde , but the GAE seems to
 ignore the tilde all together.. Please help)


 On Thu, Sep 9, 2010 at 3:46 PM, Martin.Mulone mulone.mar...@gmail.comwrote:

 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.com
 wrote:
 
 
 
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] Re: Making asynchronous request in web2py

2010-09-10 Thread mdipierro
No. It is executed inside auth

On Sep 10, 12:29 am, Adi aditya.sa...@gmail.com wrote:
 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: Problem with crud.create and duplicate _formname

2010-09-10 Thread mdipierro
No but you can do:

form=crus.create(...,onaccept=lambda form: do_something_with(form))

but perhaps there should be a way to check

On Sep 10, 12:52 am, Álvaro J. Iradier airad...@gmail.com wrote:
 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




[web2py] error on empty submit of retrieve password

2010-09-10 Thread selecta
if the retrieve password form is submitted without a value web2py
crashes
is this intended?

Traceback (most recent call last):
  File /home/fkrause/Dev/web2py/gluon/restricted.py, line 186, in
restricted
exec ccode in environment
  File /home/fkrause/Dev/web2py/applications/pyMantis/controllers/
default.py, line 178, in module
  File /home/fkrause/Dev/web2py/gluon/globals.py, line 96, in
lambda
self._caller = lambda f: f()
  File /home/fkrause/Dev/web2py/applications/pyMantis/controllers/
default.py, line 143, in user
return dict(form=auth())
  File /home/fkrause/Dev/web2py/gluon/tools.py, line 999, in
__call__
return self.retrieve_password()
  File /home/fkrause/Dev/web2py/gluon/tools.py, line 1978, in
retrieve_password
return self.request_reset_password(next,onvalidation,onaccept,log)
  File /home/fkrause/Dev/web2py/gluon/tools.py, line 1952, in
request_reset_password
dict(key=reset_password_key)):
  File /home/fkrause/Dev/web2py/gluon/tools.py, line 312, in send
raise Exception('Target receiver address not specified')
Exception: Target receiver address not specified


[web2py] Re: plugin legacy mysql: generates web2py code to access your mysql legacy db

2010-09-10 Thread selecta
 I turned this into a script in web2py/scripts in trunk. What is the
 license? I assume it is GPL or BSD but it should be stated.
nice
license is GPL3 or above ... actually I just use GPL all the time
because I do not have a lawyer here to tell me the differences between
the licences :)
it should also be mentioned that this was developed for
the BMBF SysMO Project Translucent [contract number 0313982A]


[web2py] Re: plugin legacy mysql: generates web2py code to access your mysql legacy db

2010-09-10 Thread selecta
wow I am impressed with the work you put into that little script that
was just a byproduct for moving my legacy mysqldb to web2py :)
thank you

On Sep 9, 7:01 am, ron_m ron.mco...@gmail.com wrote:
 On Sep 8, 1:30 pm, mdipierro mdipie...@cs.depaul.edu wrote:

   So maybe tonight do you want me to go through the manual and find all
   the missing datatypes and try to add them to the map?

  I would not stop you. ;-)

 Here is a replacement data_type_map, it was shuffled a bit to put like
 types together for easier maintenance. I didn't know what to do with
 the YEAR type so it is commented out. I am not sure the decimal type
 should be mapped to integer since the DAL accepts decimal(n,M) as a
 field type.

 data_type_map = dict(
         varchar = 'string',
         int = 'integer',
         integer = 'integer',
         tinyint = 'integer',
         smallint = 'integer',
         mediumint = 'integer',
         bigint = 'integer',
         float = 'double',
         double = 'double',
         char = 'string',
         decimal = 'integer',
         date = 'date',
         #year = 'date',
         time = 'time',
         timestamp = 'datetime',
         datetime = 'datetime',
         binary = 'blob',
         blob = 'blob',
         tinyblob = 'blob',
         mediumblob = 'blob',
         longblob = 'blob',
         text = 'text',
         tinytext = 'text',
         mediumtext = 'text',
         longtext = 'text',
         )

 I also fixed the remaining problem in the line match re.search so line
 75 or line 87 after above dict is changed

 75c87
                  hit = re.search('(\S+)\s+(\S+)( .*)?', line)
 ---

                  hit = re.search('(\S+)\s+(\S+)(,| )( .*)?', line)

 this fixes the matching on lines like

 `description` longtext,

 The comma immediately after the type got included as part of the type
 string match in error.

 Here is the output for the auth_event table

 legacy_db.define_table('auth_event',
     Field('id','integer'),
     Field('time_stamp','datetime'),
     Field('client_ip','string'),
     Field('user_id','integer'),
     Field('origin','string'),
     Field('description','text'),
     migrate=False)

 The id field should not be printed since it will be added
 automatically.

 The varchar fields have a length in () e.g. varchar(64) which could be
 used to add on a length=N value for the Field constructor. The same
 holds true for int fields but I don't think there is a real use for
 that.

 There is no recognition of foreign keys, fixing this would probably be
 a significant effort. Some human intervention required as it
 stands. ;-)

 It certainly is a great start to getting a model file for an existing
 MySQL database.

 Ron


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

2010-09-10 Thread mdipierro
In trunk now:

from=crud.upadate(...) # or crud.create(...)
if form.accepted: # form accepted
if form.deleted: # record deleted


On Sep 10, 7:44 am, mdipierro mdipie...@cs.depaul.edu wrote:
 No but you can do:

 form=crus.create(...,onaccept=lambda form: do_something_with(form))

 but perhaps there should be a way to check

 On Sep 10, 12:52 am, Álvaro J. Iradier airad...@gmail.com wrote:

  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




[web2py] Re: Expando and Polymodel on GAE?

2010-09-10 Thread mdipierro
I think this is fixed now but needs another test.

On Sep 9, 6:21 pm, Dave thefe...@gmail.com wrote:
 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] AJAX issue with '#' in URL

2010-09-10 Thread geoff
In your controller you could check for the # and strip it?

Alternatively, I believe you can have your onclick return false which
will avoid the #

On Sat, 2010-09-04 at 14:45 -0700, weheh wrote:
 I have a controller that takes an argument, which is the id of a row
 in mytable. If the arg is present, then the row is displayed at the
 top of the page and all the rows are displayed at the bottom of the
 page. Otherwise, the first item in mytable is displayed.
 
 The rows at the bottom of the page have ajax links on them, which if
 clicked, will update only the one selected item at the top of the
 page.
 
 So, http://127.0.0.1:8000/myapp/mycontroller/myfunc would select
 mytable.id==1 by default and
 http://127.0.0.1:8000/myapp/mycontroller/myfunc/21 would select
 mytable.id==21.
 
 In the first case, when I browse the list of rows at the bottom of the
 page, I could click on the entry for mytable.id 5 and the URL that
 would be displayed would be http://127.0.0.1:8000/myapp/mycontroller/myfunc#
 and the selected item at the top of the page is properly updated to be
 mytable.id==5.
 
 However, in the second case, when the url starts at
 http://127.0.0.1:8000/myapp/mycontroller/myfunc/21 and I click on the
 entry for mytable.id 5, I get an internal server error from
 jquery.min.js and the url now looks like 
 http://127.0.0.1:8000/myapp/mycontroller/myfunc/21#.
 
 I don't know how to debug jquery.min.js and I'm not even sure it's the
 culprit. Anyone have any suggestions about how to approach this?
 




[web2py] Re: AJAX issue with '#' in URL

2010-09-10 Thread mdipierro
this

  A(r.x.y,
_href='#',
_id='y-%d-%d'%(z_id,r.x.id),
_onclick=ajax('update_y/%s/%s',['y-%d-%d'],':eval');%\
(z_id,r.x.id,z_id,r.x.id),
),

should be

  A(r.x.y,
_href='#',
_id='y-%d-%d'%(z_id,r.x.id),
_onclick=ajax('update_y/%s/%s',['y-%d-%d'],':eval');
return false;%\
(z_id,r.x.id,z_id,r.x.id),
),

unless on click returns false it still redirects to href='#'

On Sep 4, 9:25 pm, weheh richard_gor...@verizon.net wrote:
         DIV(
           A(r.x.y,
             _href='#',
             _id='y-%d-%d'%(z_id,r.x.id),
             _onclick=ajax('update_y/%s/%s',['y-%d-%d'],':eval');%\
                 (z_id,r.x.id,z_id,r.x.id),
             ),
           _class='y',
           ),

 On Sep 4, 6:51 pm, mdipierro mdipie...@cs.depaul.edu wrote:

  what is the code that generates the url for the ajax callbask?

  On Sep 4, 4:45 pm, weheh richard_gor...@verizon.net wrote:

   I have a controller that takes an argument, which is the id of a row
   in mytable. If the arg is present, then the row is displayed at the
   top of the page and all the rows are displayed at the bottom of the
   page. Otherwise, the first item in mytable is displayed.

   The rows at the bottom of the page have ajax links on them, which if
   clicked, will update only the one selected item at the top of the
   page.

   So,http://127.0.0.1:8000/myapp/mycontroller/myfuncwouldselect
   mytable.id==1 by default 
   andhttp://127.0.0.1:8000/myapp/mycontroller/myfunc/21wouldselect
   mytable.id==21.

   In the first case, when I browse the list of rows at the bottom of the
   page, I could click on the entry for mytable.id 5 and the URL that
   would be displayed would 
   behttp://127.0.0.1:8000/myapp/mycontroller/myfunc#
   and the selected item at the top of the page is properly updated to be
   mytable.id==5.

   However, in the second case, when the url starts 
   athttp://127.0.0.1:8000/myapp/mycontroller/myfunc/21andIclick on the
   entry for mytable.id 5, I get an internal server error from
   jquery.min.js and the url now looks 
   likehttp://127.0.0.1:8000/myapp/mycontroller/myfunc/21#.

   I don't know how to debug jquery.min.js and I'm not even sure it's the
   culprit. Anyone have any suggestions about how to approach this?




[web2py] Re: plugin legacy mysql: generates web2py code to access your mysql legacy db

2010-09-10 Thread mdipierro
If the license is GPL3 I will not include it web2py. Can you make it
GPL2 or BSD?

GPL3 conflicts with GPL2 becuase would not allow the use of the code
as a service and that is what web2py is about.

Massimo

On Sep 10, 8:11 am, selecta gr...@delarue-berlin.de wrote:
  I turned this into a script in web2py/scripts in trunk. What is the
  license? I assume it is GPL or BSD but it should be stated.

 nice
 license is GPL3 or above ... actually I just use GPL all the time
 because I do not have a lawyer here to tell me the differences between
 the licences :)
 it should also be mentioned that this was developed for
 the BMBF SysMO Project Translucent [contract number 0313982A]


[web2py] contains, string:list solution

2010-09-10 Thread Martin.Mulone
I report  a bug with 'contains' in gae in list:string but in trunk is
not fixed. I want to know if this is going to be fixed and when
because is important.

this simple make in gql.py do the job

in gluon/contrib/gql.py
-
def contains(self, value):
if self.type.startswith('list:'):
if isinstance(value, (unicode, str) ):
value = [value]
return Query(self, 'IN', value)
else:
raise RuntimeError, Not supported



PROBLEM TEST:
=
In gae doesn't show any record with keywords 'planet' and 'moon'

You can verified here: http://web2pytesting.appspot.com/ultimatelist/

-
in db.py


db.define_table('tags',
Field('id', 'id'),
Field('name'),format='%(name)s')

db.define_table('testing',
  Field('id', 'id'),
  Field('keywords', 'list:string'),
  Field('numbers', 'list:integer'),
  Field('tags', 'list:reference
tags'),
  migrate=True)

testing = db(db.testing.id0).select()
if not testing:
tag1 = db.tags.insert(name=TAG1)
tag2 = db.tags.insert(name=TAG2)
tag3 = db.tags.insert(name=TAG3)
tag4 = db.tags.insert(name=TAG4)
tag5 = db.tags.insert(name=TAG5)
tag6 = db.tags.insert(name=TAG6)
id1 = db.testing.insert(keywords=['planets', 'moon',
'space'],numbers=[1, 11, 111, 0],tags=[tag1, tag2, tag3])
id2 = db.testing.insert(keywords=['planets', 'mars',
'space'],numbers=[2, 22, 222, 0],tags=[tag1, tag4, tag5])
id2 = db.testing.insert(keywords=['planets', 'mercury',
'space'],numbers=[3, 33, 333, 0],tags=[tag1, tag2, tag6])

-
controller/default.py


def index():
keys_planets =
db(db.testing.keywords.contains('planets')).select()
keys_moon = db(db.testing.keywords.contains('moon')).select()
number_0 = db(db.testing.numbers.contains('0')).select()
number_1 = db(db.testing.numbers.contains('1')).select()
return dict(keys_planets=keys_planets, keys_moon=keys_moon,
number_0=number_0, number_1=number_1)



[web2py] Re: Reverse table look up in GAE

2010-09-10 Thread howesc
please correct me if i am wrong, but ID's on GAE are really UUID's and
are not sequential and not guaranteed to be strictly increasing.
timestamps are the closest you can get to strictly increasing on GAE,
but it is possible for 2 inserts to happen at the same time, so don't
count on that 100% either.

cfh

On Sep 10, 4:42 am, b vivek bvivek1...@gmail.com wrote:
 Oh Thanks I got it ... the solution suggested by Martin works perfectly
 instead of ordering by record id ,it should be ordered by datetime field and
 the tilde works fine!

 On Fri, Sep 10, 2010 at 4:23 PM, b vivek bvivek1...@gmail.com wrote:
  It would be great if somebody could please let me know how to find the id
  of the last inserted row in a table using DAL

  On Fri, Sep 10, 2010 at 4:09 PM, b vivek bvivek1...@gmail.com wrote:

  Sorry for the late reply Martin, but even if I add the datetime field in
  here,and order by the datetime field , wont I get the data
  in ascending order . However I did what you had suggested , But i still am
  able to retrive the data in ascending order rather than descending.
  Could there be any other method ..
  (A quick recap-- I am trying to get the data ordered in descending order
  from the dbase. It can be done by using a tilde , but the GAE seems to
  ignore the tilde all together.. Please help)

  On Thu, Sep 9, 2010 at 3:46 PM, Martin.Mulone 
  mulone.mar...@gmail.comwrote:

  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.com
  wrote:

 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] Re: new features and new book sections/chapters

2010-09-10 Thread carlo
Hi Massimo,

I bought the new edition and you made the usual great job. Just one
thing: I can not find the uploadfolder parameter in the Field specs
while it is present in the online edition..thanks

On 16 Ago, 06:11, mdipierro mdipie...@cs.depaul.edu wrote:
 Or this:

 http://stores.lulu.com/web2py

 On 16 Ago, 06:10, mdipierro mdipie...@cs.depaul.edu wrote:

  There is a problem from lulu. It seems that it does not show the same
  items to different users. For example now I am using somebody else
  computer from Italy and no web2py book is listed at all.

  If you look for the item directly it is there:

 http://www.lulu.com/product/a-copertina-morbida/web2py-%283rd-edition...

  On 6 Ago, 20:29, olifante tiago.henriq...@gmail.com wrote:

   Web2py is getting more impressive by the day, and it's great that the
   documentation is even better now. Unfortunately, the PDF on sale at
   Lulu.com is apparently still the old 2nd edition. Is there any way to
   get or buy a PDF of the current draft of the 3rd edition?

   The tech book industry is increasingly making draft versions of books
   available for comment and for purchase as soon as possible, e.g.

   PragProg Beta 
   Books:http://pragprog.com/frequently-asked-questions/beta-books
   O'Reilly Open Feedback Publishing System:http://labs.oreilly.com/ofps.html
   Manning Early Access Program:http://www.manning.com/about/meap.html

   Why not do the same with the web2py book, instead of forcing eager
   buyers to wait until the final version of the 3rd edition is
   finished?

   Also, many people now prefer to do all their technical reading in
   ebook format, so making the book available in .mobi and .epub formats
   as well as in pdf would be a smart move.

   Finally, even though I personally can see the value of paying $12.50
   for the current version of the web2py book (if it was available, which
   is not the case), many people can't or won't. I really feel that the
   fact that the PDF version of the book isn't available for free hampers
   adoption of web2py. Good as web2py is, the truth is that Django
   dominates in terms of users and mindshare in the Python community. If
   you want to change that, giving the book away couldn't hurt.

   Web2py is obviously a labour of love, and I can't imagine that you get
   more than meager earnings from the PDF sales at Lulu.com. Obviously,
   everybody has to pay the bills, but you can probably earn more from
   consulting work if web2py became more popular than you ever will from
   the PDF sales.

   Thanks for all your hard work on web2py!

   Regards,

   --Tiago Henriques

   PS: you might want to hire a top-notch web designer to turn the web2py
   pages into something a bit trendier and sexier. Your web design skills
   are clearly superior to mine, but sometimes you just gotta hand it to
   the pros.- Nascondi testo citato

  - Mostra testo citato -




[web2py] Re: error on empty submit of retrieve password

2010-09-10 Thread mdipierro
Please check it again with latest version. You see to be running an
old version.
Yet this is not the indetended behaviour and it is possible the bug is
teill there but I could use a more recent traceback.

On Sep 10, 7:55 am, selecta gr...@delarue-berlin.de wrote:
 if the retrieve password form is submitted without a value web2py
 crashes
 is this intended?

 Traceback (most recent call last):
   File /home/fkrause/Dev/web2py/gluon/restricted.py, line 186, in
 restricted
     exec ccode in environment
   File /home/fkrause/Dev/web2py/applications/pyMantis/controllers/
 default.py, line 178, in module
   File /home/fkrause/Dev/web2py/gluon/globals.py, line 96, in
 lambda
     self._caller = lambda f: f()
   File /home/fkrause/Dev/web2py/applications/pyMantis/controllers/
 default.py, line 143, in user
     return dict(form=auth())
   File /home/fkrause/Dev/web2py/gluon/tools.py, line 999, in
 __call__
     return self.retrieve_password()
   File /home/fkrause/Dev/web2py/gluon/tools.py, line 1978, in
 retrieve_password
     return self.request_reset_password(next,onvalidation,onaccept,log)
   File /home/fkrause/Dev/web2py/gluon/tools.py, line 1952, in
 request_reset_password
     dict(key=reset_password_key)):
   File /home/fkrause/Dev/web2py/gluon/tools.py, line 312, in send
     raise Exception('Target receiver address not specified')
 Exception: Target receiver address not specified


[web2py] Re: error on empty submit of retrieve password

2010-09-10 Thread mdipierro
looking at this again there is a validator that should prevent
it.
The problem is that you may have a record with blank email.
I modified the code in trunk to make validation more strict.

On Sep 10, 7:55 am, selecta gr...@delarue-berlin.de wrote:
 if the retrieve password form is submitted without a value web2py
 crashes
 is this intended?

 Traceback (most recent call last):
   File /home/fkrause/Dev/web2py/gluon/restricted.py, line 186, in
 restricted
     exec ccode in environment
   File /home/fkrause/Dev/web2py/applications/pyMantis/controllers/
 default.py, line 178, in module
   File /home/fkrause/Dev/web2py/gluon/globals.py, line 96, in
 lambda
     self._caller = lambda f: f()
   File /home/fkrause/Dev/web2py/applications/pyMantis/controllers/
 default.py, line 143, in user
     return dict(form=auth())
   File /home/fkrause/Dev/web2py/gluon/tools.py, line 999, in
 __call__
     return self.retrieve_password()
   File /home/fkrause/Dev/web2py/gluon/tools.py, line 1978, in
 retrieve_password
     return self.request_reset_password(next,onvalidation,onaccept,log)
   File /home/fkrause/Dev/web2py/gluon/tools.py, line 1952, in
 request_reset_password
     dict(key=reset_password_key)):
   File /home/fkrause/Dev/web2py/gluon/tools.py, line 312, in send
     raise Exception('Target receiver address not specified')
 Exception: Target receiver address not specified


[web2py] Re: contains, string:list solution

2010-09-10 Thread mdipierro
can you help me debug this? Why is the code below wrong?

On Sep 10, 9:40 am, Martin.Mulone mulone.mar...@gmail.com wrote:
 I report  a bug with 'contains' in gae in list:string but in trunk is
 not fixed. I want to know if this is going to be fixed and when
 because is important.

 this simple make in gql.py do the job

 in gluon/contrib/gql.py
 -
     def contains(self, value):
         if self.type.startswith('list:'):
             if isinstance(value, (unicode, str) ):
                 value = [value]
             return Query(self, 'IN', value)
         else:
             raise RuntimeError, Not supported

 PROBLEM TEST:
 =
 In gae doesn't show any record with keywords 'planet' and 'moon'

 You can verified here:http://web2pytesting.appspot.com/ultimatelist/

 -
 in db.py
 

 db.define_table('tags',
                 Field('id', 'id'),
                 Field('name'),format='%(name)s')

 db.define_table('testing',
                   Field('id', 'id'),
                   Field('keywords', 'list:string'),
                   Field('numbers', 'list:integer'),
                   Field('tags', 'list:reference
 tags'),
                   migrate=True)

 testing = db(db.testing.id0).select()
 if not testing:
     tag1 = db.tags.insert(name=TAG1)
     tag2 = db.tags.insert(name=TAG2)
     tag3 = db.tags.insert(name=TAG3)
     tag4 = db.tags.insert(name=TAG4)
     tag5 = db.tags.insert(name=TAG5)
     tag6 = db.tags.insert(name=TAG6)
     id1 = db.testing.insert(keywords=['planets', 'moon',
 'space'],numbers=[1, 11, 111, 0],tags=[tag1, tag2, tag3])
     id2 = db.testing.insert(keywords=['planets', 'mars',
 'space'],numbers=[2, 22, 222, 0],tags=[tag1, tag4, tag5])
     id2 = db.testing.insert(keywords=['planets', 'mercury',
 'space'],numbers=[3, 33, 333, 0],tags=[tag1, tag2, tag6])

 -
 controller/default.py
 

 def index():
     keys_planets =
 db(db.testing.keywords.contains('planets')).select()
     keys_moon = db(db.testing.keywords.contains('moon')).select()
     number_0 = db(db.testing.numbers.contains('0')).select()
     number_1 = db(db.testing.numbers.contains('1')).select()
     return dict(keys_planets=keys_planets, keys_moon=keys_moon,
 number_0=number_0, number_1=number_1)


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

2010-09-10 Thread Miguel Goncalves
thanks I'll give it a try.
Are Tasks Queues part of web2py or is it something specific to GAE?


On Thu, Sep 9, 2010 at 9:41 PM, Richard richar...@gmail.com wrote:

 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: contains, string:list solution

2010-09-10 Thread Martin.Mulone
We were unable to post your message


On Sep 10, 12:14 pm, mdipierro mdipie...@cs.depaul.edu wrote:
 can you help me debug this? Why is the code below wrong?

 On Sep 10, 9:40 am, Martin.Mulone mulone.mar...@gmail.com wrote:



  I report  a bug with 'contains' in gae in list:string but in trunk is
  not fixed. I want to know if this is going to be fixed and when
  because is important.

  this simple make in gql.py do the job

  in gluon/contrib/gql.py
  -
      def contains(self, value):
          if self.type.startswith('list:'):
              if isinstance(value, (unicode, str) ):
                  value = [value]
              return Query(self, 'IN', value)
          else:
              raise RuntimeError, Not supported

  PROBLEM TEST:
  =
  In gae doesn't show any record with keywords 'planet' and 'moon'

  You can verified here:http://web2pytesting.appspot.com/ultimatelist/

  -
  in db.py
  

  db.define_table('tags',
                  Field('id', 'id'),
                  Field('name'),format='%(name)s')

  db.define_table('testing',
                    Field('id', 'id'),
                    Field('keywords', 'list:string'),
                    Field('numbers', 'list:integer'),
                    Field('tags', 'list:reference
  tags'),
                    migrate=True)

  testing = db(db.testing.id0).select()
  if not testing:
      tag1 = db.tags.insert(name=TAG1)
      tag2 = db.tags.insert(name=TAG2)
      tag3 = db.tags.insert(name=TAG3)
      tag4 = db.tags.insert(name=TAG4)
      tag5 = db.tags.insert(name=TAG5)
      tag6 = db.tags.insert(name=TAG6)
      id1 = db.testing.insert(keywords=['planets', 'moon',
  'space'],numbers=[1, 11, 111, 0],tags=[tag1, tag2, tag3])
      id2 = db.testing.insert(keywords=['planets', 'mars',
  'space'],numbers=[2, 22, 222, 0],tags=[tag1, tag4, tag5])
      id2 = db.testing.insert(keywords=['planets', 'mercury',
  'space'],numbers=[3, 33, 333, 0],tags=[tag1, tag2, tag6])

  -
  controller/default.py
  

  def index():
      keys_planets =
  db(db.testing.keywords.contains('planets')).select()
      keys_moon = db(db.testing.keywords.contains('moon')).select()
      number_0 = db(db.testing.numbers.contains('0')).select()
      number_1 = db(db.testing.numbers.contains('1')).select()
      return dict(keys_planets=keys_planets, keys_moon=keys_moon,
  number_0=number_0, number_1=number_1)


[web2py] Re: contains, string:list solution

2010-09-10 Thread Martin.Mulone
I continue here because google dont like my reply

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

On Sep 10, 12:14 pm, mdipierro mdipie...@cs.depaul.edu wrote:
 can you help me debug this? Why is the code below wrong?

 On Sep 10, 9:40 am, Martin.Mulone mulone.mar...@gmail.com wrote:



  I report  a bug with 'contains' in gae in list:string but in trunk is
  not fixed. I want to know if this is going to be fixed and when
  because is important.

  this simple make in gql.py do the job

  in gluon/contrib/gql.py
  -
      def contains(self, value):
          if self.type.startswith('list:'):
              if isinstance(value, (unicode, str) ):
                  value = [value]
              return Query(self, 'IN', value)
          else:
              raise RuntimeError, Not supported

  PROBLEM TEST:
  =
  In gae doesn't show any record with keywords 'planet' and 'moon'

  You can verified here:http://web2pytesting.appspot.com/ultimatelist/

  -
  in db.py
  

  db.define_table('tags',
                  Field('id', 'id'),
                  Field('name'),format='%(name)s')

  db.define_table('testing',
                    Field('id', 'id'),
                    Field('keywords', 'list:string'),
                    Field('numbers', 'list:integer'),
                    Field('tags', 'list:reference
  tags'),
                    migrate=True)

  testing = db(db.testing.id0).select()
  if not testing:
      tag1 = db.tags.insert(name=TAG1)
      tag2 = db.tags.insert(name=TAG2)
      tag3 = db.tags.insert(name=TAG3)
      tag4 = db.tags.insert(name=TAG4)
      tag5 = db.tags.insert(name=TAG5)
      tag6 = db.tags.insert(name=TAG6)
      id1 = db.testing.insert(keywords=['planets', 'moon',
  'space'],numbers=[1, 11, 111, 0],tags=[tag1, tag2, tag3])
      id2 = db.testing.insert(keywords=['planets', 'mars',
  'space'],numbers=[2, 22, 222, 0],tags=[tag1, tag4, tag5])
      id2 = db.testing.insert(keywords=['planets', 'mercury',
  'space'],numbers=[3, 33, 333, 0],tags=[tag1, tag2, tag6])

  -
  controller/default.py
  

  def index():
      keys_planets =
  db(db.testing.keywords.contains('planets')).select()
      keys_moon = db(db.testing.keywords.contains('moon')).select()
      number_0 = db(db.testing.numbers.contains('0')).select()
      number_1 = db(db.testing.numbers.contains('1')).select()
      return dict(keys_planets=keys_planets, keys_moon=keys_moon,
  number_0=number_0, number_1=number_1)


[web2py] Re: contains, string:list solution

2010-09-10 Thread mdipierro
I think it is fixed now.
very strange. I remember having this that already this week. Perhaps a
de ja vu.

Massimo

On Sep 10, 11:32 am, Martin.Mulone mulone.mar...@gmail.com wrote:
 I continue here because google dont like my reply

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

 On Sep 10, 12:14 pm, mdipierro mdipie...@cs.depaul.edu wrote:

  can you help me debug this? Why is the code below wrong?

  On Sep 10, 9:40 am, Martin.Mulone mulone.mar...@gmail.com wrote:

   I report  a bug with 'contains' in gae in list:string but in trunk is
   not fixed. I want to know if this is going to be fixed and when
   because is important.

   this simple make in gql.py do the job

   in gluon/contrib/gql.py
   -
       def contains(self, value):
           if self.type.startswith('list:'):
               if isinstance(value, (unicode, str) ):
                   value = [value]
               return Query(self, 'IN', value)
           else:
               raise RuntimeError, Not supported

   PROBLEM TEST:
   =
   In gae doesn't show any record with keywords 'planet' and 'moon'

   You can verified here:http://web2pytesting.appspot.com/ultimatelist/

   -
   in db.py
   

   db.define_table('tags',
                   Field('id', 'id'),
                   Field('name'),format='%(name)s')

   db.define_table('testing',
                     Field('id', 'id'),
                     Field('keywords', 'list:string'),
                     Field('numbers', 'list:integer'),
                     Field('tags', 'list:reference
   tags'),
                     migrate=True)

   testing = db(db.testing.id0).select()
   if not testing:
       tag1 = db.tags.insert(name=TAG1)
       tag2 = db.tags.insert(name=TAG2)
       tag3 = db.tags.insert(name=TAG3)
       tag4 = db.tags.insert(name=TAG4)
       tag5 = db.tags.insert(name=TAG5)
       tag6 = db.tags.insert(name=TAG6)
       id1 = db.testing.insert(keywords=['planets', 'moon',
   'space'],numbers=[1, 11, 111, 0],tags=[tag1, tag2, tag3])
       id2 = db.testing.insert(keywords=['planets', 'mars',
   'space'],numbers=[2, 22, 222, 0],tags=[tag1, tag4, tag5])
       id2 = db.testing.insert(keywords=['planets', 'mercury',
   'space'],numbers=[3, 33, 333, 0],tags=[tag1, tag2, tag6])

   -
   controller/default.py
   

   def index():
       keys_planets =
   db(db.testing.keywords.contains('planets')).select()
       keys_moon = db(db.testing.keywords.contains('moon')).select()
       number_0 = db(db.testing.numbers.contains('0')).select()
       number_1 = db(db.testing.numbers.contains('1')).select()
       return dict(keys_planets=keys_planets, keys_moon=keys_moon,
   number_0=number_0, number_1=number_1)




[web2py] app-specific routing

2010-09-10 Thread Jonathan Lundell
Massimo has applied (after a false start on my part) the final portion of the 
app-specific routing patch. There are no API changes (unless you're directly 
looking at rewrite.params, in which case ask about the new interface), but the 
new code is thread-safe and should be good to go.

Have a look at the web2py book or at the comments in routes.example.py for 
general information on how to use the feature.

(This is not the next-gen URL-rewrite code, which is still a good intention 
merely. It's just the app-specific version of the existing URL-rewrite logic.)

[web2py] Re: Expando and Polymodel on GAE?

2010-09-10 Thread Dave
Line 128 of gql.py gives a syntax error:

fields=[args['polymodel']]+[field fof field in fields]

I took a guess that this was supposed to give a list of fields from
both the base table and the table being created in, and replaced it
with this instead:

fields = map(lambda x: args['polymodel'][x], args['polymodel'].fields)
+list(fields)

This change allowed the table to be constructed with fields from both
itself and its base class.  Unfortunately, this gives an error when
_create is called on the table (line 137), due to duplicate properties
from the base table.  Here's the trace:

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 80, in module
db.define_table('person',Field('first_name'),
polymodel=db.contact)
  File C:\Users\Dave\Documents\Python\web2py\gluon\contrib\gql.py,
line 137, in define_table
t._create(polymodel=args.get('polymodel',None))
  File C:\Users\Dave\Documents\Python\web2py\gluon\contrib\gql.py,
line 250, in _create
self._tableobj = classobj(self._tablename,
(polymodel._tableobj, ), myfields)
  File C:\Program Files (x86)\Google\google_appengine\google\appengine
\ext\db\polymodel.py, line 125, in __init__
super(PolymorphicClass, cls).__init__(name, bases, dct,
map_kind=False)
  File C:\Program Files (x86)\Google\google_appengine\google\appengine
\ext\db\__init__.py, line 418, in __init__
_initialize_properties(cls, name, bases, dct)
  File C:\Program Files (x86)\Google\google_appengine\google\appengine
\ext\db\__init__.py, line 336, in _initialize_properties
raise DuplicatePropertyError('Duplicate property: %s' % attr_name)
DuplicatePropertyError: Duplicate property: address


[web2py] Re: Expando and Polymodel on GAE?

2010-09-10 Thread mdipierro
OK. we are getting closer... I think I can fix this tonight.

On Sep 10, 12:59 pm, Dave thefe...@gmail.com wrote:
 Line 128 of gql.py gives a syntax error:

 fields=[args['polymodel']]+[field fof field in fields]

 I took a guess that this was supposed to give a list of fields from
 both the base table and the table being created in, and replaced it
 with this instead:

 fields = map(lambda x: args['polymodel'][x], args['polymodel'].fields)
 +list(fields)

 This change allowed the table to be constructed with fields from both
 itself and its base class.  Unfortunately, this gives an error when
 _create is called on the table (line 137), due to duplicate properties
 from the base table.  Here's the trace:

 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 80, in module
     db.define_table('person',Field('first_name'),
 polymodel=db.contact)
   File C:\Users\Dave\Documents\Python\web2py\gluon\contrib\gql.py,
 line 137, in define_table
     t._create(polymodel=args.get('polymodel',None))
   File C:\Users\Dave\Documents\Python\web2py\gluon\contrib\gql.py,
 line 250, in _create
     self._tableobj = classobj(self._tablename,
 (polymodel._tableobj, ), myfields)
   File C:\Program Files (x86)\Google\google_appengine\google\appengine
 \ext\db\polymodel.py, line 125, in __init__
     super(PolymorphicClass, cls).__init__(name, bases, dct,
 map_kind=False)
   File C:\Program Files (x86)\Google\google_appengine\google\appengine
 \ext\db\__init__.py, line 418, in __init__
     _initialize_properties(cls, name, bases, dct)
   File C:\Program Files (x86)\Google\google_appengine\google\appengine
 \ext\db\__init__.py, line 336, in _initialize_properties
     raise DuplicatePropertyError('Duplicate property: %s' % attr_name)
 DuplicatePropertyError: Duplicate property: address


[web2py] permissions

2010-09-10 Thread ron_m
I see from the documentation it is possible to add a permission to
auth_permission with a blank table name. The application I am working
on has a notion of symbolic names for actions that can occur in the
application which in a prior version was assigned to groups (roles)
and then users were assigned to groups. There is no crud associated
with a table.

If I turn off the

table.table_name.requires = IS_IN_SET(self.db.tables)

validator then I can get a form to put in a blank table name. If I
also set the record_id to 0 during the insert then the decorator

@auth.requires_permission('symbolic_name')

works without specifying a table name or record_id because of default
parameters.

If I put in a table name during the insert then the table name must be
supplied on the auth.requires_permission decorator.

The manual has examples like this
@auth.requires_permission('add', 'number')
def add(a, b):
return a + b

where I am reasonably sure 'number' isn't a table.

Question:
Am I using this incorrectly? The reason I want the symbolic names for
capabilities in the application to be realised as permissions is I can
cluster them on a group but reconfigure them for a different situation
to a different mix of groups and then knowing that mapping give the
users membership in the proper group(s) so they have access to the
application functionality intended for them. Then I can use the nice
decorator capability on the controller functions.

Possible solutions
I could just use an existing table or create a dummy table so I can
slip this by the validators while in forms. But then the decorator has
the extra table name parameter which isn't really used for anything.

I could put my own logic in the forms for the permission creation or
stick the initial setup in a script and fly under the validators but
invariably someone will want a form to change things after the
programmer is gone.

I could add my own table for symbolic capabilities with a relation to
auth_group and reproduce the decorator functionality.

Thanks
Ron


[web2py] Re: permissions

2010-09-10 Thread mdipierro
I would just turn off

table.table_name.requires = IS_IN_SET(self.db.tables)

and use a dummy table name for the permission (without creating the
dummy table) and use a table name that cannot create conflict for
example something that include a special symbol like :

On Sep 10, 1:06 pm, ron_m ron.mco...@gmail.com wrote:
 I see from the documentation it is possible to add a permission to
 auth_permission with a blank table name. The application I am working
 on has a notion of symbolic names for actions that can occur in the
 application which in a prior version was assigned to groups (roles)
 and then users were assigned to groups. There is no crud associated
 with a table.

 If I turn off the

     table.table_name.requires = IS_IN_SET(self.db.tables)

 validator then I can get a form to put in a blank table name. If I
 also set the record_id to 0 during the insert then the decorator

 @auth.requires_permission('symbolic_name')

 works without specifying a table name or record_id because of default
 parameters.

 If I put in a table name during the insert then the table name must be
 supplied on the auth.requires_permission decorator.

 The manual has examples like this
 @auth.requires_permission('add', 'number')
 def add(a, b):
     return a + b

 where I am reasonably sure 'number' isn't a table.

 Question:
 Am I using this incorrectly? The reason I want the symbolic names for
 capabilities in the application to be realised as permissions is I can
 cluster them on a group but reconfigure them for a different situation
 to a different mix of groups and then knowing that mapping give the
 users membership in the proper group(s) so they have access to the
 application functionality intended for them. Then I can use the nice
 decorator capability on the controller functions.

 Possible solutions
 I could just use an existing table or create a dummy table so I can
 slip this by the validators while in forms. But then the decorator has
 the extra table name parameter which isn't really used for anything.

 I could put my own logic in the forms for the permission creation or
 stick the initial setup in a script and fly under the validators but
 invariably someone will want a form to change things after the
 programmer is gone.

 I could add my own table for symbolic capabilities with a relation to
 auth_group and reproduce the decorator functionality.

 Thanks
 Ron


[web2py] Re: permissions

2010-09-10 Thread ron_m


Thanks Massimo,

I added the lines

db.auth_permission.table_name.requires =
IS_NULL_OR(IS_IN_SET(db.tables))
db.auth_permission.record_id.default = 0

to the end of my last model file which seems to work for what I need
as well. The table name is allowed to be empty and the record_id
defaults to 0 which will pass a decorator of the form

@auth.requires_permission('symbolic_name') through only for users
given membership in the associated group.


Interesting point about declaring a table name that cannot be created
in the database.

When one starts to get the hang of web2py it is so easy to customise
from the outside avoiding the nightmare of keeping changes to the core
up to date.


[web2py] Re: contains, string:list solution

2010-09-10 Thread Martin.Mulone
thanks, is fixed now

On Sep 10, 1:55 pm, mdipierro mdipie...@cs.depaul.edu wrote:
 I think it is fixed now.
 very strange. I remember having this that already this week. Perhaps a
 de ja vu.

 Massimo

 On Sep 10, 11:32 am, Martin.Mulone mulone.mar...@gmail.com wrote:



  I continue here because google dont like my reply

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

  On Sep 10, 12:14 pm, mdipierro mdipie...@cs.depaul.edu wrote:

   can you help me debug this? Why is the code below wrong?

   On Sep 10, 9:40 am, Martin.Mulone mulone.mar...@gmail.com wrote:

I report  a bug with 'contains' in gae in list:string but in trunk is
not fixed. I want to know if this is going to be fixed and when
because is important.

this simple make in gql.py do the job

in gluon/contrib/gql.py
-
    def contains(self, value):
        if self.type.startswith('list:'):
            if isinstance(value, (unicode, str) ):
                value = [value]
            return Query(self, 'IN', value)
        else:
            raise RuntimeError, Not supported

PROBLEM TEST:
=
In gae doesn't show any record with keywords 'planet' and 'moon'

You can verified here:http://web2pytesting.appspot.com/ultimatelist/

-
in db.py


db.define_table('tags',
                Field('id', 'id'),
                Field('name'),format='%(name)s')

db.define_table('testing',
                  Field('id', 'id'),
                  Field('keywords', 'list:string'),
                  Field('numbers', 'list:integer'),
                  Field('tags', 'list:reference
tags'),
                  migrate=True)

testing = db(db.testing.id0).select()
if not testing:
    tag1 = db.tags.insert(name=TAG1)
    tag2 = db.tags.insert(name=TAG2)
    tag3 = db.tags.insert(name=TAG3)
    tag4 = db.tags.insert(name=TAG4)
    tag5 = db.tags.insert(name=TAG5)
    tag6 = db.tags.insert(name=TAG6)
    id1 = db.testing.insert(keywords=['planets', 'moon',
'space'],numbers=[1, 11, 111, 0],tags=[tag1, tag2, tag3])
    id2 = db.testing.insert(keywords=['planets', 'mars',
'space'],numbers=[2, 22, 222, 0],tags=[tag1, tag4, tag5])
    id2 = db.testing.insert(keywords=['planets', 'mercury',
'space'],numbers=[3, 33, 333, 0],tags=[tag1, tag2, tag6])

-
controller/default.py


def index():
    keys_planets =
db(db.testing.keywords.contains('planets')).select()
    keys_moon = db(db.testing.keywords.contains('moon')).select()
    number_0 = db(db.testing.numbers.contains('0')).select()
    number_1 = db(db.testing.numbers.contains('1')).select()
    return dict(keys_planets=keys_planets, keys_moon=keys_moon,
number_0=number_0, number_1=number_1)


[web2py] re: Expando and Polymodel on GAE?

2010-09-10 Thread Massimo Di Pierro

would you do one more test using this gql.py?



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


This file is part of web2py Web Framework (Copyrighted, 2007)
Developed by Massimo Di Pierro mdipie...@cs.depaul.edu and
Robin B robi...@gmail.com
License: GPL v2


__all__ = ['GQLDB', 'Field']

import re
import sys
import os
import types
import cPickle
import datetime
import thread
import cStringIO
import csv
import copy
import socket
import gluon.validators as validators
import gluon.sqlhtml as sqlhtml
import gluon.sql
from new import classobj
from google.appengine.ext import db as gae
from google.appengine.api.datastore_types import Key
from google.appengine.ext.db.polymodel import PolyModel
MAX_ITEMS = 1000 # GAE main limitation

Row = gluon.sql.Row
Rows = gluon.sql.Rows
Reference = gluon.sql.Reference

SQLCallableList = gluon.sql.SQLCallableList

table_field = re.compile('[\w_]+\.[\w_]+')

SQL_DIALECTS = {'google': {
'boolean': gae.BooleanProperty,
'string': gae.StringProperty,
'text': gae.TextProperty,
'password': gae.StringProperty,
'blob': gae.BlobProperty,
'upload': gae.StringProperty,
'integer': gae.IntegerProperty,
'double': gae.FloatProperty,
'date': gae.DateProperty,
'time': gae.TimeProperty,
'datetime': gae.DateTimeProperty,
'id': None,
'reference': gae.IntegerProperty,
'list:string': (lambda: gae.StringListProperty(default=None)),
'list:integer': (lambda: gae.ListProperty(int,default=None)),
'list:reference': (lambda: gae.ListProperty(int,default=None)),
'lower': None,
'upper': None,
'is null': 'IS NULL',
'is not null': 'IS NOT NULL',
'extract': None,
'left join': None,
}}


def cleanup(text):
if re.compile('[^0-9a-zA-Z_]').findall(text):
raise SyntaxError, \
'only [0-9a-zA-Z_] allowed in table and field names, received %s' \
% text
return text


def assert_filter_fields(*fields):
for field in fields:
if isinstance(field, (Field, Expression)) \
and field.type in ['text', 'blob']:
raise SyntaxError, \
  'AppEngine does not index by: %s' % field.type


def dateobj_to_datetime(obj):

# convert dates, times to datetimes for AppEngine

if isinstance(obj, datetime.datetime):
pass
elif isinstance(obj, datetime.date):
obj = datetime.date(obj.year, obj.month, obj.day)
elif isinstance(obj, datetime.time):
obj = datetime.datetime(
1970, 1, 1, obj.hour, obj.minute, obj.second, obj.microsecond)
return obj


class GQLDB(gluon.sql.SQLDB):


an instance of this class represents a database connection

Example::

   db=GQLDB()
   db.define_table('tablename', Field('fieldname1'),
   Field('fieldname2'))


def __init__(self):
self._uri = 'gae'
self._dbname = 'gql'
self['_lastsql'] = ''
self.tables = SQLCallableList()
self._translator = SQL_DIALECTS['google']
self._db_codec = 'UTF-8'

def define_table(
self,
tablename,
*fields,
**args
):
# these two lines are experimental
if not fields and tablename.count(':'):
(tablename, fields) = autofields(self, tablename)
# if this table extends a polymodel, inherit fields from polymodel
if isinstance(args.get('polymodel',None),Table): 
fields=[args['polymodel']]+[field for field in fields]
tablename = cleanup(tablename)
if tablename in dir(self) or tablename[0] == '_':
raise SyntaxError, 'invalid table name: %s' % tablename
if tablename in self.tables:
raise SyntaxError, 'table already defined: %s'  % tablename
t = self[tablename] = Table(self, tablename, *fields)
self.tables.append(tablename)
t._create_references()
t._create(polymodel=args.get('polymodel',None))
t._format = args.get('format', None)
return t

def __call__(self, where=''):
if not where:
where = ''
return Set(self, where)

def commit(self):
pass

def rollback(self):
pass

class SQLALL(object):

def __init__(self, table):
self.table = table


class Table(gluon.sql.Table):


an instance of this class represents a database table
Example:

db=GQLDB()
db.define_table('users', Field('name'))
db.users.insert(name='me') # print db.users._insert(...) to see SQL
db.users.drop()


def __init__(
self,
db,
tablename,
*fields
):
new_fields = [ Field('id', 'id') ]
for field in fields:
if hasattr(field,'_db'):
field = copy.copy(field)
if isinstance(field, gluon.sql.Field):
d=field.__dict__
field=Field('tmp')
field.__dict__.update(d)

[web2py] Re: app-specific routing

2010-09-10 Thread _po
Hi,

I am having trouble with this patch. (rev d38a7099445b)
The recently modified /gluon/streamer.py seems to prevent web2py from
starting :

$ hg up d38a7099445b
4 files updated, 0 files merged, 0 files removed, 0 files unresolved

$ python web2py.py
Traceback (most recent call last):
  File web2py.py, line 17, in module
import gluon.widget
  File /media/DONNEES/Mes documents/Documents/Prog/web2py/gluon/
widget.py, line 28, in module
import main
  File /media/DONNEES/Mes documents/Documents/Prog/web2py/gluon/
main.py, line 48, in module
from globals import Request, Response, Session
  File /media/DONNEES/Mes documents/Documents/Prog/web2py/gluon/
globals.py, line 19, in module
from streamer import streamer, stream_file_or_304_or_206,
DEFAULT_CHUNK_SIZE
  File /media/DONNEES/Mes documents/Documents/Prog/web2py/gluon/
streamer.py, line 46, in module
error_message = main.thread.routes.error_message % 'invalid
request',
AttributeError: 'thread._local' object has no attribute 'routes'




On 10 sep, 19:10, Jonathan Lundell jlund...@pobox.com wrote:
 Massimo has applied (after a false start on my part) the final portion of the 
 app-specific routing patch. There are no API changes (unless you're directly 
 looking at rewrite.params, in which case ask about the new interface), but 
 the new code is thread-safe and should be good to go.

 Have a look at the web2py book or at the comments in routes.example.py for 
 general information on how to use the feature.

 (This is not the next-gen URL-rewrite code, which is still a good intention 
 merely. It's just the app-specific version of the existing URL-rewrite logic.)


Re: [web2py] Re: app-specific routing

2010-09-10 Thread Jonathan Lundell
On Sep 10, 2010, at 1:20 PM, _po wrote:
 
 Hi,
 
 I am having trouble with this patch. (rev d38a7099445b)
 The recently modified /gluon/streamer.py seems to prevent web2py from
 starting :

Thanks; I'll have a look.

 
 $ hg up d38a7099445b
 4 files updated, 0 files merged, 0 files removed, 0 files unresolved
 
 $ python web2py.py
 Traceback (most recent call last):
  File web2py.py, line 17, in module
import gluon.widget
  File /media/DONNEES/Mes documents/Documents/Prog/web2py/gluon/
 widget.py, line 28, in module
import main
  File /media/DONNEES/Mes documents/Documents/Prog/web2py/gluon/
 main.py, line 48, in module
from globals import Request, Response, Session
  File /media/DONNEES/Mes documents/Documents/Prog/web2py/gluon/
 globals.py, line 19, in module
from streamer import streamer, stream_file_or_304_or_206,
 DEFAULT_CHUNK_SIZE
  File /media/DONNEES/Mes documents/Documents/Prog/web2py/gluon/
 streamer.py, line 46, in module
error_message = main.thread.routes.error_message % 'invalid
 request',
 AttributeError: 'thread._local' object has no attribute 'routes'
 
 
 
 
 On 10 sep, 19:10, Jonathan Lundell jlund...@pobox.com wrote:
 Massimo has applied (after a false start on my part) the final portion of 
 the app-specific routing patch. There are no API changes (unless you're 
 directly looking at rewrite.params, in which case ask about the new 
 interface), but the new code is thread-safe and should be good to go.
 
 Have a look at the web2py book or at the comments in routes.example.py for 
 general information on how to use the feature.
 
 (This is not the next-gen URL-rewrite code, which is still a good intention 
 merely. It's just the app-specific version of the existing URL-rewrite 
 logic.)




[web2py] Re: Expando and Polymodel on GAE?

2010-09-10 Thread Dave
It still has both the original problems.  Here's what I'm testing so
far:

contacts = db(db.contact.id0).select()

Returns all contacts, as it should

people = db(db.person.id0).select()

Also returns all contacts, instead of just the contacts that are of
type person

address = people[0].address

Works, and returns the address of the first person.

name = people[0].first_name

Crashes, with the following trace:

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/
controllers/default.py:index, line 66, in module
  File C:\Users\Dave\Documents\Python\web2py\gluon\globals.py, line
96, in lambda
self._caller = lambda f: f()
  File C:\Users\Dave\Documents\Python\web2py\applications\welcome/
controllers/default.py:index, line 23, in index
  File C:\Users\Dave\Documents\Python\web2py\gluon\sql.py, line 729,
in __getattr__
return dict.__getitem__(self,key)
KeyError: 'first_name'


[web2py] fast lookups on secondary unique key? also, error in book and code check

2010-09-10 Thread geoff
http://web2py.com/book/default/chapter/06#Indexes

The example appears to be missing a quote.
Adding the missing single-quote I am still getting a syntax
error:

Error traceback

  File /web2py/web2py/gluon/restricted.py, line 186, in
restricted
exec ccode in environment
  File /web2py/web2py/applications/ewc/models/db.py, line 108,
in module
db.executesql('CREATE INDEX IF NOT EXISTS idx_filemaker_id
ON recipe filemaker_id;')
  File /web2py/web2py/gluon/sql.py, line 1428, in executesql
self._execute(query)
  File /web2py/web2py/gluon/sql.py, line 947, in lambda
self._execute = lambda *a, **b: self._cursor.execute(*a,
**b)
OperationalError: near filemaker_id: syntax error


it  is for the line: 
db.executesql('CREATE INDEX IF NOT EXISTS idx_filemaker_id ON
recipe
filemaker_id;')

I have a db.recipe.filemaker_id of type 'integer'


Generally, I am importing some information from a few different
sources
into what will be a unified database.  Because of this, there
are
multiple keys to manage.

I have a db.recipes table which contains a field, filemaker_id.

I am importing into db.nutrition_information from a large csv
file, which has as its key a column that
maps to db.recipe.filemaker_id

I am linking db.nutrition_information to db.recipe via
db.nutrition_information.external_key

(things other than recipes will be linked to
db.nutrition_information)

The problem is, for entry into db.nutrition_information, I have
to look up db.recipe.id via db.recipe.filemaker_id

This is why I want to create an index on db.recipe.filemaker_id
as the import process is very slow right now.  Although I will
only have to do it once, it is nice to do as many test imports
as possible.

I think the code I am using may be inefficient, I hope someone
will take a look at it:

recipes = db(db.recipe.filemaker_id==rows[0]).select()
external_key = recipes[0].id #filemaker_id is unique





Re: [web2py] Re: app-specific routing

2010-09-10 Thread Jonathan Lundell
On Sep 10, 2010, at 1:20 PM, _po wrote:
 
 Hi,
 
 I am having trouble with this patch. (rev d38a7099445b)
 The recently modified /gluon/streamer.py seems to prevent web2py from
 starting :

I found this problem (and another one), and will send Massimo a patch shortly.

 
 $ hg up d38a7099445b
 4 files updated, 0 files merged, 0 files removed, 0 files unresolved
 
 $ python web2py.py
 Traceback (most recent call last):
  File web2py.py, line 17, in module
import gluon.widget
  File /media/DONNEES/Mes documents/Documents/Prog/web2py/gluon/
 widget.py, line 28, in module
import main
  File /media/DONNEES/Mes documents/Documents/Prog/web2py/gluon/
 main.py, line 48, in module
from globals import Request, Response, Session
  File /media/DONNEES/Mes documents/Documents/Prog/web2py/gluon/
 globals.py, line 19, in module
from streamer import streamer, stream_file_or_304_or_206,
 DEFAULT_CHUNK_SIZE
  File /media/DONNEES/Mes documents/Documents/Prog/web2py/gluon/
 streamer.py, line 46, in module
error_message = main.thread.routes.error_message % 'invalid
 request',
 AttributeError: 'thread._local' object has no attribute 'routes'
 
 
 
 
 On 10 sep, 19:10, Jonathan Lundell jlund...@pobox.com wrote:
 Massimo has applied (after a false start on my part) the final portion of 
 the app-specific routing patch. There are no API changes (unless you're 
 directly looking at rewrite.params, in which case ask about the new 
 interface), but the new code is thread-safe and should be good to go.
 
 Have a look at the web2py book or at the comments in routes.example.py for 
 general information on how to use the feature.
 
 (This is not the next-gen URL-rewrite code, which is still a good intention 
 merely. It's just the app-specific version of the existing URL-rewrite 
 logic.)




[web2py] Re: plugin legacy mysql: generates web2py code to access your mysql legacy db

2010-09-10 Thread selecta
then GPL2 is fine with me

On Sep 10, 4:19 pm, mdipierro mdipie...@cs.depaul.edu wrote:
 If the license is GPL3 I will not include it web2py. Can you make it
 GPL2 or BSD?

 GPL3 conflicts with GPL2 becuase would not allow the use of the code
 as a service and that is what web2py is about.

 Massimo

 On Sep 10, 8:11 am, selecta gr...@delarue-berlin.de wrote:



   I turned this into a script in web2py/scripts in trunk. What is the
   license? I assume it is GPL or BSD but it should be stated.

  nice
  license is GPL3 or above ... actually I just use GPL all the time
  because I do not have a lawyer here to tell me the differences between
  the licences :)
  it should also be mentioned that this was developed for
  the BMBF SysMO Project Translucent [contract number 0313982A]


Re: [web2py] Re: Scaffolding app with Twitter OAuth1.0a auth

2010-09-10 Thread Jonathan Lundell
Folks playing with Twitter OAuth might care to read this: 
http://arstechnica.com/security/guides/2010/09/twitter-a-case-study-on-how-to-do-oauth-wrong.ars/



[web2py] Re: permissions

2010-09-10 Thread ron_m
On Sep 10, 11:31 am, ron_m ron.mco...@gmail.com wrote:
 Thanks Massimo,

 I added the lines

 db.auth_permission.table_name.requires =
 IS_NULL_OR(IS_IN_SET(db.tables))
 db.auth_permission.record_id.default = 0


It is much better to follow what Massimo was saying earlier in this
thread after working a bit with my alternative. It turns out many of
the symbolic names for permissions in my application were things like
'ManageUsers' so that can be split into 'Manage' and 'Users:' which
are placed in fields name and table_name for the action, object pair
that permissions is intended to represent. Using the IS_NULL_OR() put
a None into the table_name column table which is not the same as the
default parameter value of '' or empty string in the
requires_permission decorator resulting in the permission check
failing. It initially worked for me because I didn't re-enter the
values into the database so I had '' in the column but when I did an
update as part of testing it converted to None which won't work.

To disable the IS_IN_SET(db.tables) validator from the define_tables
function in the Auth class just place this line somewhere in your
model instead of editing tools.py.

db.auth_permission.table_name.requires = None

I also kept this line so I didn't have to think about record ids on
non-existent tables.

db.auth_permission.record_id.default = 0

Ron



[web2py] rise HTML !--xxxxxx

2010-09-10 Thread Sebastian E. Ovide
Hi All,

in the line class HTTP (
http://www.google.com/codesearch/p?hl=en#uyCl3L51_dI/gluon/http.pyq=http%20package:http://web2py%5C.googlecode%5C.coml=85)
 there is a code that adds xxx to the error page.

I'm using some JS library that would pop up the error page message in case
of an Ajax call returns an error page ... therefore it displays the message
that I rise in the controller plus those 

Is it possible to disable those xx ?

thanks

-- 
Sebastian E. Ovide


[web2py] Re: rise HTML !--xxxxxx

2010-09-10 Thread mdipierro
those x are very important! IE does not display the content of
error pages unless the content is more than 512 bytes. Without the
x (or some other junk) IE would override the web2py error
messages.

Massimo

On Sep 10, 8:25 pm, Sebastian E. Ovide sebastian.ov...@gmail.com
wrote:
 Hi All,

 in the line class HTTP 
 (http://www.google.com/codesearch/p?hl=en#uyCl3L51_dI/gluon/http.pyq=...)
  there is a code that adds xxx to the error page.

 I'm using some JS library that would pop up the error page message in case
 of an Ajax call returns an error page ... therefore it displays the message
 that I rise in the controller plus those 

 Is it possible to disable those xx ?

 thanks

 --
 Sebastian E. Ovide


[web2py] help stress test trunk

2010-09-10 Thread mdipierro
Jonathan has rewritten a lot of code about routes.
I have rewritten a sql mechanism to deal with concurrent open
databases.

Because of these major rewrites, we really need to stress test trunk.
Both rewrites contribute to make code cleaner, leaner and eliminate
rare but possible threading issues.

Massimo


[web2py] Simple search form

2010-09-10 Thread elfuego1
Hello,

I need to create a search form.
In my DB I have fields with numbers. Now I need to look up the DB and
find out if the numbers I enter are there already or not.

db.define_table('numbers',
Field('no_1', length=18),
Field('no_2', length=18),
Field('no_3', length=18),
Field('no_4', length=18),
Field('date', 'date',default=now)

I'd like to get two kinds of information from the DB.
1. If there is a matching record in DB:
I'd like to display all fields with matching numbers and a date
when that happend (last field in DB contains a date).
2. If there is NO MATCH:
I'd like to get answer: „No matching record found”.

Can you tell me what should I do to generate a search form with four
input fields and run their contetns against my DB?

Best regards.