[web2py] How do you document your apps?

2011-06-15 Thread Marcel Luethi
Hello!

I just finished an internal project using web2py (1.95.1) and have to
document it for my colleagues.
Preferably it is a system based of doc strings. Maybe Sphinx?

Question:
What are you using?
Do you have any suggestions?

Thanks in advance for your input!

Best regards,
Marcel



[web2py] Re: More Details on RESTful web2py?

2011-06-15 Thread Web2py Newbie
As a follow up:

I want to use something like:
/myapp/api/show_comment/id
to show comment at id
and
/myapp/api/show_comment/
To show all comments

However, when I try this it complains (invalid arguments).  I try to
test id against None, but id is apparently a server object.
Any ideas or do I just have to define all_comments?




[web2py] Re: Broken pipe with mysql

2011-06-15 Thread Álvaro J . Iradier
I agree there's not way to notify web2py that the connection is lost,
but isn't it possible to detect that the connection broke after the
error is raised, and try to reconnect?

Thanks.

On 15 jun, 03:25, Massimo Di Pierro massimo.dipie...@gmail.com
wrote:
 This presents logical problems. It just should not happen. Edit the
 mysql config file and change the timeout. If the database is
 restarted, web2py needs restarting because there is no mechanism in
 the database connection API to notify web2py (or python) that a
 connection lost.

 On Jun 14, 4:06 pm, Álvaro J. Iradier airad...@gmail.com wrote:







  As seen in this thread:

 http://groups.google.com/group/web2py/browse_thread/thread/c6653dadbe...

  I'm getting broken pipe messages when mysql is restarted, and under
  other circunstances.

  Going to a shell, I tried doing a query, for example:

   db(db.location).select()

  gluon.dal.Rows object at 0xa2056ec

  everything goes ok. Then I restart Mysql, and running the same query I
  get:

   db(db.location).select()

  Traceback (most recent call last):
    File console, line 1, in module
    File /var/www/web2py_klnetcenter/gluon/dal.py, line 5382, in
  select
      return self.db._adapter.select(self.query,fields,attributes)
    File /var/www/web2py_klnetcenter/gluon/dal.py, line 1159, in
  select
      rows = response(sql)
    File /var/www/web2py_klnetcenter/gluon/dal.py, line 1149, in
  response
      self.execute(sql)
    File /var/www/web2py_klnetcenter/gluon/dal.py, line 1234, in
  execute
      return self.log_execute(*a, **b)
    File /var/www/web2py_klnetcenter/gluon/dal.py, line 1229, in
  log_execute
      ret = self.cursor.execute(*a,**b)
    File /var/www/web2py_klnetcenter/gluon/contrib/pymysql/cursors.py,
  line 108, in execute
      self.errorhandler(self, exc, value)
    File /var/www/web2py_klnetcenter/gluon/contrib/pymysql/
  connections.py, line 184, in defaulterrorhandler
      raise errorclass, errorvalue
  OperationalError: (2013, 'Lost connection to MySQL server during
  query')

  trying to run it again, I only get:

   db(db.location).select()

  Traceback (most recent call last):
    File console, line 1, in module
    File /var/www/web2py_klnetcenter/gluon/dal.py, line 5382, in
  select
      return self.db._adapter.select(self.query,fields,attributes)
    File /var/www/web2py_klnetcenter/gluon/dal.py, line 1159, in
  select
      rows = response(sql)
    File /var/www/web2py_klnetcenter/gluon/dal.py, line 1149, in
  response
      self.execute(sql)
    File /var/www/web2py_klnetcenter/gluon/dal.py, line 1234, in
  execute
      return self.log_execute(*a, **b)
    File /var/www/web2py_klnetcenter/gluon/dal.py, line 1229, in
  log_execute
      ret = self.cursor.execute(*a,**b)
    File /var/www/web2py_klnetcenter/gluon/contrib/pymysql/cursors.py,
  line 108, in execute
      self.errorhandler(self, exc, value)
    File /var/www/web2py_klnetcenter/gluon/contrib/pymysql/
  connections.py, line 182, in defaulterrorhandler
      raise Error(errorclass, errorvalue)
  Error: (class 'socket.error', error(32, 'Broken pipe'))

  forever!. However, if I do:

   db._adapter.connection.ping()
  True
   db(db.location).select()

  gluon.dal.Rows object at 0xa20596c

  so it looks like pinging does a reconnect.

  If the connection is closed manually, it won't reconnect either:

   db(db.location).select()

  gluon.dal.Rows object at 0xa205a0c db._adapter.connection.close()
   print db(db.location).select()

  Traceback (most recent call last):
    File console, line 1, in module
    File /var/www/web2py_klnetcenter/gluon/dal.py, line 5382, in
  select
      return self.db._adapter.select(self.query,fields,attributes)
    File /var/www/web2py_klnetcenter/gluon/dal.py, line 1159, in
  select
      rows = response(sql)
    File /var/www/web2py_klnetcenter/gluon/dal.py, line 1149, in
  response
      self.execute(sql)
    File /var/www/web2py_klnetcenter/gluon/dal.py, line 1234, in
  execute
      return self.log_execute(*a, **b)
    File /var/www/web2py_klnetcenter/gluon/dal.py, line 1229, in
  log_execute
      ret = self.cursor.execute(*a,**b)
    File /var/www/web2py_klnetcenter/gluon/contrib/pymysql/cursors.py,
  line 108, in execute
      self.errorhandler(self, exc, value)
    File /var/www/web2py_klnetcenter/gluon/contrib/pymysql/
  connections.py, line 184, in defaulterrorhandler
      raise errorclass, errorvalue
  InterfaceError: (0, '')

  forever again!

  Is this the expected behavior? Is web2py or the adapter not detecting
  it is not connected and not trying to reconnect unless you ping the
  connection?

  I think this needs fixing. I have a long running shell process, and
  every night I find it stopped working and broken pipe errors are all
  around... I'm trying to workaround it pinging the connection, but I
  think that's not a good fix...

  Greets.


[web2py] Re: More Details on RESTful web2py?

2011-06-15 Thread Web2py Newbie
H it seems to have just dropped my supplementary question.
Apologies if this arrives twice.

I want to do something like:
/myapp/api/get_comment/id
to return the comment at id
and
/myapp/api/get_comment/
to return a list of all comments

However, it complains when I try this (invalid argument).  I try to
test id against None, but it's a server object so isn't None.
Is this doable or do I give up and define get_all_comments?


[web2py] Python executable mismatch in ticket

2011-06-15 Thread Floyd
Hi,
I'm using web2py on a server with two different python interpreter (v. 2.6 
and v. 2.7). I'm using Apache 2.2 and mod_wsgi 3.3 built for Python 2.7. 
Everything work fine but when I get a ticket the python executable path is 
wrong. It's the Apache executable path, not the Python intepreter path. This 
is peculiar to mod_wsgi, as explained in 
http://serverfault.com/questions/108067/how-do-i-find-the-python-executable-that-my-server-is-using.
 
In the code RestrictedError.py is used sys.executable, but it should be 
sys.prefix when using mod_wsgi.

Maybe it could be useful to add this information the ticket page. 

Bye,
Floyd




[web2py] Re: dynamic link and image as represent in db Field

2011-06-15 Thread frasse
oh sorry
url is just img url like that url = URL('static/images','join.jpeg')

On Jun 15, 1:02 am, pbreit pbreitenb...@gmail.com wrote:
 I think that should be possible. Where is url coming from?

 I would definitely advise against doing this, tho. Just put that in your
 view.


[web2py] Re: Chunked downloads and corrupt files with Internet Explorer 8 (IE8)

2011-06-15 Thread Stefan Scholl
Is nobody else experiencing this problem? Is nobody using Internet
Explorer to download more than 64KiB from a web2py app?


On 6 Mai, 13:03, Stefan Scholl stefan.sch...@gmail.com wrote:
 The classicdownloadfunction:

 defdownload():
     return response.download(request, db)

 I'm developing on localhost (127.0.0.1, no SSL) and one strange thing
 happened: Downloads in IE8 (Windows XP) were all corrupt/broken if
 they weren't below 64KiB in size. Very easy to see with large images.

 Using a higher value for the argument 'chunk_size' solves this
 problem, up to this new maximum.

 web2py 1.91.6


[web2py] Speed of rendering html data (10,000+ rows)

2011-06-15 Thread Vineet
Dear All,
I wish to share some of my findings (may be useful to someone).
And one question (at the bottom of this post).

Task: Displaying a report with a large amount of data returned from
controller.

A resultset is fetched from MySQL
custdata = db.executesql(qry, as_dict=True)
There are 10,000+  records in it.
--
Earlier, I was parsing 'custdata' using 'for' loop---
--
for i in custdata:
   mystr2 = ''.join([mystr2, 'trtd' , str(i[0]) , '/td'])
   mystr2 = ''.join([mystr2, 'td' , str(i[1]) , '/td'])
   mystr2 = ''.join([mystr2, 'td' , str(i[2]) , '/td'])
..more omitted..
   mystr2 = ''.join([mystr2, 'td' , str(i[12]) , '/td/tr'])

mystr3 = '/tbody/table'
mystr = ''.join([mystr1, mystr2, mystr3])
--
It took 175 seconds to process the data.
1) Using 'for' loop is slowing down the processing.
2) Evaluating ''.join everytime in 'for' loop was costly.
--
Now, I parsed 'custdata' like ---
--
1) Used list comprehension instead of 'for' loop
2) Used jn=''.join (i.e. local variable instead of global variable)

jn = ''.join
lst = [ jn(['trtd' , str(i[0]) , '/td',
   'td' , str(i[1]) , '/td',
   'td' , str(i[2]) , '/td',
.. more omitted..]) for i in res]

mystr=jn(lst)
--
The performance boost is amazing..
It took ONLY 0.078 seconds
--
My Question is this---
--
If I send the big string output (which contains html code) to a View
from a Controller like this---
return dict(mystr=mystr)

and render it like this---
{{=XML(mystr)}}

it takes again 1 minute to display the plain html data.
(not to speak of using dataTables; it haults the task).

For testing purpose, I saved the output string in .html file like
this---
flnm=open('myfile.html', 'w')
flnm.writelines(mystr)
When I loaded the .html file in browser (outside of web2py), it loads
within 5 seconds.

In Web2Py, how do I render it quickly in View?

Thanks,
Vineet


[web2py] Re: Import from another application in 1.96.x

2011-06-15 Thread Ross Peoples
When talking across applications like that, you might be better off putting 
your core functionality in its own app, then having all of your other apps 
make XML-RPC or JSON-RPC calls to it. This gives you a good level separation 
and means that you can break up your apps and run each of them on a 
different server if you want (multi-tier). I have had to do this in the past 
and I chose JSON-RPC. It work very well and even passes exceptions across 
the wire in the form of a dict. The only thing to keep in mind is that it 
can only handle numbers, strings, and booleans. While this may be a turn off 
at first, especially if you want to use dates, it's actually pretty trivial 
to have those dates be converted to epoch numbers or full date time strings 
and back.

Re: [web2py] prettyPhoto with web2py

2011-06-15 Thread Sahil Arora
or if there are similar plugins in web2py, please do tell

On Wed, Jun 15, 2011 at 5:04 PM, Sahil Arora sahilarora...@gmail.comwrote:

 Has anyone tried using prettyPhoto (
 http://www.no-margin-for-errors.com/projects/prettyphoto-jquery-lightbox-clone/)
 with web2py. I was trying for single photo(as in demo), but facing problems.




-- 
Sahil Arora
B.Tech 2nd year
Computer Science and Engineering
IIT Delhi
Contact No: +91 9871491046
www.cse.iitd.ac.in/~cs1090213 http://www.cse.iitd.ac.in/%7Ecs1090213


[web2py] prettyPhoto with web2py

2011-06-15 Thread Sahil Arora
Has anyone tried using prettyPhoto 
(http://www.no-margin-for-errors.com/projects/prettyphoto-jquery-lightbox-clone/)
 
with web2py. I was trying for single photo(as in demo), but facing problems.


Re: [web2py] prettyPhoto with web2py

2011-06-15 Thread Sahil Arora
I got the problem solved but don't know why this happened. The images whose
link i was giving were in uploads folder. when i changed their path to a new
folder in static which has only root permissions, everything got worked

On Wed, Jun 15, 2011 at 5:20 PM, Sahil Arora sahilarora...@gmail.comwrote:

 or if there are similar plugins in web2py, please do tell


 On Wed, Jun 15, 2011 at 5:04 PM, Sahil Arora sahilarora...@gmail.comwrote:

 Has anyone tried using prettyPhoto (
 http://www.no-margin-for-errors.com/projects/prettyphoto-jquery-lightbox-clone/)
 with web2py. I was trying for single photo(as in demo), but facing problems.




 --
 Sahil Arora
 B.Tech 2nd year
 Computer Science and Engineering
 IIT Delhi
 Contact No: +91 9871491046
 www.cse.iitd.ac.in/~cs1090213 http://www.cse.iitd.ac.in/%7Ecs1090213




-- 
Sahil Arora
B.Tech 2nd year
Computer Science and Engineering
IIT Delhi
Contact No: +91 9871491046
www.cse.iitd.ac.in/~cs1090213 http://www.cse.iitd.ac.in/%7Ecs1090213


[web2py] Re: Web2py Single Sign On Free with another application

2011-06-15 Thread Neveen Adel
Thanks Massimo for your reply.

I think it use HTTP protocol .

On Jun 14, 5:49 pm, Massimo Di Pierro massimo.dipie...@gmail.com
wrote:
 yes but ow depends on what single sign on protocol is supported by the
 Java app.

 On Jun 14, 8:46 am, Neveen Adel nevo.a...@gmail.com wrote:

  Hello,

   I have a web2py application and another java application (using
  Tomcat).
  and there is links inside tomcat application that call java
  application.

  How can i use Single Sign  to make the link of the java application
  not open if the user not logged in?

  Thanks in Advance


[web2py] Re: Import from another application in 1.96.x

2011-06-15 Thread Jim Karsten
I understand what your saying and I do use that approach at times but I 
don't think it is ideal for what I'm looking at. Maybe I should explain 
further. 

While developing an application I might create a module in the applications 
modules directory. Then working on another application I see a need for that 
module from the first app. I could copy the module to the second 
application's module directory but that would create duplicate code. Instead 
I created an application called 'shared' used solely for it's modules 
directory. It acts as a library of these utility modules. All applications 
import from the shared modules as needed. It's working but feels a bit of a 
hack. With the changes to the import in 1.96.x, I thought there might be a 
better approach. 

I wonder if I should be using the site-packages directory instead of a 
shared app. 

[web2py] Re: prettyPhoto with web2py

2011-06-15 Thread blackthorne
I am using in on www.casasdocastro.com.
Check out http://www.casasdocastro.com/init/default/houses/sbento#img_gallery

On Jun 15, 1:31 pm, Sahil Arora sahilarora...@gmail.com wrote:
 I got the problem solved but don't know why this happened. The images whose
 link i was giving were in uploads folder. when i changed their path to a new
 folder in static which has only root permissions, everything got worked

 On Wed, Jun 15, 2011 at 5:20 PM, Sahil Arora sahilarora...@gmail.comwrote:





  or if there are similar plugins in web2py, please do tell

  On Wed, Jun 15, 2011 at 5:04 PM, Sahil Arora sahilarora...@gmail.comwrote:

  Has anyone tried using prettyPhoto (
 http://www.no-margin-for-errors.com/projects/prettyphoto-jquery-light...)
  with web2py. I was trying for single photo(as in demo), but facing 
  problems.

  --
  Sahil Arora
  B.Tech 2nd year
  Computer Science and Engineering
  IIT Delhi
  Contact No: +91 9871491046
 www.cse.iitd.ac.in/~cs1090213http://www.cse.iitd.ac.in/%7Ecs1090213

 --
 Sahil Arora
 B.Tech 2nd year
 Computer Science and Engineering
 IIT Delhi
 Contact No: +91 
 9871491046www.cse.iitd.ac.in/~cs1090213http://www.cse.iitd.ac.in/%7Ecs1090213


Re: [web2py] Re: Discussion: Thoughts about including jQuery UI in core web2py?

2011-06-15 Thread cjrh
Love this idea.

[web2py] MNPP (Mac + Nginx + Percona + PHP or Python) includes web2py

2011-06-15 Thread Anthony
http://getmnpp.org/
http://blog.getmnpp.org/mnpp-010-released
 
The two Python frameworks included in MNPP are Django and web2py. :-)


[web2py] Re: Speed of rendering html data (10,000+ rows)

2011-06-15 Thread cjrh
Raymond Hettinger recently tweeted that .join() was O(n) but concats are 
O(n^2), or some other super-linear factor like that, so your speedup makes 
perfect sense.   I think you've discovered a performance bottleneck in the 
rendering system of web2py.  Shouldn't be too hard to find with a profiler. 
 I wish I had time to play with this, but I don't.   But I am very 
interested in this issue, which is why I am replying (so I can tick Email 
updates to me :)

[web2py] import error

2011-06-15 Thread mb_...@yahoo.fr
I wanted to use the w2popenid example application from bitbucket
website : https://bitbucket.org/bottiger/web2py-openid/overview
 I have downloaded and placed the code in the applications directory.
I have changed in the models folder the file db.py: this line from
applications.cas.modules.w2popenid import OpenIDLogin is replaced
with this one from w2popenid import OpenIDLogin or this from
applications.w2popenid.modules.import OpenIDLogin. But it don't
worked. I get to follow this trace
Traceback (most recent call last):
  File /home/mamadou/Desktop/web2py/gluon/restricted.py, line 192,
in restricted
exec ccode in environment
  File /home/mamadou/Desktop/web2py/applications/w2popenid/models/
db.py, line 42, in module
from testing import lala
  File /home/mamadou/Desktop/web2py/gluon/custom_import.py, line
280, in __call__
fromlist, level)
  File /home/mamadou/Desktop/web2py/gluon/custom_import.py, line 75,
in __call__
level)
  File /home/mamadou/Desktop/web2py/applications/w2popenid/modules/
testing.py, line 7, in module
import openid.consumer.consumer
  File /home/mamadou/Desktop/web2py/gluon/custom_import.py, line
280, in __call__
fromlist, level)
  File /home/mamadou/Desktop/web2py/gluon/custom_import.py, line 75,
in __call__
level)
  File /usr/lib/pymodules/python2.7/openid/consumer/consumer.py,
line 197, in module
from openid.consumer.discover import discover,
OpenIDServiceEndpoint, \
  File /home/mamadou/Desktop/web2py/gluon/custom_import.py, line
280, in __call__
fromlist, level)
  File /home/mamadou/Desktop/web2py/gluon/custom_import.py, line 75,
in __call__
level)
  File /usr/lib/pymodules/python2.7/openid/consumer/discover.py,
line 21, in module
from openid.yadis.etxrd import nsTag, XRDSError, XRD_NS_2_0
  File /home/mamadou/Desktop/web2py/gluon/custom_import.py, line
280, in __call__
fromlist, level)
  File /home/mamadou/Desktop/web2py/gluon/custom_import.py, line 75,
in __call__
level)
  File /usr/lib/pymodules/python2.7/openid/yadis/etxrd.py, line 28,
in module
ElementTree = importElementTree()
  File /usr/lib/pymodules/python2.7/openid/oidutil.py, line 58, in
importElementTree
ElementTree = __import__(mod_name, None, None, ['unused'])
  File /home/mamadou/Desktop/web2py/gluon/custom_import.py, line
258, in __call__
globals.get(__file__, ))
AttributeError: 'NoneType' object has no attribute 'get'

to fix i must modify the module custom_import in the web2py/gluon
folder.
starting line 256

try:
caller_file_name = os.path.join(self.web2py_path,
\globals.get(__file__, ))
except AttributeError:
caller_file_name = 


[web2py] Re: Import from another application in 1.96.x

2011-06-15 Thread cjrh
On Wednesday, June 15, 2011 3:22:02 PM UTC+2, Jim Karsten wrote:

 I wonder if I should be using the site-packages directory instead of a 
 shared app.


Yes.  web2py/site-packages.  It depends to some extent on how much 
app-specific references are used, I guess.  For example, if your site 
packages module contains functions that operate internally on objects with 
members that are only defined inside the apps, then I would rather suggest 
that that code remain within the scope of the app (and then: why share that 
code anyway between apps?), but if the code is more generic, and especially 
if multiple apps are going to use it, then site-packages is a good spot.


[web2py] Re: How do you document your apps?

2011-06-15 Thread Massimo Di Pierro
I am not that familiar with Sphinx. If you use markmin syntax you can
used the provided markmin2pdf to generate pdf documentation.

On Jun 15, 1:39 am, Marcel Luethi marcel.lue...@gmail.com wrote:
 Hello!

 I just finished an internal project using web2py (1.95.1) and have to
 document it for my colleagues.
 Preferably it is a system based of doc strings. Maybe Sphinx?

 Question:
 What are you using?
 Do you have any suggestions?

 Thanks in advance for your input!

 Best regards,
 Marcel


[web2py] Re: Broken pipe with mysql

2011-06-15 Thread Massimo Di Pierro
Consider this code:

1) connect
2) start transaction
3) insert a record
4) select
5) insert another record
6) close transaction

If the connection is lost between 4 and 5 and you reconnect what
should the workflow be? Jump to 1? Jump to 6? Should 5 be executed if
3 was not committed?

I do not believe this reconnection can be automated because depends on
your workflow. Connections should not break.


On Jun 15, 2:58 am, Álvaro J. Iradier airad...@gmail.com wrote:
 I agree there's not way to notify web2py that the connection is lost,
 but isn't it possible to detect that the connection broke after the
 error is raised, and try to reconnect?

 Thanks.

 On 15 jun, 03:25, Massimo Di Pierro massimo.dipie...@gmail.com
 wrote:







  This presents logical problems. It just should not happen. Edit the
  mysql config file and change the timeout. If the database is
  restarted, web2py needs restarting because there is no mechanism in
  the database connection API to notify web2py (or python) that a
  connection lost.

  On Jun 14, 4:06 pm, Álvaro J. Iradier airad...@gmail.com wrote:

   As seen in this thread:

  http://groups.google.com/group/web2py/browse_thread/thread/c6653dadbe...

   I'm getting broken pipe messages when mysql is restarted, and under
   other circunstances.

   Going to a shell, I tried doing a query, for example:

db(db.location).select()

   gluon.dal.Rows object at 0xa2056ec

   everything goes ok. Then I restart Mysql, and running the same query I
   get:

db(db.location).select()

   Traceback (most recent call last):
     File console, line 1, in module
     File /var/www/web2py_klnetcenter/gluon/dal.py, line 5382, in
   select
       return self.db._adapter.select(self.query,fields,attributes)
     File /var/www/web2py_klnetcenter/gluon/dal.py, line 1159, in
   select
       rows = response(sql)
     File /var/www/web2py_klnetcenter/gluon/dal.py, line 1149, in
   response
       self.execute(sql)
     File /var/www/web2py_klnetcenter/gluon/dal.py, line 1234, in
   execute
       return self.log_execute(*a, **b)
     File /var/www/web2py_klnetcenter/gluon/dal.py, line 1229, in
   log_execute
       ret = self.cursor.execute(*a,**b)
     File /var/www/web2py_klnetcenter/gluon/contrib/pymysql/cursors.py,
   line 108, in execute
       self.errorhandler(self, exc, value)
     File /var/www/web2py_klnetcenter/gluon/contrib/pymysql/
   connections.py, line 184, in defaulterrorhandler
       raise errorclass, errorvalue
   OperationalError: (2013, 'Lost connection to MySQL server during
   query')

   trying to run it again, I only get:

db(db.location).select()

   Traceback (most recent call last):
     File console, line 1, in module
     File /var/www/web2py_klnetcenter/gluon/dal.py, line 5382, in
   select
       return self.db._adapter.select(self.query,fields,attributes)
     File /var/www/web2py_klnetcenter/gluon/dal.py, line 1159, in
   select
       rows = response(sql)
     File /var/www/web2py_klnetcenter/gluon/dal.py, line 1149, in
   response
       self.execute(sql)
     File /var/www/web2py_klnetcenter/gluon/dal.py, line 1234, in
   execute
       return self.log_execute(*a, **b)
     File /var/www/web2py_klnetcenter/gluon/dal.py, line 1229, in
   log_execute
       ret = self.cursor.execute(*a,**b)
     File /var/www/web2py_klnetcenter/gluon/contrib/pymysql/cursors.py,
   line 108, in execute
       self.errorhandler(self, exc, value)
     File /var/www/web2py_klnetcenter/gluon/contrib/pymysql/
   connections.py, line 182, in defaulterrorhandler
       raise Error(errorclass, errorvalue)
   Error: (class 'socket.error', error(32, 'Broken pipe'))

   forever!. However, if I do:

db._adapter.connection.ping()
   True
db(db.location).select()

   gluon.dal.Rows object at 0xa20596c

   so it looks like pinging does a reconnect.

   If the connection is closed manually, it won't reconnect either:

db(db.location).select()

   gluon.dal.Rows object at 0xa205a0c db._adapter.connection.close()
print db(db.location).select()

   Traceback (most recent call last):
     File console, line 1, in module
     File /var/www/web2py_klnetcenter/gluon/dal.py, line 5382, in
   select
       return self.db._adapter.select(self.query,fields,attributes)
     File /var/www/web2py_klnetcenter/gluon/dal.py, line 1159, in
   select
       rows = response(sql)
     File /var/www/web2py_klnetcenter/gluon/dal.py, line 1149, in
   response
       self.execute(sql)
     File /var/www/web2py_klnetcenter/gluon/dal.py, line 1234, in
   execute
       return self.log_execute(*a, **b)
     File /var/www/web2py_klnetcenter/gluon/dal.py, line 1229, in
   log_execute
       ret = self.cursor.execute(*a,**b)
     File /var/www/web2py_klnetcenter/gluon/contrib/pymysql/cursors.py,
   line 108, in execute
       self.errorhandler(self, exc, value)
     File /var/www/web2py_klnetcenter/gluon/contrib/pymysql/
   connections.py, line 184, in defaulterrorhandler
       raise errorclass, 

[web2py] Re: Web2py Single Sign On Free with another application

2011-06-15 Thread Massimo Di Pierro
We need more details about the Java app. Examples of single sign on
protocols are CAS, OpenID, Oauth, Kerberos.

On Jun 15, 7:59 am, Neveen Adel nevo.a...@gmail.com wrote:
 Thanks Massimo for your reply.

 I think it use HTTP protocol .

 On Jun 14, 5:49 pm, Massimo Di Pierro massimo.dipie...@gmail.com
 wrote:







  yes but ow depends on what single sign on protocol is supported by the
  Java app.

  On Jun 14, 8:46 am, Neveen Adel nevo.a...@gmail.com wrote:

   Hello,

    I have a web2py application and another java application (using
   Tomcat).
   and there is links inside tomcat application that call java
   application.

   How can i use Single Sign  to make the link of the java application
   not open if the user not logged in?

   Thanks in Advance


[web2py] Re: MNPP (Mac + Nginx + Percona + PHP or Python) includes web2py

2011-06-15 Thread Massimo Di Pierro
Nice!

On Jun 15, 8:57 am, Anthony abasta...@gmail.com wrote:
 http://getmnpp.org/http://blog.getmnpp.org/mnpp-010-released

 The two Python frameworks included in MNPP are Django and web2py. :-)


[web2py] Re: Speed of rendering html data (10,000+ rows)

2011-06-15 Thread Massimo Di Pierro
Please open an issue in google code and link this thread. This should
be improved.

On Jun 15, 8:59 am, cjrh caleb.hatti...@gmail.com wrote:
 Raymond Hettinger recently tweeted that .join() was O(n) but concats are
 O(n^2), or some other super-linear factor like that, so your speedup makes
 perfect sense.   I think you've discovered a performance bottleneck in the
 rendering system of web2py.  Shouldn't be too hard to find with a profiler.
  I wish I had time to play with this, but I don't.   But I am very
 interested in this issue, which is why I am replying (so I can tick Email
 updates to me :)


[web2py] Re: import error

2011-06-15 Thread Massimo Di Pierro
looking into this...

On Jun 15, 8:12 am, mb_...@yahoo.fr mb_...@yahoo.fr wrote:
 I wanted to use the w2popenid example application from bitbucket
 website :https://bitbucket.org/bottiger/web2py-openid/overview
  I have downloaded and placed the code in the applications directory.
 I have changed in the models folder the file db.py: this line from
 applications.cas.modules.w2popenid import OpenIDLogin is replaced
 with this one from w2popenid import OpenIDLogin or this from
 applications.w2popenid.modules.import OpenIDLogin. But it don't
 worked. I get to follow this trace
 Traceback (most recent call last):
   File /home/mamadou/Desktop/web2py/gluon/restricted.py, line 192,
 in restricted
     exec ccode in environment
   File /home/mamadou/Desktop/web2py/applications/w2popenid/models/
 db.py, line 42, in module
     from testing import lala
   File /home/mamadou/Desktop/web2py/gluon/custom_import.py, line
 280, in __call__
     fromlist, level)
   File /home/mamadou/Desktop/web2py/gluon/custom_import.py, line 75,
 in __call__
     level)
   File /home/mamadou/Desktop/web2py/applications/w2popenid/modules/
 testing.py, line 7, in module
     import openid.consumer.consumer
   File /home/mamadou/Desktop/web2py/gluon/custom_import.py, line
 280, in __call__
     fromlist, level)
   File /home/mamadou/Desktop/web2py/gluon/custom_import.py, line 75,
 in __call__
     level)
   File /usr/lib/pymodules/python2.7/openid/consumer/consumer.py,
 line 197, in module
     from openid.consumer.discover import discover,
 OpenIDServiceEndpoint, \
   File /home/mamadou/Desktop/web2py/gluon/custom_import.py, line
 280, in __call__
     fromlist, level)
   File /home/mamadou/Desktop/web2py/gluon/custom_import.py, line 75,
 in __call__
     level)
   File /usr/lib/pymodules/python2.7/openid/consumer/discover.py,
 line 21, in module
     from openid.yadis.etxrd import nsTag, XRDSError, XRD_NS_2_0
   File /home/mamadou/Desktop/web2py/gluon/custom_import.py, line
 280, in __call__
     fromlist, level)
   File /home/mamadou/Desktop/web2py/gluon/custom_import.py, line 75,
 in __call__
     level)
   File /usr/lib/pymodules/python2.7/openid/yadis/etxrd.py, line 28,
 in module
     ElementTree = importElementTree()
   File /usr/lib/pymodules/python2.7/openid/oidutil.py, line 58, in
 importElementTree
     ElementTree = __import__(mod_name, None, None, ['unused'])
   File /home/mamadou/Desktop/web2py/gluon/custom_import.py, line
 258, in __call__
     globals.get(__file__, ))
 AttributeError: 'NoneType' object has no attribute 'get'

 to fix i must modify the module custom_import in the web2py/gluon
 folder.
 starting line 256

 try:
     caller_file_name = os.path.join(self.web2py_path,
 \globals.get(__file__, ))
 except AttributeError:
 caller_file_name = 


[web2py] Re: Speed of rendering html data (10,000+ rows)

2011-06-15 Thread cjrh
Hi Veneet

Following Massimo's recommendation that an issue be opened, I have taken the 
liberty of creating one on your behalf here (Issue 307):

http://code.google.com/p/web2py/issues/detail?id=307sort=-id

I am impatient and I couldn't wait.  Please bookmark the issue and follow 
progress there.  

regards
Caleb


[web2py] Am I understanding session correctly

2011-06-15 Thread Jim Steil

Hi

I have a page with a jqgrid and my own search form.  Nothing fancy, just 
an input box, submit button and clear button.  I'm trying to implement 
so that the following can happen:


*  User enters search phrase and clicks submit - Grid is refetched 
displaying filtered results

*  User can double-click on a row to go to a new page to edit the record
*  User returns to search page and previous search phrase is redisplayed 
in search field and list is filtered
*  User can click on the Clear button to clear the search and redisplay 
results with no filtering
*  If user leaves the page and returns the search phrase is forgotten 
and full list is displayed


I'm implementing this currently saving the name of the page and the last 
used search phrase in session variables.


It is all working as desired except that when I click on the Clear 
button my code (called via JQuery using script below) resets my session 
variables to ''.  The problem is that my change to the session variables 
do not get saved somehow.


$(#list).setGridParam({postData:{'searchText':'..clear..'}});
$(#list).trigger(reloadGrid);
$(#searchText).val('');

So, my question is - Am I understanding correctly that session variables 
are valid for my 'session' and are not function-specific?  Also, would 
the fact that I'm setting the session variables back to their default in 
a function with the @service.json decorator change the behavior of the 
session object and cause my changes to not be saved?


Any pointers would be appreciated.

-Jim





[web2py] Re: Am I understanding session correctly

2011-06-15 Thread Massimo Di Pierro
You are correct with one exception... when calling services the
session cookie is usually not passed therefore if you call functions
using the call() action for services, they will not see and will not
save sessions.

On Jun 15, 9:46 am, Jim Steil j...@qlf.com wrote:
 So, my question is - Am I understanding correctly that session variables
 are valid for my 'session' and are not function-specific?  Also, would
 the fact that I'm setting the session variables back to their default in
 a function with the @service.json decorator change the behavior of the
 session object and cause my changes to not be saved?

 Any pointers would be appreciated.

      -Jim


Re: [web2py] Re: Am I understanding session correctly

2011-06-15 Thread Jim Steil

Thank you for the explanation.

-Jim

On 6/15/2011 10:06 AM, Massimo Di Pierro wrote:

You are correct with one exception... when calling services the
session cookie is usually not passed therefore if you call functions
using the call() action for services, they will not see and will not
save sessions.

On Jun 15, 9:46 am, Jim Steilj...@qlf.com  wrote:

So, my question is - Am I understanding correctly that session variables
are valid for my 'session' and are not function-specific?  Also, would
the fact that I'm setting the session variables back to their default in
a function with the @service.json decorator change the behavior of the
session object and cause my changes to not be saved?

Any pointers would be appreciated.

  -Jim


[web2py] Re: Speed of rendering html data (10,000+ rows)

2011-06-15 Thread Vineet
Caleb,
Thanks for opening an issue on my behalf.
I am eagerly following the developments on this.
Thanks,
Vineet

On Jun 15, 7:29 pm, cjrh caleb.hatti...@gmail.com wrote:
 Hi Veneet

 Following Massimo's recommendation that an issue be opened, I have taken the
 liberty of creating one on your behalf here (Issue 307):

 http://code.google.com/p/web2py/issues/detail?id=307sort=-id

 I am impatient and I couldn't wait.  Please bookmark the issue and follow
 progress there.  

 regards
 Caleb


[web2py] SQLFORM layout - very frustrating

2011-06-15 Thread wdtatenh
I could really use an answer to this question.

Using SQLFORM is there a simple notation to set the width of a
select with IS_IN_SET defined in the model.

Inserting {{=custom.form.widget.myField}} works but I don't see how I
can set the width?

I've experimented to my eye's bleed but nothing I've attempted works.

Would appreciate even an answer that says you can't do it with
custom.form. notation.

It works find for other form elements - just the select is the
hangup.

thanks in advance


[web2py] Re: SQLFORM layout - very frustrating

2011-06-15 Thread apple
I had similar issue with a textarea. Resolved using a custom widget.

On Jun 15, 4:16 pm, wdtatenh wdt...@comcast.net wrote:
 I could really use an answer to this question.

 Using SQLFORM is there a simple notation to set the width of a
 select with IS_IN_SET defined in the model.

 Inserting {{=custom.form.widget.myField}} works but I don't see how I
 can set the width?

 I've experimented to my eye's bleed but nothing I've attempted works.

 Would appreciate even an answer that says you can't do it with
 custom.form. notation.

 It works find for other form elements - just the select is the
 hangup.

 thanks in advance


[web2py] Re: How do you document your apps?

2011-06-15 Thread Carl
I'm using http://epydoc.sourceforge.net/

It's output is fairly plain but it does parse doc strings. Optionally,
the source code cam be included so your colleagues can click from doc
through to code.

Easy to install too.


On Jun 15, 3:05 pm, Massimo Di Pierro massimo.dipie...@gmail.com
wrote:
 I am not that familiar with Sphinx. If you use markmin syntax you can
 used the provided markmin2pdf to generate pdf documentation.

 On Jun 15, 1:39 am, Marcel Luethi marcel.lue...@gmail.com wrote:







  Hello!

  I just finished an internal project using web2py (1.95.1) and have to
  document it for my colleagues.
  Preferably it is a system based of doc strings. Maybe Sphinx?

  Question:
  What are you using?
  Do you have any suggestions?

  Thanks in advance for your input!

  Best regards,
  Marcel


Re: [web2py] SQLFORM layout - very frustrating

2011-06-15 Thread Marin Pranjic
you can customize select / option tags layout with CSS

On Wed, Jun 15, 2011 at 5:16 PM, wdtatenh wdt...@comcast.net wrote:

 I could really use an answer to this question.

 Using SQLFORM is there a simple notation to set the width of a
 select with IS_IN_SET defined in the model.

 Inserting {{=custom.form.widget.myField}} works but I don't see how I
 can set the width?

 I've experimented to my eye's bleed but nothing I've attempted works.

 Would appreciate even an answer that says you can't do it with
 custom.form. notation.

 It works find for other form elements - just the select is the
 hangup.

 thanks in advance


[web2py] Re: Broken pipe with mysql

2011-06-15 Thread Álvaro J . Iradier
I agree with Ron. If connection is broken between 4 and 5, I would
expect the transaction to be rollback (it was not commited), and an
error raised. Probably that request will fail, but at least the
connection is not dropped and not recoverable.

I guess in a server restart or shutdown, the server will probably (or
should) wait until active connections are finished, and stop accepting
new connections meanwhile. So the problem is likely to happen when
there are idle connections in the pool, and the server is restarted.
The connnections in the pool are invalid and can't be used anymore,
but they won't recover, as web2py won't notice they are
disconnected...

Greets.

On 15 jun, 17:28, ron_m ron.mco...@gmail.com wrote:
 Unless step 6 is reached and completed if the client closed then I would
 expect the database server to detect the closed connection and rollback on
 its own since there is no way to recover the state built on that connection
 or if the database server is restarted then the database server should
 perform startup recovery and rollback anything that isn't completed but the
 client still needs to clean up.

 What this smells like is a connection pool will hold open connections for
 reuse, the database server is restarted because of a maintenance script and
 now the pool has stale connections. When one of these pooled connections is
 given to a user task the connection should be detected as stale in the pool
 logic and a reconnect attempted before handing it over to the user.

 What Alvaro describes is similar but it looks like the DAL won't initiate a
 new connection after a server restart unless a ping is performed. Is it
 possible there is state being held in the DAL or the mysqldb driver that
 says there is a connection but is not cleared to allow an attempt to get a
 fresh open on the database?


[web2py] Re: Broken pipe with mysql

2011-06-15 Thread ron_m
Unless step 6 is reached and completed if the client closed then I would 
expect the database server to detect the closed connection and rollback on 
its own since there is no way to recover the state built on that connection 
or if the database server is restarted then the database server should 
perform startup recovery and rollback anything that isn't completed but the 
client still needs to clean up.

What this smells like is a connection pool will hold open connections for 
reuse, the database server is restarted because of a maintenance script and 
now the pool has stale connections. When one of these pooled connections is 
given to a user task the connection should be detected as stale in the pool 
logic and a reconnect attempted before handing it over to the user.

What Alvaro describes is similar but it looks like the DAL won't initiate a 
new connection after a server restart unless a ping is performed. Is it 
possible there is state being held in the DAL or the mysqldb driver that 
says there is a connection but is not cleared to allow an attempt to get a 
fresh open on the database?




[web2py] Re: SQLFORM layout - very frustrating

2011-06-15 Thread selecta
 you can customize select / option tags layout with CSS
that is what i usually do
go with you mouse and rightclik on the element and select inspect
element (ff+firebug, chrom or opera)
now you can see the id of the element
in you css you can now write something like
#mytable_body{
width: 790px;
height: 50px;
}

you could also change the width of all form elements from the table
mytable with
input[id^='mytalbe_'] {
   width: 100px;
}


[web2py] Re: SQLFORM layout - very frustrating

2011-06-15 Thread Massimo Di Pierro
Whether you use form.custom or not all elements are CSS friendly. You
can change all attribute using CSS or
jQuery('#name').css('attribute','value');

On Jun 15, 10:42 am, selecta gr...@delarue-berlin.de wrote:
  you can customize select / option tags layout with CSS

 that is what i usually do
 go with you mouse and rightclik on the element and select inspect
 element (ff+firebug, chrom or opera)
 now you can see the id of the element
 in you css you can now write something like
 #mytable_body{
     width: 790px;
     height: 50px;

 }

 you could also change the width of all form elements from the table
 mytable with
 input[id^='mytalbe_'] {
    width: 100px;







 }


[web2py] Re: Speed of rendering html data (10,000+ rows)

2011-06-15 Thread VP



 for i in custdata:
    mystr2 = ''.join([mystr2, 'trtd' , str(i[0]) , '/td'])
...

 lst = [ jn(['trtd' , str(i[0]) , '/td',
            'td' , str(i[1]) , '/td',
            'td' , str(i[2]) , '/td',
         .. more omitted..]) for i in res]

 mystr=jn(lst)
 --
 The performance boost is amazing..
 It took ONLY 0.078 seconds
 --


This makes sense because a crude analysis shows that the first
approach is O(n^3) while the second one is O(n).

(I think)


[web2py] Re: dynamic link and image as represent in db Field

2011-06-15 Thread villas
Just a general comment - I don't think using a field name of join is a 
good idea.  It must be a reserved word and therefore might lead to problems.


[web2py] Re: SQLFORM layout - very frustrating

2011-06-15 Thread wdtatenh
That worked - thanks very so much.


Re: [web2py] import error

2011-06-15 Thread Pierre Thibault
2011/6/15 mb_...@yahoo.fr mb_...@yahoo.fr

 I wanted to use the w2popenid example application from bitbucket
 website : https://bitbucket.org/bottiger/web2py-openid/overview
  I have downloaded and placed the code in the applications directory.
 I have changed in the models folder the file db.py: this line from
 applications.cas.modules.w2popenid import OpenIDLogin is replaced
 with this one from w2popenid import OpenIDLogin or this from
 applications.w2popenid.modules.import OpenIDLogin. But it don't
 worked. I get to follow this trace
 Traceback (most recent call last):
  File /home/mamadou/Desktop/web2py/gluon/restricted.py, line 192,
 in restricted
exec ccode in environment
  File /home/mamadou/Desktop/web2py/applications/w2popenid/models/
 db.py, line 42, in module
from testing import lala
  File /home/mamadou/Desktop/web2py/gluon/custom_import.py, line
 280, in __call__
fromlist, level)
  File /home/mamadou/Desktop/web2py/gluon/custom_import.py, line 75,
 in __call__
level)
  File /home/mamadou/Desktop/web2py/applications/w2popenid/modules/
 testing.py, line 7, in module
import openid.consumer.consumer
  File /home/mamadou/Desktop/web2py/gluon/custom_import.py, line
 280, in __call__
fromlist, level)
  File /home/mamadou/Desktop/web2py/gluon/custom_import.py, line 75,
 in __call__
level)
  File /usr/lib/pymodules/python2.7/openid/consumer/consumer.py,
 line 197, in module
from openid.consumer.discover import discover,
 OpenIDServiceEndpoint, \
  File /home/mamadou/Desktop/web2py/gluon/custom_import.py, line
 280, in __call__
fromlist, level)
  File /home/mamadou/Desktop/web2py/gluon/custom_import.py, line 75,
 in __call__
level)
  File /usr/lib/pymodules/python2.7/openid/consumer/discover.py,
 line 21, in module
from openid.yadis.etxrd import nsTag, XRDSError, XRD_NS_2_0
  File /home/mamadou/Desktop/web2py/gluon/custom_import.py, line
 280, in __call__
fromlist, level)
  File /home/mamadou/Desktop/web2py/gluon/custom_import.py, line 75,
 in __call__
level)
  File /usr/lib/pymodules/python2.7/openid/yadis/etxrd.py, line 28,
 in module
ElementTree = importElementTree()
  File /usr/lib/pymodules/python2.7/openid/oidutil.py, line 58, in
 importElementTree
ElementTree = __import__(mod_name, None, None, ['unused'])
  File /home/mamadou/Desktop/web2py/gluon/custom_import.py, line
 258, in __call__
globals.get(__file__, ))
 AttributeError: 'NoneType' object has no attribute 'get'

 to fix i must modify the module custom_import in the web2py/gluon
 folder.
 starting line 256

 try:
caller_file_name = os.path.join(self.web2py_path,
 \globals.get(__file__, ))
 except AttributeError:
 caller_file_name = 



Hi,

Could you send me the code of your app and instructions on how to reproduce
the problem in my personal mail box? I will investigate the problem. Thank
you.
-- 


A+

-
Pierre
My blog and profile
(http://pierrethibault.posterous.com)http://pierrethibault.posterous.com
YouTube page 
(http://www.youtube.com/user/tubetib)http://www.youtube.com/user/tubetib
Twitter (http://twitter.com/pierreth2) http://twitter.com/pierreth2


Re: [web2py] How do you document your apps?

2011-06-15 Thread Pierre Thibault
I like epydoc. It is supported by pydev. It is simple. Sphinx is more both
more powerful and more complex.

I am sending my epydoc Eclipse external tool as an attachment. I think you
just have to put the file somewhere in an open project to make it available
as a external tool. To use it, click on your project and choose the command
from the external tool menu available in the tool bar.

2011/6/15 Marcel Luethi marcel.lue...@gmail.com

 Hello!

 I just finished an internal project using web2py (1.95.1) and have to
 document it for my colleagues.
 Preferably it is a system based of doc strings. Maybe Sphinx?

 Question:
 What are you using?
 Do you have any suggestions?

 Thanks in advance for your input!

 Best regards,
 Marcel




-- 


A+

-
Pierre
My blog and profile
(http://pierrethibault.posterous.com)http://pierrethibault.posterous.com
YouTube page 
(http://www.youtube.com/user/tubetib)http://www.youtube.com/user/tubetib
Twitter (http://twitter.com/pierreth2) http://twitter.com/pierreth2


Epydoc.launch
Description: Binary data


[web2py] Re: dynamic link and image as represent in db Field

2011-06-15 Thread frasse
Thanx Villas . but it is not my real code . I just put a example to
explain my problem

On Jun 15, 6:45 pm, villas villa...@gmail.com wrote:
 Just a general comment - I don't think using a field name of join is a
 good idea.  It must be a reserved word and therefore might lead to problems.


[web2py] personalise sqltable

2011-06-15 Thread frasse
Hi all
i try to personalise sqltable by using following code
I am using __setitem__ to generate customize rows in table. this code
is working for StartTime Field but not for gameName Field (it just
display the html code ). any idea?

db code:

db.define_table('games',
Field('gameName',default='Game'),
Field('StartTime','datetime',default=now)
)

Controllers code:
-

def Mytest():
rows = db().select(db.games.ALL)
records=SQLTABLE(getRows(rows),
 headers='fieldname:capitalize',
 truncate=100
 )
return dict(records=records )

def getRows(rows):
for r in rows:
r.__setitem__('StartTime', B(str(r['StartTime'])))  # This
code is working
r.__setitem__('gameName', B(str(r['gameName']))) # This code
is not working

return rows



Thanx
Frasse


[web2py] ORMs as anti-pattern?

2011-06-15 Thread pbreit
Interesting perspective on ORM:
http://seldo.com/weblog/2011/06/15/orm_is_an_antipattern

We don't quite fall in to that category do we?


[web2py] Re: ORMs as anti-pattern?

2011-06-15 Thread Massimo Di Pierro
I do not think it applies. web2py has a DAL not an ORM. There are
similarities but there are differences. The DAL preserves the SQL
query syntax, while an ORM often does not.

On Jun 15, 1:32 pm, pbreit pbreitenb...@gmail.com wrote:
 Interesting perspective on 
 ORM:http://seldo.com/weblog/2011/06/15/orm_is_an_antipattern

 We don't quite fall in to that category do we?


[web2py] Controller specific models

2011-06-15 Thread Jay Shaffstall
I've been unable to get my controller specific model to work in
1.96.4.  Here's what I've got set up, can anyone point out the error?

Controller: email.py, in app/controllers/email.py
Model: email/settings.py in app/models/email/settings.py

My understanding is that email/settings.py should be run for any page
invoked in email.py.  That isn't happening (verified with a print
statement, just to make sure something else weird wasn't going on).

Alternatively, if anyone has an example app that demonstrates using
controller specific models, I can try running that to see if I've
somehow broken web2py.

Thanks,
Jay


Re: [web2py] prettyPhoto with web2py

2011-06-15 Thread Bruno Rocha
I am using on http://CursoDePython.com.br , no problem



--
Bruno Rocha
[ About me: http://zerp.ly/rochacbruno ]
[ Aprenda a programar: http://CursoDePython.com.br ]
[ O seu aliado nos cuidados com os animais: http://AnimalSystem.com.br ]
[ Consultoria em desenvolvimento web: http://www.blouweb.com ]



On Wed, Jun 15, 2011 at 8:34 AM, Sahil Arora sahilarora...@gmail.comwrote:

 Has anyone tried using prettyPhoto (
 http://www.no-margin-for-errors.com/projects/prettyphoto-jquery-lightbox-clone/)
 with web2py. I was trying for single photo(as in demo), but facing problems.



[web2py] Re: ORMs as anti-pattern?

2011-06-15 Thread cjrh


On Wednesday, 15 June 2011 20:50:49 UTC+2, Massimo Di Pierro wrote:

 The DAL preserves the SQL 
 query syntax, while an ORM often does not. 


That is exactly right.  The DAL abstracts away some of the complexity of 
SQL, and certainly some of the differences between the various 
implementations of SQL by the various vendors of database engines, but not 
too much that it is difficult to figure out what is happening at the lower 
level of raw sql.  A foot in both worlds.



Re: [web2py] prettyPhoto with web2py

2011-06-15 Thread Bruno Rocha
I am using on http://CursoDePython.com.br , no problem



--
Bruno Rocha
[ About me: http://zerp.ly/rochacbruno ]
[ Aprenda a programar: http://CursoDePython.com.br ]
[ O seu aliado nos cuidados com os animais: http://AnimalSystem.com.br ]
[ Consultoria em desenvolvimento web: http://www.blouweb.com ]



On Wed, Jun 15, 2011 at 8:34 AM, Sahil Arora sahilarora...@gmail.comwrote:

 Has anyone tried using prettyPhoto (
 http://www.no-margin-for-errors.com/projects/prettyphoto-jquery-lightbox-clone/)
 with web2py. I was trying for single photo(as in demo), but facing problems.



[web2py] Re: personalise sqltable

2011-06-15 Thread pbreit
This doesn't answer your question but, why aren't you doing this easily in 
the view? That code doesn't resemble anything I've ever seen in Web2py.

[web2py] Re: dynamic link and image as represent in db Field

2011-06-15 Thread pbreit
frasse, what are you trying to do? Your code is very different from how you 
would usually do something in Web2py. Are you making a web site?

[web2py] possible web2py job in Germany

2011-06-15 Thread Tim Michelsen
http://www.axantis.com/job.php?postid=833

(I am just reposting.)



[web2py] Simple DAL question

2011-06-15 Thread Jim Steil

Hi

New to web2py and DAL and some things are just not obvious, probably 
because I'm coming from SQLObject where things are done a bit 
differently.  Here is my challenge, probably something everyone else 
here has already dealt with:


Using the following auth tables:

auth_user
auth_group
auth_membership

...how do I get a list of users who are members of a specific group?  
Simple SQL would be:


SELECT first_name, last_name
FROM auth_user
WHERE id IN (SELECT user_id FROM auth_membership WHERE group_id = 4)

How would I do this most efficiently using the DAL?

-Jim




Re: [web2py] Simple DAL question

2011-06-15 Thread Vasile Ermicioi
not tested:
your sql query equivalent

group_query =
db(db.auth_membership.group_id==4)._select(db.auth_membership.user_id)
rows =
db(db.auth_user.id.belongs(group_query)).select(db.auth_user.first_name,db.auth_user.last_name)


Re: [web2py] Simple DAL question

2011-06-15 Thread Anthony
Also, for more about 'belongs' and nested selects, see 
http://web2py.com/book/default/chapter/06#belongs.
 
Anthony

On Wednesday, June 15, 2011 4:00:34 PM UTC-4, elffikk wrote:

 not tested:
 your sql query equivalent

 group_query = 
 db(db.auth_membership.group_id==4)._select(db.auth_membership.user_id) 
 rows = 
 db(db.auth_user.id.belongs(group_query)).select(db.auth_user.first_name,db.auth_user.last_name)



Re: [web2py] Simple DAL question

2011-06-15 Thread Jim Steil

Exactly what I needed - Thanks much!

-Jim

On 6/15/2011 3:00 PM, Vasile Ermicioi wrote:
group_query = 
db(db.auth_membership.group_id==4)._select(db.auth_membership.user_id)
rows = 
db(db.auth_user.id.belongs(group_query)).select(db.auth_user.first_name,db.auth_user.last_name)


[web2py] Re: possible web2py job in Germany

2011-06-15 Thread JorgeH
It doesn't even mention Web2py

It talks about web.py , quite another python framework, not related to 
Massimo's project.


[web2py] fyi: web2py 1.96.4 breaks with pywin32-2.16 - fine with pywin32-2.14

2011-06-15 Thread baloan
After a system upgrade I found that web2py 1.96.4 breaks with pywin32
2.16. It works fine with pywin32 2.14. The installation features
mercurial 1.7.5. I can't use mercurial 1.8.4 because it breaks my trac
0.12.2 installation.

With web2py 1.96.4, pywin32 2.16, mercurial 1.7.5 I see the following
error:

Traceback (most recent call last):
  File D:\\Home\\web\\web2py\\gluon\\main.py, line 516, in wsgibase
session._try_store_on_disk(request, response)
  File D:\\Home\\web\\web2py\\gluon\\globals.py, line 494, in
_try_store_on_disk
portalocker.lock(response.session_file, portalocker.LOCK_EX)
  File C:\\Apps\\Python27\\lib\\site-packages\\mercurial\
\demandimport.py, line 75, in __getattribute__
self._load()
  File C:\\Apps\\Python27\\lib\\site-packages\\mercurial\
\demandimport.py, line 47, in _load
mod = _origimport(head, globals, locals)
  File D:\\Home\\web\\web2py\\gluon\\portalocker.py, line 69, in
module
__overlapped = pywintypes.OVERLAPPED()
  File C:\\Apps\\Python27\\lib\\site-packages\\mercurial\
\demandimport.py, line 75, in __getattribute__
self._load()
  File C:\\Apps\\Python27\\lib\\site-packages\\mercurial\
\demandimport.py, line 47, in _load
mod = _origimport(head, globals, locals)
  File C:\\Apps\\Python27\\lib\\site-packages\\win32\\lib\
\pywintypes.py, line 124, in module
__import_pywin32_system_module__(pywintypes, globals())
  File C:\\Apps\\Python27\\lib\\site-packages\\win32\\lib\
\pywintypes.py, line 98, in __import_pywin32_system_module__
raise ImportError(No system module \'%s\' (%s) % (modname,
filename))
ImportError: No system module \'pywintypes\' (pywintypes27.dll)


[web2py] Exception with couchdb on trunk type 'exceptions.AttributeError'('Database' object has no attribute 'save')

2011-06-15 Thread David Watson
Hi All,

I finally got some time to begin working with couchdb on trunk again.
I'm working with:

web2py™ Version 1.96.4 (2011-06-14 14:30:00)
Python  Python 2.6.5: /usr/bin/python
Couchdb   Apache 0.10.0

on Ubuntu 10.04 LTS

I was blown away by how far the web interface on web2py has progressed
in 6 months. No time for sleeping!

Anyhow, I created an app with the wizard, all the plugins, and no
model but auth. When the wizard finished, couchdb showed the following
objects:

auth_permission
auth_membership
auth_user
auth_event
auth_group
auth_cas

each of which was 79 bytes and empty from what I could tell. So far so
good. Then it crashed with the following stack:

Traceback (most recent call last):
  File /home/davidthewatson/tornado-couch-blog/web2py/gluon/
restricted.py, line 192, in restricted
exec ccode in environment
  File /home/davidthewatson/tornado-couch-blog/web2py/applications/
lazyblog/models/db_wizard_populate.py, line 3, in module
populate(db.auth_user,10)
  File /home/davidthewatson/tornado-couch-blog/web2py/gluon/contrib/
populate.py, line 155, in populate
table.insert(**record)
  File /home/davidthewatson/tornado-couch-blog/web2py/gluon/dal.py,
line 4701, in insert
return self._db._adapter.insert(self,self._listify(fields))
  File /home/davidthewatson/tornado-couch-blog/web2py/gluon/dal.py,
line 3374, in insert
ctable.save(values)
AttributeError: 'Database' object has no attribute 'save'

This looks very similar to the exceptions I was seeing six months ago
where I presume that either the registration of the couchdb callbacks
isn't right or the calls shouldn't get made for couchdb.

Thanks,
Dave


Re: [web2py] Simple DAL question

2011-06-15 Thread pbreit
And one more option:

auth.has_membership(group_id, user_id, role)


http://web2py.com/book/default/chapter/08#Authorization


[web2py] Re: fyi: web2py 1.96.4 breaks with pywin32-2.16 - fine with pywin32-2.14

2011-06-15 Thread Massimo Di Pierro
This traceback is not compatible with the code:

try:
...
import pywintypes
os_locking = 'windows'
except:
pass
if os_locking == 'windows':

__overlapped = pywintypes.OVERLAPPED()

Did you change the code?

On Jun 15, 3:39 pm, baloan balo...@googlemail.com wrote:
 After a system upgrade I found that web2py 1.96.4 breaks with pywin32
 2.16. It works fine with pywin32 2.14. The installation features
 mercurial 1.7.5. I can't use mercurial 1.8.4 because it breaks my trac
 0.12.2 installation.

 With web2py 1.96.4, pywin32 2.16, mercurial 1.7.5 I see the following
 error:

 Traceback (most recent call last):
   File D:\\Home\\web\\web2py\\gluon\\main.py, line 516, in wsgibase
     session._try_store_on_disk(request, response)
   File D:\\Home\\web\\web2py\\gluon\\globals.py, line 494, in
 _try_store_on_disk
     portalocker.lock(response.session_file, portalocker.LOCK_EX)
   File C:\\Apps\\Python27\\lib\\site-packages\\mercurial\
 \demandimport.py, line 75, in __getattribute__
     self._load()
   File C:\\Apps\\Python27\\lib\\site-packages\\mercurial\
 \demandimport.py, line 47, in _load
     mod = _origimport(head, globals, locals)
   File D:\\Home\\web\\web2py\\gluon\\portalocker.py, line 69, in
 module
     __overlapped = pywintypes.OVERLAPPED()
   File C:\\Apps\\Python27\\lib\\site-packages\\mercurial\
 \demandimport.py, line 75, in __getattribute__
     self._load()
   File C:\\Apps\\Python27\\lib\\site-packages\\mercurial\
 \demandimport.py, line 47, in _load
     mod = _origimport(head, globals, locals)
   File C:\\Apps\\Python27\\lib\\site-packages\\win32\\lib\
 \pywintypes.py, line 124, in module
     __import_pywin32_system_module__(pywintypes, globals())
   File C:\\Apps\\Python27\\lib\\site-packages\\win32\\lib\
 \pywintypes.py, line 98, in __import_pywin32_system_module__
     raise ImportError(No system module \'%s\' (%s) % (modname,
 filename))
 ImportError: No system module \'pywintypes\' (pywintypes27.dll)


[web2py] Re: ORMs as anti-pattern?

2011-06-15 Thread VP
I have always felt that ORM is OO goes nuts.

I have a question for Massimo.  When we select a few columns, does the
Web2py DAL only get those columns from the database (with appropriate
queries), or does it retrieve all of them from the database and only
return those selected for?

Thanks.


[web2py] Re: ORMs as anti-pattern?

2011-06-15 Thread Massimo Di Pierro
It only fetches from the database the columns you asked for, except of
GAE. GAE does not allow this.

On Jun 15, 4:52 pm, VP vtp2...@gmail.com wrote:
 I have always felt that ORM is OO goes nuts.

 I have a question for Massimo.  When we select a few columns, does the
 Web2py DAL only get those columns from the database (with appropriate
 queries), or does it retrieve all of them from the database and only
 return those selected for?

 Thanks.


[web2py] Re: possible web2py job in Germany

2011-06-15 Thread Anthony
On Wednesday, June 15, 2011 4:36:22 PM UTC-4, JorgeH wrote: 

 It doesn't even mention Web2py

 It talks about web.py , quite another python framework, not related to 
 Massimo's project.

 
Well, it says, ...Python frameworks, like Pyramid, web.py, or similar, so 
they may be open to using web2py.


[web2py] how to start web2py in shell as a long web request with a login user?

2011-06-15 Thread Carlos
Hi,

Is it possible to start web2py in the shell as if it was a (long) web 
request (with a login user and/or reusing an existing session)?.

I want to do some interactive testing in the shell as if I was already a 
login user (recognized by a session or via explicit login credentials) since 
the beginning (including the loading of models, i.e. models knowing that 
this long web request is for one specific user or session).

Is this possible?.

I usually start web2py shell with: python web2py.py -S myapp -M

Thanks,

   Carlos



[web2py] Small bug in Version 1.96.4 when using GAE

2011-06-15 Thread Matt
Hi there,

In Version 1.96.4 (2011-06-14 14:30:00) when running GAE there is an
errror:

raise RuntimeError, Failure to connect, tried %d times:\n%s %
(attempts, error)
RuntimeError: Failure to connect, tried 5 times:
global name 'is_jdbc' is not defined

So in dal.py (around line 312) needs to be:

if 'google' in drivers:
is_jdbc = False

Cheers,
Matt


[web2py] Re: Small bug in Version 1.96.4 when using GAE

2011-06-15 Thread Massimo Di Pierro
This is now fixed in trunk. Thank you!

On Jun 15, 6:10 pm, Matt mjwat...@gmail.com wrote:
 Hi there,

 In Version 1.96.4 (2011-06-14 14:30:00) when running GAE there is an
 errror:

     raise RuntimeError, Failure to connect, tried %d times:\n%s %
 (attempts, error)
 RuntimeError: Failure to connect, tried 5 times:
 global name 'is_jdbc' is not defined

 So in dal.py (around line 312) needs to be:

 if 'google' in drivers:
     is_jdbc = False

 Cheers,
 Matt


[web2py] Re: how to start web2py in shell as a long web request with a login user?

2011-06-15 Thread Massimo Di Pierro
Do not forget -N

python web2py.py -S myapp -M -N

else you will get cron tasks that eat memory.

On Jun 15, 5:53 pm, Carlos carlosgali...@gmail.com wrote:
 Hi,

 Is it possible to start web2py in the shell as if it was a (long) web
 request (with a login user and/or reusing an existing session)?.

 I want to do some interactive testing in the shell as if I was already a
 login user (recognized by a session or via explicit login credentials) since
 the beginning (including the loading of models, i.e. models knowing that
 this long web request is for one specific user or session).

 Is this possible?.

 I usually start web2py shell with: python web2py.py -S myapp -M

 Thanks,

    Carlos


[web2py] Re: possible web2py job in Germany

2011-06-15 Thread JorgeH
good point


[web2py] Spello in @request.restful() parsed.error

2011-06-15 Thread Web2py Newbie
Version 1.96.4 (2011-06-07 21:08:15)

If there's no matching pattern:
no mathcing pattern - no matching pattern
^^
Is there a bug tracker somewhere I'm supposed to use?



[web2py] Re: More Details on RESTful web2py?

2011-06-15 Thread Web2py Newbie
Apparently: wait for a pattern failure and work with that?

if parsed.status==200: return parsed.response.json()
else:
   maybe some test for kind of parse error
   print out the whole



[web2py] Re: Spello in @request.restful() parsed.error

2011-06-15 Thread Massimo Di Pierro
this is sufficient. I just fixed it in trunk. If I do not act, next
time, open a ticket in google code.

On Jun 15, 9:03 pm, Web2py Newbie
swiawte...@garrifulio.mailexpire.com wrote:
 Version 1.96.4 (2011-06-07 21:08:15)

 If there's no matching pattern:
 no mathcing pattern - no matching pattern
             ^^
 Is there a bug tracker somewhere I'm supposed to use?


[web2py] Re: More Details on RESTful web2py?

2011-06-15 Thread Massimo Di Pierro
please show us your code.

On Jun 15, 2:25 am, Web2py Newbie
swiawte...@garrifulio.mailexpire.com wrote:
 As a follow up:

 I want to use something like:
 /myapp/api/show_comment/id
 to show comment at id
 and
 /myapp/api/show_comment/
 To show all comments

 However, when I try this it complains (invalid arguments).  I try to
 test id against None, but id is apparently a server object.
 Any ideas or do I just have to define all_comments?