[web2py] web2py represent_none in SQLFORM.smartgrid in combination with date field throws exception

2020-02-25 Thread David Zejda
Hi,

I found out that

SQLFORM.smartgrid(db.table_name, represent_none="") with a table table_name 
containing a field with date datatype throws the exception:

File "/opt/web2py3/gluon/packages/dal/pydal/validators.py", line 2335, in 
formatter
  year = value.year
AttributeError: 'str' object has no attribute 'year'

The problem occurs even if IS_DATE validator is not specified for the 
field. I have not checked it, but other validators might be affected too.

web2py 2.18.5-stable+timestamp.2019.04.08.04.22.03
python 3.7.3

Have a nice day!
David

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/web2py/bad6707a-aacf-47b4-801b-e3465a09bae5%40googlegroups.com.


[web2py] Re: Progressive Web Apps

2019-12-04 Thread David Zejda
Hi,

I use web2py to serve PWA, service worker for client-side caching and for 
proactive loading of contents which are likely to be requested in the next 
step. 

In routes.py I have root_static = ['favicon.ico', 'robots.txt', 
'service_worker.js']. 

Per-app specific service worker. The script is visible to the client (which 
is common for client-side JS, isn't it?). If you don't like it you may 
consider something like https://javascript-obfuscator.org/ .

Layout like this:




{{=response.title}}































{{if 'cust_style' in response:}} {{=XML(response.cust_style)}} {{pass}}
 





{{if 'cust_js' in response:}}{{=XML(response.cust_js)}} 
{{pass}}

{{include}}

{{block page_js}}{{end page_js}}






David

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/web2py/f7b88230-e6a6-413c-864e-dc85c9a4cffb%40googlegroups.com.


[web2py] Re: how to specify python3 for wsgihandler

2019-12-04 Thread David Zejda
I needed SSL with per-domain certificates. Because mod_wsgi-express, though 
easy to install, becomes inflexible if virtual hosts settings need to be 
adjusted eventually, I switched to a second instance of Apache from the 
system-specific packaging. The steps like this: 

cd /usr/share/doc/apache2/examples/
./setup-instance python3

The new instance can be launched as:

systemctl start apache2@python3.service

To get WSGI support for python3 it was not possible to simply install the 
relevant mod-wsgi module package (libapache2-mod-wsgi-py3) alongside with 
its python2 version (libapache2-mod-wsgi), because they are in conflict.

So, I had to install the module from source, such as:

aptitude install apache2-dev
cd /opt
wget https://github.com/GrahamDumpleton/mod_wsgi/archive/4.6.5.tar.gz
tar -xvzf 4.6.5.tar.gz 
cd mod_wsgi-4.6.5
which python3.7
./configure --with-python=/usr/bin/python3.7

add and enable the mod_wsgi.so (located in my case in 
/opt/mod_wsgi-4.6.5/src/server/.libs/mod_wsgi.so) in the apache-python3 
instance instead of the python2 version. As long as the correct module is 
loaded, no need to specify the interpreter in Apache configs; at least in 
my case.

I hope it helps someone ...

David

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/web2py/b428e3f7-c2a5-44ba-8f0b-165e6a01d3aa%40googlegroups.com.


[web2py] Re: how to specify python3 for wsgihandler

2019-11-22 Thread David Zejda
Hi again.

Well, I found out that one Apache instance can't handle applications with 
different python interpreters via mod_wsgi. 

So, I decided to set up a virtual environment for a web2py instance running 
python3 applications with its own Apache and mod_wsgi. 

Since it is virtual environment, I decided if favour of pip instead of the 
operating system-specific packaging system.

Apache+mod_wsgi and the script mod_wsgi-express (refer to 
http://blog.dscpl.com.au/2015/04/introducing-modwsgi-express.html) makes 
the process easier:

Provided that the web2py for python3 apps is in /opt/web2py3, my steps were 
roughly:

sudo apt-get install python3-pip virtualenvwrapper
pip3 install --user --upgrade virtualenvwrapper
cd ~/.local/bin
mkvirtualenv -p /usr/bin/python3 /opt/python3env/web2py
cd /opt/python3env/web2py/bin
./pip3 install mod_wsgi-httpd
./pip3 install mod_wsgi 
cd /opt/web2py3
/opt/python3env/web2py/bin/mod_wsgi-express \
  --user www-data \
  --group www-data \
  --port 8830 \
  --working-directory /opt/web2py3
  --server-root /opt/python3env/web2py/etc
  --log-directory /opt/python3env/web2py/log
  --access-log 
  --startup-log
  --rotate-logs
  start-server wsgihandler.py

I will probably use one public IP address for web2py with python2-based 
apps served by the legacy Apache and a different IP address for 
python3-based apps served by the Apache from the virtual environment 
(configured as a bridge on the same network interface), so I can stick to 
default ports for HTTP and HTTPS, which seems a better solution than 
proxying from one Apache instance to the other.

David

On Monday, 11 November 2019 23:42:56 UTC+1, David Zejda wrote:
>
> Hello to all.
>
> I have a web2py with several apps on a production server behind Apache 
> accessed via wsgihandler. So far, all the apps have been developed for 
> python2.
>
> To support python3 apps (preferred for new projects), I set-up a separate 
> web2py directory and adjusted the Apache configs respectively.
>
> The question is - how to set this new web2py instance to run on python3?
>
> For compatibility reasons, /usr/bin/env python still translates to python 
> 2 interpreter. 
>
> Do I have to change all the #!/usr/bin/env python lines in web2py sources 
> to point to python3 instead? 
> Or where else can I specify the python version? 
>
> Thank you very much for an answer in advance!
>
> David
>

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/web2py/a4aff89d-0f78-45f2-a81a-1c3f58179a44%40googlegroups.com.


[web2py] py4web and Eclipse/PyDev

2019-11-13 Thread David Zejda
Hi to all,

to start experimenting with py4web in Eclipse/PyDev on Debian Linux I did 
the following. 
Maybe someone will find it useful. 

Debugging is not working yet for me, an advice would be welcome.

1) Set-up the virtual environment for web4py with libraries managed by pip 
(to avoid mixing with system-wide python libraries installed by the Debian 
packaging system):

sudo apt-get install virtualenvwrapper
pip3 install --user --upgrade virtualenvwrapper
mkvirtualenv -p /usr/bin/python3 /opt/python3env/py4web
cd /opt/python3env/py4web/bin

2) Install py4web by pip.

./pip3 install py4web
./python3 -c "from pydal.validators import CRYPT; 
open('/opt/py4web/password.txt','w').write(str(CRYPT()(input('password:'))[0]))"

Test if it is working:

./py4web-start /opt/py4web -p /opt/py4web/password.txt

3) Create a new PyDev project for the whole py4web apps directory:

Start Eclipse, create a new PyDev project with the source directory /opt/py4web 


Define the interpreter /opt/python3env/py4web/bin/python3 for the project; 
in its definition at first add the system libraries:

/opt/python3env/py4web/lib/python3.7 
/opt/python3env/py4web/lib/python3.7/lib-dynload 
/opt/python3env/py4web/lib/python3.7/site-packages

As a result, PyDev complained: "It seems that the Python /Lib folder (which 
contains the standard library) was not found /selected during the instal 
process. This folder (which contains files such as threading.py and 
traceback.py) is required for PyDev to function properly ...". To solve it, 
at first I tried symlinking the mentioned files:

ln -s /usr/lib/python3.7/threading.py 
/opt/python3env/py4web/lib/threading.py
ln -s /usr/lib/python3.7/traceback.py 
/opt/python3env/py4web/lib/traceback.py

The complaint has disappeared and I have not noticed any other apparent 
problems. However, to be sure that everything needed is available, later I 
added the whole /usr/lib/python3.7 in libraries instead of the symlinked 
files.
Because only system libraries are imported and not site-packages, hopefully 
this second solution won't break the virtualenv separation from the system 
environment.

4) Enable launching py4web from Eclipse:

Copy web4py starting script to the apps directory:

cp /opt/python3env/py4web/bin/py4web-start /opt/py4web/py4web-start.py

Define new run configuration for py4web-start.py with the arguments 
"/opt/py4web 
-p /opt/py4web/password.txt".

Now I can start py4web from Eclipse and read its output in the Eclipse 
console.

5) PyDev Debugging:

However, for now, I got stuck in making the PyDev debugger working. It 
complains:

pydev debugger: starting (pid: 27370)
Traceback (most recent call last):
  File "", line 983, in _find_and_load
  File "", line 967, in _find_and_load_unlocked
  File "", line 677, in _load_unlocked
  File "", line 728, in exec_module
  File "", line 219, in 
_call_with_frames_removed
  File 
"/opt/python3env/py4web/lib/python3.7/site-packages/py4web/__init__.py", 
line 1, in 
from . core import (
  File "", line 983, in _find_and_load
  File "", line 152, in __exit__
  File "", line 107, in release
RuntimeError: cannot release un-acquired lock

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "", line 983, in _find_and_load
  File "", line 953, in _find_and_load_unlocked
  File "", line 219, in 
_call_with_frames_removed
  File "", line 983, in _find_and_load
  File "", line 152, in __exit__
  File "", line 107, in release
RuntimeError: cannot release un-acquired lock

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File 
"/home/zejdad/.p2/pool/plugins/org.python.pydev.core_7.4.0.201910251334/pysrc/pydevd.py",
 
line 3090, in 
main()
  File 
"/home/zejdad/.p2/pool/plugins/org.python.pydev.core_7.4.0.201910251334/pysrc/pydevd.py",
 
line 3083, in main
globals = debugger.run(setup['file'], None, None, is_module)
  File 
"/home/zejdad/.p2/pool/plugins/org.python.pydev.core_7.4.0.201910251334/pysrc/pydevd.py",
 
line 2154, in run
return self._exec(is_module, entry_point_fn, module_name, file, 
globals, locals)
  File 
"/home/zejdad/.p2/pool/plugins/org.python.pydev.core_7.4.0.201910251334/pysrc/pydevd.py",
 
line 2161, in _exec
pydev_imports.execfile(file, globals, locals)  # execute the script
  File 
"/home/zejdad/.p2/pool/plugins/org.python.pydev.core_7.4.0.201910251334/pysrc/_pydev_imps/_pydev_execfile.py",
 
line 25, in execfile
exec(compile(contents+"\n", file, 'exec'), glob, loc)
  File "/opt/py4web/py4web-start.py", line 3, in 
from py4web.core import main
  File "", line 983, in _find_and_load
  File "", line 152, in __exit__
  File "", line 107, in release
RuntimeError: cannot release un-acquired lock

With regards,
David

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report 

[web2py] how to specify python3 for wsgihandler

2019-11-11 Thread David Zejda
Hello to all.

I have a web2py with several apps on a production server behind Apache 
accessed via wsgihandler. So far, all the apps have been developed for 
python2.

To support python3 apps (preferred for new projects), I set-up a separate 
web2py directory and adjusted the Apache configs respectively.

The question is - how to set this new web2py instance to run on python3?

For compatibility reasons, /usr/bin/env python still translates to python 2 
interpreter. 

Do I have to change all the #!/usr/bin/env python lines in web2py sources 
to point to python3 instead? 
Or where else can I specify the python version? 

Thank you very much for an answer in advance!

David

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/web2py/633956c2-9522-4d56-9bf0-7ec9a467881c%40googlegroups.com.


[web2py] Re: query to match if boolean field is not True

2018-02-12 Thread David Zejda

On Sunday, 11 February 2018 05:52:44 UTC+1, Massimo Di Pierro wrote:
>
> I would expect that too but it is not a web2py issue. It is a database 
> issue. web2py simply translate those in
>

Hi Massimo, thank you for explanation!

David

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[web2py] query to match if boolean field is not True

2018-02-06 Thread David Zejda
Hi :)

Intuitively I would expect that these queries are equivalent ways to match 
if boolean_field is not True:

~(db.mytable.boolean_field == True)

(db.mytable.boolean_field != True)

((db.mytable.boolean_field == None) | (db.mytable.boolean_field == False))

But only the last one works as expected.

David

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[web2py] Re: web2py behind Apache with virtualhosts and SSL (SNI) leads to SSL_ERROR_RX_RECORD_TOO_LONG

2018-02-03 Thread David Zejda
Hi I found it. 

There was another host config in my setup with such a redirect:


  ServerName domainxx.com
  RedirectMatch permanent (.*) http://www.otherdomain.com$1


When I changed it to:


  ServerName domainxx.com
  RedirectMatch permanent (.*) http://www.otherdomain.com$1


other domains' SSL started working normally. :)

What initially confused me, that the problem appeared only for sites served 
by web2py. But I must admit that the problem really lied in the config. 
Truly, redirecting both HTTP and HTTPS requests to a HTTP site was not a 
bright idea.

David

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[web2py] Re: IMPORTANT - WEB2PY CONSULTING

2018-02-02 Thread David Zejda
Hi, 

If you can, please list Open-IT cz, s.r.o. (Czech Republic) as well.

Main website is https://www.o-it.info made in Zope. Though it should be 
replaced with something fresher. But, IMO, it is not as ugly that it could 
not be listed..

We have a plenty of web2py-based projects, such as:

http://www.englishlife.cz/
http://www.englishspace.cz/
http://www.englishanywhere.cz/
http://gjs.englishanywhere.cz/
http://lc.o-it.info/
http://www.netlektor.cz/

And we also offer web2py hosting:

http://www.o-it.info/weby/webhosting/web2py-hosting

Thank you in advance :)
D.

On Sunday, 15 February 2015 23:21:36 UTC+1, Massimo Di Pierro wrote:
>
> We need to update the list of companies that provide web2py consulting.
> This list is obsolete:
>
> http://web2py.com/init/default/support
>
> Some links are broke. Most pages do not even mention web2py. Some of them 
> have a design that is simply not acceptable for a web development company.
>
> That list will be eliminated. IF YOU WANT TO BE LISTED please update your 
> page to have a decent design and MENTION WEB2PY on the main site. Then 
> respond to this thread by providing an updated link and the country were 
> you incorporated. If you have a self-employed individual list your country 
> of residence.
>
>

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[web2py] web2py behind Apache with virtualhosts and SSL (SNI) leads to SSL_ERROR_RX_RECORD_TOO_LONG

2018-02-02 Thread David Zejda
Hi :)

I am having troubles with web2py behind Apache with multiple SSL 
virtualhosts, each serving different web2py application and encrypted with 
a different letsencrypt SSL key. All are served from the same IP address. I 
have only one web2py instance in my setup.
If I set-up up to 3 VirtualHosts (serving 3 applications), it works. But as 
soon as I add more applications in my setup, all HTTPS end up in 
SSL_ERROR_RX_RECORD_TOO_LONG.

Versions: Web2py 2.16.1, Apache 2.4.10, libapache2-mod-wsgi 4.3.0-1 (Debian 
Jessie)

My config follows; to make it concise I removed the portions dealing with 
static files, logging etc. which are not related to the problem:




  ServerName $domain
  WSGIDaemonProcess $domain user=www-data group=www-data 
display-name=%{GROUP} 
  WSGIScriptAlias / /opt/web2py/wsgihandler.py
  WSGIProcessGroup $domain

  
Require all denied
  

  
Require all denied
  

  
AllowOverride None
Require all denied

  Require all granted

  





  SSLEngine on
  SSLCertificateFile /etc/apache2/ssl/letsencrypt/$domain/fullchain.pem
  SSLCertificateKeyFile /etc/apache2/ssl/letsencrypt/$domain/privkey.pem

  ServerName $domain

  WSGIScriptAlias / /opt/web2py/wsgihandler.py
  WSGIProcessGroup $domain
  WSGIPassAuthorization On

  
AllowOverride None
Require all denied

  Require all granted

  






And one-liners in sites-enabled:

Use Web2PySSL www.domain1.com

Use Web2PySSL www.domain2.com

Use Web2PySSL www.domain3.com
...

SSL certificates are symlinked to /etc/apache2/ssl/letsencrypt.

routes.py:

routers = dict(
BASE=dict(
domains = {
  'www.domain1.com' : 'domain1',
  'www.domain3.com' : 'domain2',
  'www.domain3.com' : 'domain3',
  #...
}
),
)

I made several experiments to help to identify the cause. 

1) Instead of domain-specific letsencrypt certificates I tried one 
self-signed certificate for all domains. It increased the number of 
applications which work in my scenario from 3 to 5, but as soon as I add 
one more, it starts failing again. I think the main difference of the 
self-signed certificate in the context of the error is that it does not 
have any chain.

2) In order to find out if it is not a problem of Apache, I tried to set-up 
plain Apache virtualhosts with SSL support. It works. There are no problems 
with SSL at all, regardless to the number of virtualhosts.




  ServerName $domain
  DocumentRoot /var/www
  
Options FollowSymLinks
AllowOverride None
  
  
Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
allow from all
  
  ErrorLog ${APACHE_LOG_DIR}/error.log
  LogLevel warn
  CustomLog ${APACHE_LOG_DIR}/access.log combined



  ServerName $domain
  SSLEngine on
  SSLCertificateFile /etc/apache2/ssl/letsencrypt/$domain/fullchain.pem
  SSLCertificateKeyFile /etc/apache2/ssl/letsencrypt/$domain/privkey.pem
  DocumentRoot /var/www
  
Options FollowSymLinks
AllowOverride None
  
  
Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
allow from all
  
  ErrorLog ${APACHE_LOG_DIR}/error.log
  LogLevel warn
  CustomLog ${APACHE_LOG_DIR}/access.log combined




And:

Use testSSL www.domain1.com

Use testSSL www.domain2.com

Use testSSL www.domain3.com

...

3) In order to find out if it is not a problem of mod-wsgi, I tried the 
following. Again, no problems. Both HTTP and HTTPS is working well.

Simple WSGI handler in /var/www/wsgi/test.wsgi:

def application(environ, start_response):
status = '200 OK'
output = 'Just testing...'
response_headers = [('Content-type', 'text/plain'),('Content-Length', 
str(len(output)))]
start_response(status, response_headers)
return [output]



And related config:




  ServerName $domain

  WSGIDaemonProcess $domain user=www-data group=www-data 
display-name=%{GROUP} 
  WSGIScriptAlias / /var/www/wsgi/test.wsgi
  WSGIProcessGroup $domain

  DocumentRoot /var/www
  
Options FollowSymLinks
AllowOverride None
  
  
Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
allow from all
  
  ErrorLog ${APACHE_LOG_DIR}/error.log
  LogLevel warn
  CustomLog ${APACHE_LOG_DIR}/access.log combined




  ServerName $domain

  SSLEngine on
  SSLCertificateFile /etc/apache2/ssl/letsencrypt/$domain/fullchain.pem
  SSLCertificateKeyFile /etc/apache2/ssl/letsencrypt/$domain/privkey.pem

  WSGIScriptAlias / /var/www/wsgi/test.wsgi
  WSGIProcessGroup $domain

  DocumentRoot /var/www
  
Options FollowSymLinks
AllowOverride None
  
  
Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
allow from all
  
  ErrorLog ${APACHE_LOG_DIR}/error.log
  LogLevel warn
  CustomLog ${APACHE_LOG_DIR}/access.log combined





And:

Use testSSLWSGI www.domain1.com

Use testSSLWSGI www.domain2.com

Use testSSLWSGI www.domain3.com
...

So, my conclusion is 

Re: [web2py] response.render in controller raises NameError

2015-07-25 Thread David Zejda

I see. Thank you for your help!

David

On 22.7.2015 19:16, Anthony wrote:

It has nothing to do with WSGI. Now that I look back at the code, I
see that run_view_in() simply looks for a compiled folder, and if
it exists, it assumes all views are compiled. That means if any part
of the app is compiled, even a single non-compiled view will lead to
this error (which is why I had submitted that patch).

As a workaround, I believe you can set response.view to an open file
object:

response.view = open(os.path.join(response.folder, views,
response.view), 'rb')

Or you can go back to calling gluon.template.render directly, though
in that case, you should set context=globals() to ensure the full
view environment (including the web2py API) is available.

Anthony



--
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups web2py-users group.

To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [web2py] response.render in controller raises NameError

2015-07-22 Thread David Zejda

Thank you, Anthony!

I deploy the app using commandline script which packs the application 
sources, uploads them on server and calls a server-side script which 
compiles the app.


So, on the server side in the application folder I have standard 
directory structure - source files in 'models', 'controllers', 'views', 
and the compiled version in the 'compiled' subfolder.


But it seems to me, that WSGI can work only with compiled files, not 
with the sources.


Regarding your patch - IMO compilation gives sense even if the whole app 
can't be packed compiled (performance). It could even allow mixed 
packing - add compiled files for all compilable content and sources for 
the remaining noncompilable views.


David

On 22.7.2015 15:44, Anthony wrote:

Probably you chose Pack compiled in admin, which packs only the
compiled models, controllers, and views. If you didn't compile the
views, then your packed app will have no views. Instead, choose Pack
custom, and be sure to include the /views folder.

A while back, I submitted a patch that would allow you to compile the
whole app, even if some particular views could not be compiled. In
that case, you could still benefit from compiling most of the views.
However, the patch was never applied. If this is of interest to you,
maybe submit an issue on Github and link to
https://groups.google.com/d/msg/web2py-developers/GhvqakUaujA/iTj0_uP76XcJ.

 Anthony



--
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups web2py-users group.

To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [web2py] response.render in controller raises NameError

2015-07-22 Thread David Zejda

Hi, Anthony,

thank you for explaining the meaning of the 'context' argument. It works 
now as expected.


The suggested approach with variable in extend is neater. It works well 
in my development environment. But in the production environment I use 
web2py behind Apache through WSGI. If I compile_models, 
compile_controllers instead of compile_application, it leads to
invalid view (default/index.html) error. Is it true, that {{extend 
variable}} can't be used in combination WSGI, since whole app has to be 
compiled?


David

On 21.7.2015 22:32, Anthony wrote:

Your context is an empty dict, so the template doesn't see any of the
usual globals.

Anyway, this approach is unnecessary. The argument to extend can be a
Python expression, do just use the extendtempl variable in the extend
statement in the view. The only drawback is that you won't be able to
compile this particular view, but you couldn't do that with your
approach either.

Anthony



--
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups web2py-users group.

To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[web2py] response.render in controller raises NameError

2015-07-21 Thread David Zejda

Hi :)

I would like to run one app on more domains and allow users to apply 
per-domain specific skins. E.g. default/index.html should be extending 
layout_xyz.html for domain xyz.com, but layout_abc.html for domain abc.com.


As covered in the documentation, conditional {{extend}} does not work.

So, as an alternative, I tried to remove {{extend}} from 
fuction-specific view files (e.g. default/index.html) completely, add 
{{extend}} programmatically in the controller, such as:


fpath = request.folder+'views/'
extendtempl = 'layout_xyz.html'
myfile = open(fpath+fname, r)
content={{extend '%s'}}\n % extendtempl + myfile.read()
myfile.close()
from gluon.template import render
return render(content=content, context=dict(), path=fpath)

But it raises an error:

return render(content=content, context=dict(), path=fpath)
  File /opt/web2py/gluon/template.py, line 906, in render
exec(code) in context
  File string, line 2, in module
  NameError: name 'request' is not defined

The error refers to the very beginning of template.py:

if False:
from gluon import db, auth, crud
from gluon import *
request = current.request

Please, is there a different (proper) way to call view rendering 
directly from a controller?


Relevant threads:

https://groups.google.com/forum/#!topic/web2py/AjefSkUoe5g
https://groups.google.com/forum/#!msg/web2py/iG48JpZj9d4/FzwBrUMCbKcJ
https://groups.google.com/forum/?fromgroups=#!topic/web2py/yBBhvADGGB4[1-25]

Thank you!
David

--
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups web2py-users group.

To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[web2py] Apache virtual hosts http and https correct WSGI setup?

2014-06-16 Thread David Zejda

Hello :)

I am experiencing an issue when I try to log-in through http, then 
through https behind Apache using WSGI.


Web2py Version 2.9.5-stable+timestamp.2014.03.16.02.35.39
Python 2.7.3: /usr/bin/python (prefix: /usr)

Traceback (most recent call last):
  File /opt/web2py/gluon/main.py, line 457, in wsgibase
session._try_store_in_db(request, response)
  File /opt/web2py/gluon/globals.py, line 1089, in _try_store_in_db
(self._unchanged(response) and not response.session_new)):
  File /opt/web2py/gluon/globals.py, line 1078, in _unchanged
session_pickled = cPickle.dumps(self)
  File /usr/lib/python2.7/copy_reg.py, line 84, in _reduce_ex
dict = getstate()
TypeError: 'NoneType' object is not callable

After apache restart it works fine.

Seems to be related to these:

https://code.google.com/p/web2py/issues/detail?id=1438#makechanges
https://groups.google.com/forum/#!topic/web2py/jkqyPM5_zaE
https://groups.google.com/forum/#!msg/web2py/2SLPllKa-qQ/E_a55n5iGTMJ

My setup is:

1. One WSGIDaemonProcess for the whole apache server:

WSGIDaemonProcess web2py user=www-data group=www-data display-name=%{GROUP}

2. SSL config for the whole server - mainly for the purpose of accessing 
web2py admin interface:


VirtualHost *:443
  SSLEngine on
  SSLCertificateFile /etc/apache2/ssl/self_signed.cert
  SSLCertificateKeyFile /etc/apache2/ssl/self_signed.key

  WSGIProcessGroup web2py
  WSGIScriptAlias / /opt/web2py/wsgihandler.py

  Directory /opt/web2py
AllowOverride None
Order Allow,Deny
Deny from all
Files wsgihandler.py
  Allow from all
/Files
  /Directory

  AliasMatch ^/([^/]+)/static/(?:_[\d]+.[\d]+.[\d]+/)?(.*) 
/opt/web2py/applications/$1/static/$2

  Directory /opt/web2py/applications/*/static/
Order Allow,Deny
Allow from all
  /Directory

  CustomLog /var/log/apache2/access-ssl.log common
  ErrorLog /var/log/apache2/error-ssl.log
/VirtualHost

3. Macro:

Macro Web2Py $domain
  ServerName $domain

  WSGIProcessGroup web2py
  WSGIScriptAlias / /opt/web2py/wsgihandler.py

  Directory /opt/web2py
AllowOverride None
Order Allow,Deny
Deny from all
Files wsgihandler.py
  Allow from all
/Files
  /Directory

  AliasMatch ^/([^/]+)/static/(?:_[\d]+.[\d]+.[\d]+/)?(.*) 
/opt/web2py/applications/$1/static/$2

  Directory /opt/web2py/applications/*/static/
Options -Indexes
Order Allow,Deny
Allow from all
  /Directory

  Location /admin
Deny from all
  /Location

  LocationMatch ^/([^/]+)/appadmin
Deny from all
  /LocationMatch

  CustomLog /var/log/apache2/$domain.log common
  ErrorLog /var/log/apache2/$domain-error.log
/Macro

4. Virtual hosts (in separate files):

# firstdomain.com
VirtualHost *:80
  ServerName firstdomain.com
  RedirectMatch permanent (.*) http://www.firstdomain.com$1
/VirtualHost

VirtualHost *:80
  Use Web2Py www.firstdomain.com
/VirtualHost

# my.mywebserver.com
VirtualHost *:80
  Use Web2Py my.mywebserver.com
/VirtualHost

4. Routes in web2py:

routers = dict(
BASE=dict(
domains = {
  'www.firstdomain.com' : 'firstapp',
  'my.mywebserver.com' : 'myapp',
}
),
)

A workaround is suggested at the end of the thread:

https://groups.google.com/forum/#!topic/web2py/jkqyPM5_zaE

Anyway i use different WSGIDaemonProcess on https and http and problem 
solve.


So, I have changed in Macro:

WSGIProcessGroup web2py

to

WSGIDaemonProcess $domain user=www-data group=www-data display-name=%{GROUP}
WSGIProcessGroup $domain

and the problem seems to be solved. But is it really correct to use 
different WSGIDaemonProcess for the same web2py instance?


Graham Dumpleton here:

https://groups.google.com/forum/#!topic/modwsgi/URpyQXl5d8g

lists several potential problems related to a configuration with 
separate WSGIDaemonProcess, such as leakage of data between sub 
interpreters. He suggests:


Overall, the safest thing to do is to have each distinct web
application instance delegated to its own daemon process group, with
it being forced to run in %{GLOBAL} application group of that daemon
process group. The %{GLOBAL} here means force it to run in the main
(first created) Python interpreter within the process. This is
equivalent to the interpreter environment which is used by command
line Python and so all C extension modules should work in that.

Please, is there anyone with the necessary inside to provide correct 
instructions how to set-up multiple virtual hosts with SSL, all served 
by one web2py instance behind Apache correctly? It would be great to 
include the instructions in the web2py book, because IMO such config is 
likely to be quite common. :)


Thanks in advance!
David

--
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups web2py-users group.

To unsubscribe from 

[web2py] ImportError: cannot import name PickleableStorage after upgrading to 1.99.7

2012-04-12 Thread David Zejda
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

After upgrade to 1.99.7. I started receiving this error:

Traceback (most recent call last):
  File /opt/web2py/gluon/restricted.py, line 194, in restricted
in code it raises a RestrictedError containing the traceback. layer is
  File /opt/web2py/applications/trom/compiled/models/menu.py, line 3,
in module
  File /opt/web2py/gluon/custom_import.py, line 294, in __call__
#except Exception, e:
  File /opt/web2py/gluon/custom_import.py, line 78, in __call__
level)
  File /opt/web2py/gluon/tools.py, line 28, in module
from storage import Storage, PickleableStorage, StorageList,
Settings, Messages
ImportError: cannot import name PickleableStorage

The error disappeared when I removed PickleableStorage from import in tools.

D.
-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.10 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAk+GdpQACgkQ3oCkkciamVGuJwCffvSARB7XLeCvNdFqWr5tz/Ag
19IAoINWjF4MNIEVBpRU8+8xsMXEAR+c
=jk/I
-END PGP SIGNATURE-


Re: [web2py] Re: Memory leak - followup

2011-01-04 Thread David Zejda
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

Hi :)

Yes, I am really sure. This is exact code of my controller.

def load_pers():

class Blah():
def __init__(self):
pass

def blah2():
return Blah()

p = cache.ram('blahblah',blah2,time_expire=30)

return dict(p=BEAUTIFY(p))

and this has the same effect:

def load_pers():

class Blah():
def __init__(self):
pass

p = cache.ram('blahblah',Blah,time_expire=30)

return dict(p=BEAUTIFY(p))

Simply, if I store an object declared in controller or model in cache
(regardless of db involvement), whole db model is being duplicated in
RAM, which is really unwanted behaviour.

As I mentioned in one of previous messages, I have strong suspiction
that the issue is related to another one discussed here:

http://www.mail-archive.com/web2py@googlegroups.com/msg34333.html

D.

mdipierro wrote:
 Sorry. I got confused too. You say this leads to the leak:
 
 class Blah():
 def __init__(self):
 pass
 def blah2():
 return Blah()
 p = cache.ram('blahblah',blah2,time_expire=30)
 
 so there is o db involved? Are you sure 'blahblah' is a constant in
 your code and not a variable? Is this the exact code you are running?
 
 
 On Jan 3, 5:42 pm, David Zejda d...@atlas.cz wrote:
 Hello Massimo,
 
 sorry, but I really do not understand. :-|
 
 How do I store whole record if the only thing I'm trying to store is
 instance of a dummy class? In the last example with empty __init__ there
 is no record involved at all!
 
 If I do exactly what Michele suggested:
 
 class Blah():
 def __init__(self):
 self.nick = db.person[1].nick
 
 def blah_f():
 return Blah()
 
 p = cache.ram('blahblah', blah_f,time_expire=30)
 
 result is the same, of course.
 
 David

- --
David Zejda, Open-IT cz
web development  services
http://www.o-it.info
-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.9 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iEYEARECAAYFAk0i3rUACgkQ3oCkkciamVEz2wCdGXIgszz1wjDCR6/gHMOSqpda
T+QAnjbShkt47zF8D1NLzrjm0zrXEyTL
=88aY
-END PGP SIGNATURE-


Re: [web2py] Re: Memory leak - followup

2011-01-04 Thread David Zejda
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

Whenever in controller/model is the class declared, the same result.

Michele Comitini wrote:
 Try to put the Blah class in the global scope of the controller.  Do
 you get same result?

- --
David Zejda, Open-IT cz
web development  services
http://www.o-it.info
-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.9 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iEYEARECAAYFAk0jOaoACgkQ3oCkkciamVH++gCgpR/w98HwRVUgTqOpCbj+/ITE
LrwAn3b34zURtjOXDb3rXIsX3bwDXc4v
=2l85
-END PGP SIGNATURE-


Re: [web2py] Re: Memory leak - followup

2011-01-04 Thread David Zejda
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

Hi :)

You may check the issue even with the default simple application created
by web admin. Simply add this to the default controller:

class Blah():
def __init__(self):
pass

def blahstuff():
p = cache.ram('blahblah',Blah,time_expire=30)
return dict(p=BEAUTIFY(p))

def guppy():
from guppy import hpy
h = hpy()
label='h.heap()'
form = FORM(LABEL(Guppy code: ),INPUT(_name=code, _size='35',
_value=label),INPUT(_type=submit, _value=Execute..))
if form.accepts(request.vars, session):
heap = eval(request.vars.code)
label = request.vars.code
else:
heap = h.heap()
fullstack = h.heap().parts
return dict(heap=PRE(heap), fullstack=PRE(BEAUTIFY(fullstack)),
label=label, form=form)

If you visit heapy() first time, the results contains:

Partition of a set of 24 objects. Total size = 80448 bytes.
 Index  Count   % Size   % Cumulative  % Kind (class / dict of class)
 0 24 10080448 100 80448 100 dict of gluon.dal.Field

Once you run blahstuff(), heapy() reports:

Partition of a set of 48 objects. Total size = 160896 bytes.
 Index  Count   % Size   % Cumulative  % Kind (class / dict of class)
 0 48 100   160896 100160896 100 dict of gluon.dal.Field

David

mdipierro wrote:
 can you show us the guppy stats before and after caching? without
 caching any db object?
 can you also email me the entire app code?
 
 On Jan 4, 9:15 am, David Zejda d...@atlas.cz wrote:
 Whenever in controller/model is the class declared, the same result.
 
 Michele Comitini wrote:
 Try to put the Blah class in the global scope of the controller.  Do
 you get same result?

- --
David Zejda, Open-IT cz
web development  services
http://www.o-it.info
-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.9 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iEYEARECAAYFAk0jYp0ACgkQ3oCkkciamVEyngCfeFLsLcFyo3+97O0wc0w/cbPM
oI8AoLY5t0URVVk2+ehOFomsMAjZzlyv
=0hmM
-END PGP SIGNATURE-


Re: [web2py] Re: Memory leak - followup

2011-01-04 Thread David Zejda
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

 Let' move this discussion to web2py-developers. If you are not already
 there, please join.

OK, the discussion continues there:

http://groups.google.com/group/web2py-developers/t/136534ec35b48af8

and this is relevant issue:

https://code.google.com/p/web2py/issues/detail?id=146

David

- --
David Zejda, Open-IT cz
web development  services
http://www.o-it.info
-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.9 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iEYEARECAAYFAk0jvOsACgkQ3oCkkciamVFe5gCgqT2vUFPNcJptDrwNAVhk7FYt
nEcAnR0UEjp0JRCsrl4AXRt+lVmzOAVB
=jJDx
-END PGP SIGNATURE-


Re: [web2py] Re: Memory leak - followup

2011-01-03 Thread David Zejda
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

Hi,

nick is not reference field. To make it sure that the issue is not
dependent on the field definition I checked it with as simple Field as
possible:

Field('trustworthiness', 'double', default=0),

defined in my model and added conversion to str:

class Blah():
def __init__(self):
self.nick = str(db.person[1].trustworthiness)

p = cache.ram('blahblah',Blah,time_expire=30)

Also,

def blah_f():
 return Blah()

makes no change, leads to the same leak.

The leak appears regardless to the place of the declaration of Blah
class. I tried to declare it in top level of model, in controller, and
inside function of controller, no difference.

It is possible that this IMO weird behaviour is related to another issue
which teased me months ago:

http://www.mail-archive.com/web2py@googlegroups.com/msg34333.html

With regards,
David

mdipierro wrote:
 It depends on whether nick is a reference field.
 
 
 On Jan 2, 5:31 pm, Michele Comitini michele.comit...@gmail.com
 wrote:
 what if you do this?

 class Blah():
 def __init__(self):
 self.nick = db.person[1].nick

 def blah_f():
 return Blah()

  p = cache.ram('blahblah', blah_f,time_expire=30)

 2011/1/2 David Zejda d...@atlas.cz:



- --
David Zejda, Open-IT cz
web development  services
http://www.o-it.info
-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.9 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iEYEARECAAYFAk0hoyEACgkQ3oCkkciamVGE0gCfROfrJo7SaeDxIbPco58LHzt9
mesAoK9JfcQKnGyAlkKfoeqIGKLJ812Z
=IBqT
-END PGP SIGNATURE-


Re: [web2py] Re: Memory leak - followup

2011-01-03 Thread David Zejda
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

Dear Massimo,

thank you for the reply, but Michele's advice makes no difference.

I just noticed that even this one leads to the leak:

class Blah():
def __init__(self):
pass

def blah2():
return Blah()

p = cache.ram('blahblah',blah2,time_expire=30)

Since I avoid storing objects of classes declared in model or
controllers I do not have problems. But still I do not understand why
when I store such object in cache, whole copy of db model goes into
memory. IMO if there is no solution for the behaviour, at least the
danger should be emphasized in cache docs, because I doubt that anybody
would anticipate it.

Wising you a nice day!
David

mdipierro wrote:
 yes but you are not following Michele's advice. If you cache a record
 or a an object like a reference, you are storing in ram of copy db
 (the leak). You should cache values or dictionaries. As long as those
 values are not reference fields there should be no leaks.
 
 I am not sure the term leak is appropriate here. When you cache you
 store something and storage takes space, until you clear cache. The
 bigger the object you cache, the more space it takes.
 
 On Jan 3, 4:21 am, David Zejda d...@atlas.cz wrote:
 Hi,
 
 nick is not reference field. To make it sure that the issue is not
 dependent on the field definition I checked it with as simple Field as
 possible:
 
 Field('trustworthiness', 'double', default=0),
 
 defined in my model and added conversion to str:
 
 class Blah():
 def __init__(self):
 self.nick = str(db.person[1].trustworthiness)
 
 p = cache.ram('blahblah',Blah,time_expire=30)
 
 Also,
 
 def blah_f():
  return Blah()
 
 makes no change, leads to the same leak.
 
 The leak appears regardless to the place of the declaration of Blah
 class. I tried to declare it in top level of model, in controller, and
 inside function of controller, no difference.
 
 It is possible that this IMO weird behaviour is related to another issue
 which teased me months ago:
 
 http://www.mail-archive.com/web2py@googlegroups.com/msg34333.html
 
 With regards,
 David
 
 
 
 mdipierro wrote:
 It depends on whether nick is a reference field.
 On Jan 2, 5:31 pm, Michele Comitini michele.comit...@gmail.com
 wrote:
 what if you do this?
 class Blah():
 def __init__(self):
 self.nick = db.person[1].nick
 def blah_f():
 return Blah()
  p = cache.ram('blahblah', blah_f,time_expire=30)
 2011/1/2 David Zejda d...@atlas.cz:

- --
David Zejda, Open-IT cz
web development  services
http://www.o-it.info
-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.9 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iEYEARECAAYFAk0iE/4ACgkQ3oCkkciamVHfNwCdFkpF3okgulfxi7qV1EZA0P1/
VhAAn0Rd3EXTwwn+fttzIvc83K8ri8bK
=3lwE
-END PGP SIGNATURE-


Re: [web2py] Re: Memory leak - followup

2011-01-03 Thread David Zejda
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

Hello Massimo,

sorry, but I really do not understand. :-|

How do I store whole record if the only thing I'm trying to store is
instance of a dummy class? In the last example with empty __init__ there
is no record involved at all!

If I do exactly what Michele suggested:

class Blah():
def __init__(self):
self.nick = db.person[1].nick

def blah_f():
return Blah()

p = cache.ram('blahblah', blah_f,time_expire=30)

result is the same, of course.

David

mdipierro wrote:
 This is not what Michele suggested. You are still storing the entire
 record.
 
 On Jan 3, 12:22 pm, David Zejda d...@atlas.cz wrote:
 Dear Massimo,
 
 thank you for the reply, but Michele's advice makes no difference.
 
 I just noticed that even this one leads to the leak:
 
 class Blah():
 def __init__(self):
 pass
 
 def blah2():
 return Blah()
 
 p = cache.ram('blahblah',blah2,time_expire=30)
 
 Since I avoid storing objects of classes declared in model or
 controllers I do not have problems. But still I do not understand why
 when I store such object in cache, whole copy of db model goes into
 memory. IMO if there is no solution for the behaviour, at least the
 danger should be emphasized in cache docs, because I doubt that anybody
 would anticipate it.
 
 Wising you a nice day!
 David
 
 
 
 mdipierro wrote:
 yes but you are not following Michele's advice. If you cache a record
 or a an object like a reference, you are storing in ram of copy db
 (the leak). You should cache values or dictionaries. As long as those
 values are not reference fields there should be no leaks.
 I am not sure the term leak is appropriate here. When you cache you
 store something and storage takes space, until you clear cache. The
 bigger the object you cache, the more space it takes.
 On Jan 3, 4:21 am, David Zejda d...@atlas.cz wrote:
 Hi,
 nick is not reference field. To make it sure that the issue is not
 dependent on the field definition I checked it with as simple Field as
 possible:
 Field('trustworthiness', 'double', default=0),
 defined in my model and added conversion to str:
 class Blah():
 def __init__(self):
 self.nick = str(db.person[1].trustworthiness)
 p = cache.ram('blahblah',Blah,time_expire=30)
 Also,
 def blah_f():
  return Blah()
 makes no change, leads to the same leak.
 The leak appears regardless to the place of the declaration of Blah
 class. I tried to declare it in top level of model, in controller, and
 inside function of controller, no difference.
 It is possible that this IMO weird behaviour is related to another issue
 which teased me months ago:
 http://www.mail-archive.com/web2py@googlegroups.com/msg34333.html
 With regards,
 David
 mdipierro wrote:
 It depends on whether nick is a reference field.
 On Jan 2, 5:31 pm, Michele Comitini michele.comit...@gmail.com
 wrote:
 what if you do this?
 class Blah():
 def __init__(self):
 self.nick = db.person[1].nick
 def blah_f():
 return Blah()
  p = cache.ram('blahblah', blah_f,time_expire=30)
 2011/1/2 David Zejda d...@atlas.cz:

- --
David Zejda, Open-IT cz
web development  services
http://www.o-it.info
-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.9 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iEYEARECAAYFAk0iXskACgkQ3oCkkciamVHYZgCdFltRuwqLh1y3NPmS45VxNfnh
9iUAniwUeoXlSbtCniEnc99Q0sKzIm9+
=SRTR
-END PGP SIGNATURE-


[web2py] Memory leak - followup

2011-01-02 Thread David Zejda
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

Finally I had enough time to find out, where is the main root of my
memory leak.

Consider two scenarios:

1. start web2py server

2. execute controller function with contents:

def blah():
return Storage(dict(nick=db.person[1].nick))

p = cache.ram('blahblah',blah,time_expire=30)

3. guppy stats:

Partition of a set of 119902 objects. Total size = 17240104 bytes.
 Index  Count   % Size   % Cumulative  % Kind (class / dict of class)
 0  64658  54  5946560  34   5946560  34 str
 1  24649  21  2172768  13   8119328  47 tuple
 2624   1  2091648  12  10210976  59 dict of gluon.dal.Field
 3706   1   888112   5  11099088  64 dict (no owner)
 4282   0   876912   5  11976000  69 dict of module
 5   6701   6   804120   5  12780120  74 types.CodeType
 6   6359   5   763080   4  13543200  79 function
 7652   1   571680   3  14114880  82 type
 8652   1   501280   3  14616160  85 dict of type
 9451   0   454984   3  15071144  87 dict of class
342 more rows. Type e.g. '_.more' to view.


1. start web2py server

2. execute controller function with contents (nick is plain string):

class Blah():
def __init__(self):
self.nick = db.person[1].nick

p = cache.ram('blahblah',Blah,time_expire=30)

3. guppy stats:

Partition of a set of 13 objects. Total size = 21017568 bytes.
 Index  Count   % Size   % Cumulative  % Kind (class / dict of class)
 0  69722  53  6343688  30   6343688  30 str
 1   1248   1  4183296  20  10526984  50 dict of gluon.dal.Field
 2  26193  20  2334008  11  12860992  61 tuple
 3756   1   987360   5  13848352  66 dict (no owner)
 4282   0   876912   4  14725264  70 dict of module
 5   7056   5   846720   4  15571984  74 types.CodeType
 6   6686   5   802320   4  16374304  78 function
 7654   0   573440   3  16947744  81 type
 8654   0   501840   2  17449584  83 dict of type
 9459   0   471048   2  17920632  85 dict of class
356 more rows. Type e.g. '_.more' to view.

Please, look at dict of gluon.dal.Field. In the second scenario the
count is doubled, which means that db model remains in the memory twice,
which is bad.

I did not try the same with simplier model, so I do not have idea
whether it matters.

In my case it will not be too difficult to replace my own classes with
dicts or Storages, but maybe the findings will help somebody else facing
similar leak..

Nice year to all :)
David

- --
David Zejda, Open-IT cz
web development  services
http://www.o-it.info
-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.9 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iEYEARECAAYFAk0gqW4ACgkQ3oCkkciamVH0JACfWPEaSQX+7/OqeGeWNhtJr4/R
JzwAn3Z17zjKv93dxjDTuM2KorzI6LB/
=OKMq
-END PGP SIGNATURE-


Re: [web2py] Re: memory leak - model remains in memory after requests

2010-12-27 Thread David Zejda
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

I think you are right. It is highly probable that my app is leaking
somehow. I do not cache dal objects directly and I use finite set of
indentifiers for cached objects, but it is possible that some of my
objects reference dal objects in an unwanted way, leading to some kind
of circular references which prevent garbage collection. It is not easy
to identify where exactly is the problem rooted, because my model is
quite complex (more than 100 tables, highly interlinked, etc.) and I
cache business objects built above DAL a lot. Maybe I'll use some tool
to examine the references between objects in memory (objgraph?).

So, I agree that there is probably no leak directly in web2py or Rocket
and uWSGI does not bring cure for the memory leak disease causation, but
it removes the symptoms, which makes me satisfied for now. The new setup
is also more stable. With Rocket my web2py freezed every couple of hours
(http://groups.google.com/group/web2py/browse_thread/thread/bd4f6e9f20d1a5aa)
and I had to monitor its state and force restarts whenever it happened.
Now it either freezes no more or Cherokee restarts uwsgi behind the
scenes whenever necessary. :)

David

Timbo wrote:
 So you do use caching?  Is it RAM caching or disk caching?  If RAM
 caching, it could be that running under Cherokee and uWSGI is deleting
 the environment that web2py is run in after a certain number of
 requests.  This would reduce the usefulness of a RAM cache but would
 also produce the results you're seeing. Whereas a Python-based server
 (Rocket or Cherrypy) would not do this and a RAM cache would persist
 as long as the server process (or until otherwise deleted).
 
 Please let us know when you look into the possibilities of caching
 being the issue.
 
 @ron_m: Awesome.  Great suggestions!
 
 -tim
 
 On Dec 25, 3:20 pm, David Zejda d...@atlas.cz wrote:
 Thanks for the all replies!

 I do not directly cache DAL objects, but yes, caching may be behind
 the leak
 through some references between objects. Maybe I'll examine it with
 objgraph,
 and I agree, it would be nice to have the function at hand in the
 admin interface.

 Cherrypy  anyserver brings no significant change.

 With Cherokee  uWSGI the problem has gone. Moreover the new setup is
 subjectively
 faster to the previous one (Rocket behind Apache proxy). :)

 David
 
 

- --
David Zejda, Open-IT cz
web development  services
http://www.o-it.info
-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.9 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iEYEARECAAYFAk0YZeMACgkQ3oCkkciamVFgdgCfczag6uRCsadFl+TtTBj+SDgV
BokAoLfKc4Caslc0QISWt1fXf6lAhCBv
=+XpP
-END PGP SIGNATURE-


[web2py] Re: memory leak - model remains in memory after requests

2010-12-25 Thread David Zejda
Thanks for the all replies!

I do not directly cache DAL objects, but yes, caching may be behind
the leak
through some references between objects. Maybe I'll examine it with
objgraph,
and I agree, it would be nice to have the function at hand in the
admin interface.

Cherrypy  anyserver brings no significant change.

With Cherokee  uWSGI the problem has gone. Moreover the new setup is
subjectively
faster to the previous one (Rocket behind Apache proxy). :)

David


[web2py] memory leak - model remains in memory after requests

2010-12-24 Thread David Zejda
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

My web2py instance gradually eats memory, during day the consumption
grows up to several gigs, so I have to restart often. According to guppy
most of memory is occupied by gluon.dal.Field and other classes of dal:

Partition of a set of 3231760 objects. Total size = 443724152 bytes.
 Index  Count   % Size   % Cumulative  % Kind
 0 113419   4 189636568  43 189636568  43 dict of gluon.dal.Field
 1 1324208  41 80561096  18 270197664  61 str
 2 328642  10 15982732   4 286180396  64 tuple
 3  26637   1 13851240   3 300031636  68 dict of
gluon.validators.IS_IN_DB
 4  98796   3 13436256   3 313467892  71 dict of gluon.dal.Set
 5  20042   1 13344464   3 326812356  74 dict (no owner)
 6   8199   0 11860464   3 338672820  76 gluon.dal.Row
 7  16615   1 11482224   3 350155044  79 gluon.dal.Table
 8  63682   2  8660752   2 358815796  81 dict of gluon.dal.Query
 9 137779   4  7363776   2 366179572  83 list
2282 more rows. Type e.g. '_.more' to view.

The proportion is relatively stable. It seems that model definition
remains in memory after each request. It is probably caused by a weird
reference, but I'm not sure how to track it. Please do you have any ideas?

Thanks :)
David
-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.9 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iEYEARECAAYFAk0VN9gACgkQ3oCkkciamVFHHwCfWiIkmrH9buBYA/7HvgIbz+mR
ei0AniZ0UYwZtj9zagp2sx/IawmBE2iA
=9cqX
-END PGP SIGNATURE-


Re: [web2py] Re: Stick web2py to one CPU?

2010-11-15 Thread David Zejda
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1



mdipierro wrote:
 yes.
 
 On Nov 14, 5:50 pm, David Zejda d...@atlas.cz wrote:
 What do you think, would it be good idea to attach web2py process to one
 CPU core to avoid overhead related to switching between cores?
 
 Ryan Kelly writes: I just halved the running time of one of my test
 
 suites.
 
 http://www.rfk.id.au/blog/entry/a-gil-adventure-threading2
 
 David

- --
David Zejda, Open-IT cz
web development  services
http://www.o-it.info
-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.9 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iEYEARECAAYFAkzhlrgACgkQ3oCkkciamVHogwCgq0hAyEYfUZo+xCO3fmuyNY/g
MVgAn0/E7Y4DzMBWg/Bt0QSNbsryCUtB
=QoR3
-END PGP SIGNATURE-


Re: [web2py] Re: Stick web2py to one CPU?

2010-11-15 Thread David Zejda
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

Well.. thanks for a very straightforward answer :)

Will you apply this in a next web2py version? Or is it better to leave
it on each web2py user?

David

mdipierro wrote:
 yes.
 
 On Nov 14, 5:50 pm, David Zejda d...@atlas.cz wrote:
 What do you think, would it be good idea to attach web2py process to one
 CPU core to avoid overhead related to switching between cores?
 
 Ryan Kelly writes: I just halved the running time of one of my test
 
 suites.
 
 http://www.rfk.id.au/blog/entry/a-gil-adventure-threading2
 
 David

- --
David Zejda, Open-IT cz
web development  services
http://www.o-it.info
-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.9 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iEYEARECAAYFAkzhl5IACgkQ3oCkkciamVH7hgCfXQPeQpbsP912HC4t9txpvo4j
4ZMAn3aouJoMV/sE0+Jg51Ddavlfd03Q
=FEdt
-END PGP SIGNATURE-


[web2py] Stick web2py to one CPU?

2010-11-14 Thread David Zejda
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

What do you think, would it be good idea to attach web2py process to one
CPU core to avoid overhead related to switching between cores?

Ryan Kelly writes: I just halved the running time of one of my test
suites.

http://www.rfk.id.au/blog/entry/a-gil-adventure-threading2

David
- --
David Zejda, Open-IT cz
web development  services
http://www.o-it.info
-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.9 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iEYEARECAAYFAkzgddIACgkQ3oCkkciamVEuRACfUrHv8hKlkFWPmdmFDEzF4Ww4
GZ8An0Yub2C+83nb+Ghu6gTc+NNmhbkv
=TyFn
-END PGP SIGNATURE-


Re: [web2py] Re: ProgrammingError: (2014, Commands out of sync; you can't run this command now)

2010-11-10 Thread David Zejda
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

This one is also quite common:

Traceback (most recent call last):
  File /opt/web2py/gluon/main.py, line 475, in wsgibase
BaseAdapter.close_all_instances(BaseAdapter.rollback)
  File /opt/web2py/gluon/sql.py, line 810, in close_all_instances
action(instance)
  File /opt/web2py/gluon/sql.py, line 1393, in rollback
self._connection.rollback()
ProgrammingError: (2014, Commands out of sync; you can't run this
command now)

Yes, I have many queries also in try..except blocks. But it is really
hard to find what exactly is the root of problem because I did not
reveal any meaningful shape in the error occurencies. At least not yet. :(

D.

mdipierro wrote:
 Has anybody else here had a similar problem?
 
 massimo
 
 On Nov 9, 11:29 am, David Zejda d...@atlas.cz wrote:
 Hi :)
 
 E.g. now the exception was raised by the web2py internal db
 initialization routine:
 
 28: db = SQLDB('mysql://myus:myp...@localhost:330h6/mydb', pool_size=10)
 
 Traceback (most recent call last):
   File /opt/web2py/gluon/restricted.py, line 188, in restricted
 exec ccode in environment
   File /opt/web2py/applications/myapp/compiled/models_db.py, line 28,
 in module
   File /opt/web2py/gluon/sql.py, line 978, in __init__
 self._execute('SET FOREIGN_KEY_CHECKS=1;')
   File /opt/web2py/gluon/sql.py, line 977, in lambda
 self._execute = lambda *a, **b: self._cursor.execute(*a, **b)
   File /var/lib/python-support/python2.5/MySQLdb/cursors.py, line 166,
 in execute
 self.errorhandler(self, exc, value)
   File /var/lib/python-support/python2.5/MySQLdb/connections.py, line
 35, in defaulterrorhandler
 raise errorclass, errorvalue
 ProgrammingError: (2014, Commands out of sync; you can't run this
 command now)
 
 I'm thinking about possibility to raise the size of my poll. But in the
 past with higher poll I think I was receiving more OperationalError:
 (2006, 'MySQL server has gone away'). Because I am referring to a live
 server, I would prefer to avoid experiments which could make frequency
 of db errors even worse :)
 
 thanks  wishing you a nice day..
 David
 
 
 
 mdipierro wrote:
 I cannot say without looking at the code. MySQL has lots of
 undocumented quirks about what you can do and what you cannot do
 within one transaction.
 Try add a db.commit() after each insert/unpdate/form.accepts/
 crud.update/crud.select IF you do a select after that.
 Do you have any try:...except in your controllers and db queries
 inside?
 On Nov 8, 2:57 am, David Zejda d...@atlas.cz wrote:
 The MySQL error occurs quite often, several times every day. The app has
 about 2 page views daily and heavily communicates with db (tens of
 queries per request, in db I have about 100 tables). Currently I have
 pool with size for 10 connections.
 Meaning of the error message is described here:
 http://dev.mysql.com/doc/refman/4.1/en/commands-out-of-sync.html
 It seems that with MySQL statements on the same db connection have to be
 exhausted one-by-one, never in parallel. Two statements returning data
 to the process must be using separate DBConnections (possibly to the
 same host/db). Multiple statements on the same connection are supported,
 but only 1 may be in a state to 'fetch' data.
 Traces for the errors look like this:
   File /opt/web2py/gluon/sql.py, line 3378, in count
 return self.select('count(*)')[0]._extra['count(*)']
   File /opt/web2py/gluon/sql.py, line 3237, in select
 rows = response(query)
   File /opt/web2py/gluon/sql.py, line 3232, in response
 db._execute(query)
   File /opt/web2py/gluon/sql.py, line 977, in lambda
 self._execute = lambda *a, **b: self._cursor.execute(*a, **b)
   File /var/lib/python-support/python2.5/MySQLdb/cursors.py, line 166,
 in execute
 self.errorhandler(self, exc, value)
   File /var/lib/python-support/python2.5/MySQLdb/connections.py, line
 35, in defaulterrorhandler
 raise errorclass, errorvalue
 ProgrammingError: (2014, Commands out of sync; you can't run this
 command now)
 Or e.g.:
 Traceback (most recent call last):
   File /opt/web2py/gluon/main.py, line 475, in wsgibase
 BaseAdapter.close_all_instances(BaseAdapter.rollback)
   File /opt/web2py/gluon/sql.py, line 810, in close_all_instances
 action(instance)
   File /opt/web2py/gluon/sql.py, line 1393, in rollback
 self._connection.rollback()
 ProgrammingError: (2014, Commands out of sync; you can't run this
 command now)
 Do you have any tips how to aviod these errors?
 Thanks!

- --
David Zejda, Open-IT cz
web development  services
http://www.o-it.info
-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.9 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iEYEARECAAYFAkza+54ACgkQ3oCkkciamVG10ACgmEIip08ls4k3XRzIsQxWAPxX
BIcAn27XoF8Ka9kEPMqZWK16dgwvY6kw
=/ISp
-END PGP SIGNATURE-


Re: [web2py] Re: ProgrammingError: (2014, Commands out of sync; you can't run this command now)

2010-11-09 Thread David Zejda
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

Hi :)

E.g. now the exception was raised by the web2py internal db
initialization routine:

28: db = SQLDB('mysql://myus:myp...@localhost:330h6/mydb', pool_size=10)

Traceback (most recent call last):
  File /opt/web2py/gluon/restricted.py, line 188, in restricted
exec ccode in environment
  File /opt/web2py/applications/myapp/compiled/models_db.py, line 28,
in module
  File /opt/web2py/gluon/sql.py, line 978, in __init__
self._execute('SET FOREIGN_KEY_CHECKS=1;')
  File /opt/web2py/gluon/sql.py, line 977, in lambda
self._execute = lambda *a, **b: self._cursor.execute(*a, **b)
  File /var/lib/python-support/python2.5/MySQLdb/cursors.py, line 166,
in execute
self.errorhandler(self, exc, value)
  File /var/lib/python-support/python2.5/MySQLdb/connections.py, line
35, in defaulterrorhandler
raise errorclass, errorvalue
ProgrammingError: (2014, Commands out of sync; you can't run this
command now)

I'm thinking about possibility to raise the size of my poll. But in the
past with higher poll I think I was receiving more OperationalError:
(2006, 'MySQL server has gone away'). Because I am referring to a live
server, I would prefer to avoid experiments which could make frequency
of db errors even worse :)

thanks  wishing you a nice day..
David

mdipierro wrote:
 I cannot say without looking at the code. MySQL has lots of
 undocumented quirks about what you can do and what you cannot do
 within one transaction.
 
 Try add a db.commit() after each insert/unpdate/form.accepts/
 crud.update/crud.select IF you do a select after that.
 
 Do you have any try:...except in your controllers and db queries
 inside?
 
 
 On Nov 8, 2:57 am, David Zejda d...@atlas.cz wrote:
 The MySQL error occurs quite often, several times every day. The app has
 about 2 page views daily and heavily communicates with db (tens of
 queries per request, in db I have about 100 tables). Currently I have
 pool with size for 10 connections.
 
 Meaning of the error message is described here:
 
 http://dev.mysql.com/doc/refman/4.1/en/commands-out-of-sync.html
 
 It seems that with MySQL statements on the same db connection have to be
 exhausted one-by-one, never in parallel. Two statements returning data
 to the process must be using separate DBConnections (possibly to the
 same host/db). Multiple statements on the same connection are supported,
 but only 1 may be in a state to 'fetch' data.
 
 Traces for the errors look like this:
 
   File /opt/web2py/gluon/sql.py, line 3378, in count
 return self.select('count(*)')[0]._extra['count(*)']
   File /opt/web2py/gluon/sql.py, line 3237, in select
 rows = response(query)
   File /opt/web2py/gluon/sql.py, line 3232, in response
 db._execute(query)
   File /opt/web2py/gluon/sql.py, line 977, in lambda
 self._execute = lambda *a, **b: self._cursor.execute(*a, **b)
   File /var/lib/python-support/python2.5/MySQLdb/cursors.py, line 166,
 in execute
 self.errorhandler(self, exc, value)
   File /var/lib/python-support/python2.5/MySQLdb/connections.py, line
 35, in defaulterrorhandler
 raise errorclass, errorvalue
 ProgrammingError: (2014, Commands out of sync; you can't run this
 command now)
 
 Or e.g.:
 
 Traceback (most recent call last):
   File /opt/web2py/gluon/main.py, line 475, in wsgibase
 BaseAdapter.close_all_instances(BaseAdapter.rollback)
   File /opt/web2py/gluon/sql.py, line 810, in close_all_instances
 action(instance)
   File /opt/web2py/gluon/sql.py, line 1393, in rollback
 self._connection.rollback()
 ProgrammingError: (2014, Commands out of sync; you can't run this
 command now)
 
 Do you have any tips how to aviod these errors?
 
 Thanks!
 

- --
David Zejda, Open-IT cz
web development  services
http://www.o-it.info
-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.9 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iEYEARECAAYFAkzZhPcACgkQ3oCkkciamVGyjwCfc0HsoJyvD8DuRWDjT02UJwae
U0cAmgKsRs7vhz2j5MTljR6TQDulBvt9
=HFwI
-END PGP SIGNATURE-


[web2py] ProgrammingError: (2014, Commands out of sync; you can't run this command now)

2010-11-08 Thread David Zejda
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

The MySQL error occurs quite often, several times every day. The app has
about 2 page views daily and heavily communicates with db (tens of
queries per request, in db I have about 100 tables). Currently I have
pool with size for 10 connections.

Meaning of the error message is described here:

http://dev.mysql.com/doc/refman/4.1/en/commands-out-of-sync.html

It seems that with MySQL statements on the same db connection have to be
exhausted one-by-one, never in parallel. Two statements returning data
to the process must be using separate DBConnections (possibly to the
same host/db). Multiple statements on the same connection are supported,
but only 1 may be in a state to 'fetch' data.

Traces for the errors look like this:

  File /opt/web2py/gluon/sql.py, line 3378, in count
return self.select('count(*)')[0]._extra['count(*)']
  File /opt/web2py/gluon/sql.py, line 3237, in select
rows = response(query)
  File /opt/web2py/gluon/sql.py, line 3232, in response
db._execute(query)
  File /opt/web2py/gluon/sql.py, line 977, in lambda
self._execute = lambda *a, **b: self._cursor.execute(*a, **b)
  File /var/lib/python-support/python2.5/MySQLdb/cursors.py, line 166,
in execute
self.errorhandler(self, exc, value)
  File /var/lib/python-support/python2.5/MySQLdb/connections.py, line
35, in defaulterrorhandler
raise errorclass, errorvalue
ProgrammingError: (2014, Commands out of sync; you can't run this
command now)

Or e.g.:

Traceback (most recent call last):
  File /opt/web2py/gluon/main.py, line 475, in wsgibase
BaseAdapter.close_all_instances(BaseAdapter.rollback)
  File /opt/web2py/gluon/sql.py, line 810, in close_all_instances
action(instance)
  File /opt/web2py/gluon/sql.py, line 1393, in rollback
self._connection.rollback()
ProgrammingError: (2014, Commands out of sync; you can't run this
command now)

Do you have any tips how to aviod these errors?

Thanks!

- --
David Zejda
Sbírka na operaci pro pětiletou Vanessu
http://www.tabang.eu
-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.9 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iEYEARECAAYFAkzXu3oACgkQ3oCkkciamVEXdACeJOUPZt8d3yDvgNNNY6V8HDmX
TvEAnid88S+V2I7OV9XLR1Kq/etu92kM
=iP7t
-END PGP SIGNATURE-


[web2py] Authentication over domains

2010-11-08 Thread David Zejda
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

My application is running on more domains. Users wish to move from one
domain to another, being still signed-in. I used combination of JS and
Ajax to transfer the credentials from sessions between domains, adhering
to security measures of JS which do not allow to do it directly. If
anybody interested, I may describe the solution.
-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.9 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iEYEARECAAYFAkzXvVkACgkQ3oCkkciamVG/rgCfTZHn86h+wZUsLYjnZI/4Gqv5
FXkAniaSbzsFDAEf90djkSuj7CTZVvby
=IDNP
-END PGP SIGNATURE-


[web2py] MultipleOptionsWidget do not work with multiple=True fields (patch)

2010-10-11 Thread David Zejda
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

I had to add

value = value == '||' and [] or value[1:-1].split(|)

to make it working properly with existing data rows:


class MultipleOptionsWidget2(OptionsWidget):

@staticmethod
def widget(field, value, size=5, **attributes):

value = value == '||' and [] or value[1:-1].split(|)

attributes.update(dict(_size=size, _multiple=True))
return OptionsWidget.widget(field, value, **attributes)


Values in the widget were not preselected before the change.

David
-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.9 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iEYEARECAAYFAkyzWF0ACgkQ3oCkkciamVGVHgCfej3grFLiXXi6F2zG7UkEqgxY
GpoAnjv7DRcks7zgJ8lxYCP8G19qww76
=cj+E
-END PGP SIGNATURE-


[web2py] Web2py crashing

2010-05-07 Thread David Zejda
Hi,

my web2py instance (about 1 pageviews, 30+ ajax requests
daily) crashes about daily. As a workaround I have a script which
(re)starts the server when either memory usage exceeds certain
threshold or when the server is completely down. I run the script from
cron every minute.

#! /bin/sh

A=`netstat -tlnp | grep 8000`
TIME=`date`
LOG='/var/log/web2py/keepalive.log'

if [ $A ];
then
B=`echo $A | cut -d   -f 7`
PID=${B%/*}
MEM=`ps -p $PID -o vsz | tail -n 1`
if [ $MEM -gt 200 ];
then
echo $TIME $PID$MEMMEMORY  $LOG
echo Web2py memory $MEM on $TIME = restart. | mail
m...@mail.com -s 'Web2py fail!'
/etc/init.d/web2py restart
else
echo $TIME $PID$MEMOK  $LOG
fi
else
echo $TIME FAIL  $LOG
echo Web2py failed on $TIME | mail m...@mail.com -s 'Web2py fail!'
/etc/init.d/web2py restart
fi

I know I should find time to try to examine cause of memory leaking
with guppy-heapy. But I think the crashing is another issue, not
directly related to the leaking. Access logs revealed no direct
relation to any particular controller or function. Also, after web2py
upgrade it has not changed.

Do you have any idea how to reveal the cause of crashing?

Thanks!
David


[web2py] Re: Web2py crashing

2010-05-07 Thread David Zejda
AFAIK web2py uses cherrypy webserver, which listens as a daemon on
certain port. With crashing I mean that the listening process (web2py
with cherrypy at the background) suddenly terminates. I use standard
Python v 2.5.2 as packaged for Debian.

David

On May 7, 2:52 pm, Timothy Farrell tfarr...@swgen.com wrote:
 Can you be more specific on what you mean by crashing?  Interpreted
 languages shouldn't crash and generally if they do it's something wrong
 with the interpreter.  Are you using cPython?

 On 5/7/2010 1:48 AM, David Zejda wrote:

  Hi,

  my web2py instance (about 1 pageviews, 30+ ajax requests
  daily) crashes about daily. As a workaround I have a script which
  (re)starts the server when either memory usage exceeds certain
  threshold or when the server is completely down. I run the script from
  cron every minute.

  #! /bin/sh

  A=`netstat -tlnp | grep 8000`
  TIME=`date`
  LOG='/var/log/web2py/keepalive.log'

  if [ $A ];
  then
       B=`echo $A | cut -d   -f 7`
       PID=${B%/*}
       MEM=`ps -p $PID -o vsz | tail -n 1`
       if [ $MEM -gt 200 ];
       then
           echo $TIME  $PID    $MEM    MEMORY  $LOG
           echo Web2py memory $MEM on $TIME =  restart. | mail
  m...@mail.com -s 'Web2py fail!'
           /etc/init.d/web2py restart
       else
           echo $TIME  $PID    $MEM    OK  $LOG
       fi
  else
       echo $TIME      FAIL  $LOG
       echo Web2py failed on $TIME | mail m...@mail.com -s 'Web2py fail!'
       /etc/init.d/web2py restart
  fi

  I know I should find time to try to examine cause of memory leaking
  with guppy-heapy. But I think the crashing is another issue, not
  directly related to the leaking. Access logs revealed no direct
  relation to any particular controller or function. Also, after web2py
  upgrade it has not changed.

  Do you have any idea how to reveal the cause of crashing?

  Thanks!
  David


[web2py] Re: Web2py crashing

2010-05-07 Thread David Zejda
Yes, vanilla hardware (some dual core Intel). I'm running the latest
web2py now, but it was crashing even with about half year old version
(1.73 or so), so the issue is probably not webserver specific. The
process is in ps ax no more when crashes. Currently the server is
being accessed through Apache proxy. Maybe I'll find a while to test
it with mod_wsgi.

Thanks :)

On May 7, 4:00 pm, Timothy Farrell tfarr...@swgen.com wrote:
 Is this standard hardware?  The only place I've seen Python crash is on
 non-standard hardware (AS400) with a non-supported build of Python.

 Web2py recent switched from Cherrypy's wsgiserver to Rocket (which I
 wrote) as of version 1.77.2 (I think).  Which version are you running?

 With built-in web-servers, the listening for connections and the
 response processing all happens in the same Linux Process.  So if it
 stops listening, do you still see the process in 'top' or 'px ax'?  If
 so, then, Yes, the whole process crashed (in which case it is more
 likely the Python interpreter); otherwise, there would likely be a bug
 somewhere in web2py that we can address.

 You could also try Apache+mod_wsgi to see if that changes things.

 -tim

 On 5/7/2010 8:36 AM, David Zejda wrote:

  AFAIK web2py uses cherrypy webserver, which listens as a daemon on
  certain port. With crashing I mean that the listening process (web2py
  with cherrypy at the background) suddenly terminates. I use standard
  Python v 2.5.2 as packaged for Debian.

  David

  On May 7, 2:52 pm, Timothy Farrelltfarr...@swgen.com  wrote:

  Can you be more specific on what you mean by crashing?  Interpreted
  languages shouldn't crash and generally if they do it's something wrong
  with the interpreter.  Are you using cPython?

  On 5/7/2010 1:48 AM, David Zejda wrote:

  Hi,

  my web2py instance (about 1 pageviews, 30+ ajax requests
  daily) crashes about daily. As a workaround I have a script which
  (re)starts the server when either memory usage exceeds certain
  threshold or when the server is completely down. I run the script from
  cron every minute.

  #! /bin/sh

  A=`netstat -tlnp | grep 8000`
  TIME=`date`
  LOG='/var/log/web2py/keepalive.log'

  if [ $A ];
  then
        B=`echo $A | cut -d   -f 7`
        PID=${B%/*}
        MEM=`ps -p $PID -o vsz | tail -n 1`
        if [ $MEM -gt 200 ];
        then
            echo $TIME  $PID    $MEM    MEMORY    $LOG
            echo Web2py memory $MEM on $TIME =    restart. | mail
  m...@mail.com -s 'Web2py fail!'
            /etc/init.d/web2py restart
        else
            echo $TIME  $PID    $MEM    OK    $LOG
        fi
  else
        echo $TIME      FAIL    $LOG
        echo Web2py failed on $TIME | mail m...@mail.com -s 'Web2py fail!'
        /etc/init.d/web2py restart
  fi

  I know I should find time to try to examine cause of memory leaking
  with guppy-heapy. But I think the crashing is another issue, not
  directly related to the leaking. Access logs revealed no direct
  relation to any particular controller or function. Also, after web2py
  upgrade it has not changed.

  Do you have any idea how to reveal the cause of crashing?

  Thanks!
  David


[web2py] web2py Mail tool - unwanted encoding of 'to' header

2010-05-05 Thread David Zejda
Hi,

headers of my mails are being encoded to utf-8, which causes troubles
with delivery.

e.g. 'dvid[at]atlas.cz' (where [at] is '@') is being encoded as

=?utf-8?q?dvid=40atlas=2Ecz?=

processed by mailserver as:

=?utf-8?q?dvid=40atlas=2ec...@crfreenet.org

after decoding:

dvid@atlas...@crfreenet.org

To avoid the encoding I changed

payload['To'] = \
header.Header(',
'.join(to).decode(encoding).encode('utf-8'),'utf-8')

in Auth.send to

payload['To'] = \
header.Header(', '.join(to))

Is there a better solution?

The problem started to appear after upgrade, with some older web2py
version it was OK.

David


[web2py] Re: web2py Mail tool - unwanted encoding of 'to' header

2010-05-05 Thread David Zejda
Yes, I agree, it seems as a good solution :)

On May 5, 8:24 pm, mdipierro mdipie...@cs.depaul.edu wrote:
 I guess we should check is the address contains non-ascii chars, and
 use ore of the other depedning on the result.


[web2py] Re: Memory usage inspection

2010-04-10 Thread David Zejda
Hi thanks for advices, I'll check it using guppy-heapy in appadmin.

Yes, the benefits of caching are obvious. My project has one central
table with about 100 fields representing 'user' and about 100 other
tables. To allow rich relations and searching and other interaction
among users, without caching it was necessary to run many complex
queries (or tons of simple queries) and process the results per each
request. If I cache the processed results now, times for the complex
requests dropped from about 10 secs to about 1 s and do not rise too
sharply with additional users, but sorry, I do not have the exact
results stored.

The fact that still I have to instantiate object per each user in each
request to not loose track of a current session and other globals (as
discussed in 
http://groups.google.com/group/web2py/browse_thread/thread/9ad00afc98616f15#
) surely affects the performance, but still it seems beneficial
enough.

David

On Apr 9, 11:56 pm, mdipierro mdipie...@cs.depaul.edu wrote:
 If you have multiple processes make sure all of them call
 cache.ram.clear() or consider using cache.disk().

 Can you give us some data about performance benefits?

 If you discover anything about the cause for this problem, please keep
 us posted.

 Massimo

 On Apr 9, 4:28 pm, David Zejda d...@atlas.cz wrote:

  Hi,

  I'm aggresively caching nearly everything.. it helped to reduce
  database queries and increase performance in result. But I have
  another problem now - memory usage slowly grows, during a day my
  server eats about 2 GB. If I flush cache by clear() function, it does
  not help much. Something it's leaking perhaps.

  Please, do you use any tool to inspect what a hell is in the memory?

  Thanks!

  David


-- 
To unsubscribe, reply using remove me as the subject.


[web2py] Memory usage inspection

2010-04-09 Thread David Zejda
Hi,

I'm aggresively caching nearly everything.. it helped to reduce
database queries and increase performance in result. But I have
another problem now - memory usage slowly grows, during a day my
server eats about 2 GB. If I flush cache by clear() function, it does
not help much. Something it's leaking perhaps.

Please, do you use any tool to inspect what a hell is in the memory?

Thanks!

David


-- 
To unsubscribe, reply using remove me as the subject.


[web2py] Re: Cache - how to prevent session object to be cached?

2010-04-03 Thread David Zejda
Hmm.. I had to cut my objects into parts, those which hold data are
being cached while those with logic are not... kind of hack, but I'm
no more directly affected by the bug.

D.

-- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To post to this group, send email to web...@googlegroups.com.
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en.



[web2py] Re: Cache - how to prevent session object to be cached?

2010-03-31 Thread David Zejda
I played with the cache more. If I pass current session to the object
loaded from cache, it works OK, I mean the times returned are equal:

class Blah:
def sessiontime(self, session):
globals()['session'] = session
return session.ctime

def cache_test():
import time
session.ctime = time.ctime()
def blah():
return Blah()
b = cache.ram('blah',blah,30)
return dict(cached=b.sessiontime(session), current=session.ctime)

Of course, this is not a solution, just a dirty hack.

Moreover the problem is not with session object only. It seems that
whole globals at the time of storage are being attached to the object,
including request, result etc. E.g.:

class Blah2:
def req_function(self):
return request.function

def cache_test_2():
b = cache.ram('blah',Blah2,30)
return dict(function=b.req_function())

def cache_test_other():
b = cache.ram('blah',Blah2,30)
return dict(function=b.req_function())

I would anticipate that it will return the name of request function
from which it is being called,
but blah pulled from cache prints name of function from the time of
construction :-(

David

-- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To post to this group, send email to web...@googlegroups.com.
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en.



[web2py] Re: Cache - how to prevent session object to be cached?

2010-03-30 Thread David Zejda
I tried to move the part which asks session for the ctime value into a
model:

def sestime():
return session.ctime

In controller there is:

class Blah:
def sessiontime(self):
return sestime()

def cache_test():
import time
session.ctime = time.ctime()
def blah():
return Blah()
b = cache.ram('blah',blah,30)
return dict(cached=b.sessiontime(), current=session.ctime)

And still the same, the cached and current differ. The old session is
wired into the cache somehow, hmmm..

The examples are silly, of course, just to show the problem. I wish to
use the cache to store complex objects, constructed on results of
multiple queries. The objects have various methods operating on their
properties in context of session. Once I cache the objects (to avoid
tons of queries), my program breaks :(

David

-- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To post to this group, send email to web...@googlegroups.com.
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en.



[web2py] Re: Cache - how to prevent session object to be cached?

2010-03-28 Thread David Zejda
Hi Massimo,

i touched it to cache function instead of constructor:

class Blah:
def sessiontime(self):
return session.ctime

def cache_test():
import time
session.ctime = time.ctime()
def blah():
return Blah()
b = cache.ram('blah',blah,30)
return dict(cached=b.sessiontime(), current=session.ctime)

and result is the same.

David

On Mar 28, 4:39 pm, mdipierro mdipie...@cs.depaul.edu wrote:
 No. and frankly I do not understand why it behaves it this way. You
 are doing something I never thought of: caching a constructor instead
 of a function. I will check this.

 Massimo

-- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To post to this group, send email to web...@googlegroups.com.
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en.



[web2py] Re: cache language files

2010-03-27 Thread David Zejda
Thanks :)

I'll report if I find any troubles...

D.

On Mar 26, 6:21 pm, mdipierro mdipie...@cs.depaul.edu wrote:
 I changed this in trunk. The language files are now cached but please
 check that I did not not break them.

-- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To post to this group, send email to web...@googlegroups.com.
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en.



[web2py] Re: MySQL server has gone away

2010-03-26 Thread David Zejda
Thanks. The workaround works, even when keeping the pool. :)

D.

 try:
     db=DAL(mysql://a:b...@localhost/c, pool_size=5)
 except:
     db=DAL(mysql://a:b...@localhost/c, pool_size=5)

-- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To post to this group, send email to web...@googlegroups.com.
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en.



[web2py] pass arguments to a function used by cache

2010-03-26 Thread David Zejda
Hello :)

I'd like to do something like this:

def load_chapter(book, chapter):
   

args = ('Alice', 3)
a = cache.ram('%s_%s' % args, load_chapter, arguments=args,
time_expire=50)

where the cache would execute load_chapter('Alice', 3) if necessary.

Any advices, please?

Regards,
David

-- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To post to this group, send email to web...@googlegroups.com.
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en.



[web2py] cache language files

2010-03-26 Thread David Zejda
Hi,

is it true, that languages.py reads language files per request (using
read_dict)?

If so, is it be possible to cache the loaded languages somehow?

Thanks!

David

-- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To post to this group, send email to web...@googlegroups.com.
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en.



[web2py] Re: MySQL server has gone away

2010-03-23 Thread David Zejda
Hi Massimo, please, were you able to look at it?
I'm getting the same error relatively often, several times a day one a
site with about 1 daily requests.

Thanks :)
David

On Feb 23, 9:31 am, mdipierro mdipie...@cs.depaul.edu wrote:
 will look into this.

-- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To post to this group, send email to web...@googlegroups.com.
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en.



[web2py:37572] compile app to bytecode using commandline

2009-12-19 Thread David Zejda
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

Hello,

I know I may compile my app using the web interface. I wish to deploy
the bytecode often. Is there any way to perform the compilation by script?

I have found, that there is a function compile_application in
gluon.contrib.compileapp.py, but the module is labeled FOR INTERNAL USE
ONLY so I do not know whether it is a good idea to try it directly
somehow :)

Thanks,
David

- --
David Zejda
http://www.tabang.eu
-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.9 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iEYEARECAAYFAkstMfMACgkQ3oCkkciamVFRogCffwB1qQACTQlbO1MFJTEqh7bf
830AoJMxVHjKvE9j4A7SpTcWm0HEdHA5
=2F0z
-END PGP SIGNATURE-

--

You received this message because you are subscribed to the Google Groups 
web2py-users group.
To post to this group, send email to web...@googlegroups.com.
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en.




[web2py:33081] web2py behind apache

2009-10-17 Thread David Zejda

-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

Hello,

I know there are several articles and posts related to the subject,
including relevant section in manual cut.

http://mdp.cti.depaul.edu/examples/static/web2py_manual_cut.pdf

But I encountered Graham Dumpleton's blog with severe arguments against
some of the recommended solutions. I would like to choose good way for
my production site. First of all - is it true, that I should select
mod_wsgi rather than mod_proxy if I wish to let Apache to serve my web?

And which of guides available is up-to date, free of security issues,
and thus recommended?

My setup is a bit more complicated, because I would like to have
* two domains served by different web2py apps
* together with separated error app, which is defined in routes.py to
serve exceptions in one of the domains.
Like this:

www.onedomain.com/error/(.*) - localhost:8000/error/$1

www.onedomain.com/(.*) - localhost:8000/onedomainapp/$1
(e.g. www.onedomain.com/controller/function -
  localhost:8000/onedomainapp/controller/function )

www.otherdomain.com/(.*) - localhost:8000/otherapp/$1

Please, could you help?

Thank you!

David
-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.9 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iEYEARECAAYFAkraPi0ACgkQ3oCkkciamVGJQACbBc9pKjSMnusalTImwWRDLd8t
3joAn2/vHgYOyeRzrzq5RYdhSPkngOyr
=0llU
-END PGP SIGNATURE-

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To post to this group, send email to web2py@googlegroups.com
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en
-~--~~~~--~~--~--~---



[web2py:31677] TypeError not indexable request.vars on SQLFORM.accepts()

2009-09-25 Thread David Zejda

-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

Hello,

I have upload field with IS_IMAGE validator, which allow only gif,jpg.
If I try to upload bmp, it leads to a weird uncaught exception:

Traceback (most recent call last):
  File /opt/web2py/gluon/restricted.py, line 176, in restricted
exec ccode in environment
  File /opt/web2py/applications/jfind/controllers/users.py, line 1571,
in module
  File /opt/web2py/gluon/globals.py, line 100, in lambda
self._caller = lambda f: f()
  File /opt/web2py/applications/jfind/controllers/users.py, line 868,
in update_my_profile
if form.accepts(request.vars, session):
  File /opt/web2py/gluon/sqlhtml.py, line 738, in accepts
if not request_vars.get(key,None) and self.table[key].type=='upload' \
  File /usr/lib/python2.5/cgi.py, line 633, in __len__
return len(self.keys())
  File /usr/lib/python2.5/cgi.py, line 609, in keys
raise TypeError, not indexable
TypeError: not indexable

This workaround in sqlhtml.accepts() helps for me:

if not ret and self.record and self.errors:
for key in self.errors.keys():
try:
if not request_vars.get(key,None) and
self.table[key].type=='upload' \
and self.record[key] and not
key+UploadWidget.ID_DELETE_SUFFIX in request_vars:
del self.errors[key]
except TypeError:
pass

But IMO the real cause of non-indexable request_vars will be somewhere
else..

D
-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.9 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iEYEARECAAYFAkq9L54ACgkQ3oCkkciamVESjgCgmNMWX/7yS3oezscwSnjJFNx7
Zr4AoJLg+0Wv8isN08WWwZpWNgZN9UNq
=SlJu
-END PGP SIGNATURE-

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To post to this group, send email to web2py@googlegroups.com
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en
-~--~~~~--~~--~--~---



[web2py:31133] Re: ticket tracking

2009-09-16 Thread David Zejda

-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

Hello,

I returned to examine the problem more deeply, but now it behaves
differently and I do not know why, I do not remember any change, which
could cause the change.

Now the error_handler entry in routes.py seems to be completely ignored.
I tried further to make a simpliest testing scenario possible - there is
application error with default controller only:

def index():
return dict(msg=aaa)

def err():
raise Exception(bbb)

Error raised by err function results in standard error though there is

error_handler = dict(application='error',
controller='default',function='index')

in routes.py.

If I call index() directly (http://127.0.0.1:8000/error) it works
normally. The routes.py is not ignored in whole - change in
error_message works.

Please, any ideas?

David

mdipierro napsal(a):
 If this is the case I could use some help debugging it.
 
 Massimo
 
 On Sep 11, 7:54 am, David Zejda d...@atlas.cz wrote:
 Thank you for the help.
 
 I have one problem with the solution - it seems, that if there is custom
 error_handler in routes.py specified, the ticket is not being generated.
 No file with traceback information appears and also the
 request.vars.ticket is left undefined.
 
 David
 
 mdipierro napsal(a):
 
 make app error with a controller default.py and an action
 def index():
 from gluon.tools import Mail
 mail=Mail()
 mail.settings.server=smpt.example.com:port
 mail.settings.sender=y...@example.com
 mail.settings.login=you:password
 ticket=request.vars.ticket
 subject=Ticket: %s % ticket
 message=bla bla bla
 mail.sent
 (to=administra...@example.com,subject=subject,message=message)
 return Sorry, an error occurred (%s), administrator has been
 notified % ticket
 and then create a file web2py/routes.py and in it write:
 error_handler = dict(application='error', controller='default',
 function='index')
 On Sep 10, 8:54 am, David Zejda d...@atlas.cz wrote:
 Hello,
 for a productive site I wish to touch the default error handler, maybe
 using some kind of decorator. IMO it would be good to
 1. retain the ticket generation
 2. notify admin by e-mail
 3. redirect client to a custom error page
 I would like to do it site-wide - not using the decorators for all
 controller functions one-by-one.
 Please, I will appreciate your advices..
 Thanks a lot!
 David
 
-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.9 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iEYEARECAAYFAkqxSAgACgkQ3oCkkciamVFW4ACggn3XI+3qZtiZIr3vA3D5cocd
4FoAnREVbhxKmvLH7n1df5qhG6abhFh7
=mtr1
-END PGP SIGNATURE-

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To post to this group, send email to web2py@googlegroups.com
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en
-~--~~~~--~~--~--~---



[web2py:31137] Re: MySQL - OperationalError: Error on rename (errno: 150)

2009-09-16 Thread David Zejda

-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

Here:

http://dev.mysql.com/doc/refman/5.1/en/innodb-foreign-key-constraints.html

they say: To find out the symbol value when you want to drop a foreign
key, use the SHOW CREATE TABLE statement.

David

mdipierro napsal(a):
 One more reason to have mysql.
 
 How do we figure out the name of the foreign key from the name of the
 table/field?
 
 Massimo
 
 
 
 On Jul 22, 10:10 am, David Zejda d...@atlas.cz wrote:
 Yes, the problem is connected with dropping the index on interrelated
 field. If I try to manually
 
 DROP INDEX field2__idx ON testing4;
 
 or
 
 ALTER TABLE testing4 DROP field2;
 
 i get the error too. I examined the problem more and the result is:
 
 Field with a FOREIGN KEY can't stay without at least one index defined
 on it. But if you remove the relation first:
 
 ALTER TABLE testing4 DROP FOREIGN KEY testing4_ibfk_1;
 
 Either the index or the whole field may be removed without error..
 
 David
 
 mdipierro napsal(a):
 
 OK, I see we have a problem with removing fields that have an index
 associated to them.
 Can you try remove the index manually and then attempt the migration?
 Massimo
 On Jul 21, 5:45 pm, Fran francisb...@googlemail.com wrote:
 On Jul 21, 11:42 pm, Fran francisb...@googlemail.com wrote:
 Confirmed. MySQL-5.1.36 with MySQL-python-1.2.2.win32 on Python-2.5.4
 on Windows XP
 OperationalError: (1025, Error on rename of '.\\db\\#sql-198_4' to '.\
 \db\\testing4' (errno: 150))
 sql.log doesn't show anything interesting:
 timestamp: 2009-07-21T23:39:53.171000
 CREATE TABLE ref2(
 id INT AUTO_INCREMENT NOT NULL,
 name VARCHAR(32),
 PRIMARY KEY(id)
 ) ENGINE=InnoDB CHARACTER SET utf8;
 success!
 timestamp: 2009-07-21T23:39:53.75
 CREATE TABLE testing4(
 id INT AUTO_INCREMENT NOT NULL,
 field VARCHAR(32),
 field2 INT, INDEX field2__idx (field2), FOREIGN KEY (field2)
 REFERENCES ref2(id) ON DELETE CASCADE,
 PRIMARY KEY(id)
 ) ENGINE=InnoDB CHARACTER SET utf8;
 success!
 timestamp: 2009-07-21T23:40:27.906000
 ALTER TABLE testing4 DROP COLUMN field2;
 F
 
-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.9 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iEYEARECAAYFAkqxUucACgkQ3oCkkciamVHUWQCggWwyEIJVBCpfIN5lIOIslQZs
cx8An1K/h6PKBtkRbXusmFXQJGlYE23w
=ukBM
-END PGP SIGNATURE-

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To post to this group, send email to web2py@googlegroups.com
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en
-~--~~~~--~~--~--~---



[web2py:30711] Re: ticket tracking

2009-09-11 Thread David Zejda

-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

Thank you for the help.

I have one problem with the solution - it seems, that if there is custom
error_handler in routes.py specified, the ticket is not being generated.
No file with traceback information appears and also the
request.vars.ticket is left undefined.

David

mdipierro napsal(a):
 make app error with a controller default.py and an action
 
 def index():
 from gluon.tools import Mail
 mail=Mail()
 mail.settings.server=smpt.example.com:port
 mail.settings.sender=y...@example.com
 mail.settings.login=you:password
 ticket=request.vars.ticket
 subject=Ticket: %s % ticket
 message=bla bla bla
 mail.sent
 (to=administra...@example.com,subject=subject,message=message)
 return Sorry, an error occurred (%s), administrator has been
 notified % ticket
 
 and then create a file web2py/routes.py and in it write:
 
 error_handler = dict(application='error', controller='default',
 function='index')
 
 
 
 
 
 On Sep 10, 8:54 am, David Zejda d...@atlas.cz wrote:
 Hello,
 
 for a productive site I wish to touch the default error handler, maybe
 using some kind of decorator. IMO it would be good to
 
 1. retain the ticket generation
 2. notify admin by e-mail
 3. redirect client to a custom error page
 
 I would like to do it site-wide - not using the decorators for all
 controller functions one-by-one.
 
 Please, I will appreciate your advices..
 
 Thanks a lot!
 
 David
 
-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.9 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iEYEARECAAYFAkqqSHIACgkQ3oCkkciamVGu3wCfbo4iBpkj5Y2TrQ5hnu6ZDtYw
+z4An2E+QK9lT+L7q+ZiAH6/bvudXfKG
=66uR
-END PGP SIGNATURE-

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To post to this group, send email to web2py@googlegroups.com
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en
-~--~~~~--~~--~--~---



[web2py:30609] ticket tracking

2009-09-10 Thread David Zejda

-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

Hello,

for a productive site I wish to touch the default error handler, maybe
using some kind of decorator. IMO it would be good to

1. retain the ticket generation
2. notify admin by e-mail
3. redirect client to a custom error page

I would like to do it site-wide - not using the decorators for all
controller functions one-by-one.

Please, I will appreciate your advices..

Thanks a lot!

David
-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.9 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iEYEARECAAYFAkqpBQ8ACgkQ3oCkkciamVEWpwCglAV9jvlB7qNYeqzBHe6kyj5a
Z94AoKhys1cmmSRw9UYAnzIdIX3E57aU
=/pZf
-END PGP SIGNATURE-

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To post to this group, send email to web2py@googlegroups.com
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en
-~--~~~~--~~--~--~---



[web2py:28605] sessions - how to find who is online

2009-08-14 Thread David Zejda

-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

Hello,

there is a multiuser web2py site. I'd like to be able to show, who is
online just now. Please, is there a way to drain the information, maybe
from the stored sessions?

Thanks!

David
-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.9 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iEYEARECAAYFAkqFHa4ACgkQ3oCkkciamVHKVACcDEX7Q+fAixjPJG0gUMX9/UdM
utsAn17kuRL+fM1HpYzp4OS5HhcpBLdc
=kShE
-END PGP SIGNATURE-

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To post to this group, send email to web2py@googlegroups.com
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en
-~--~~~~--~~--~--~---



[web2py:28178] filtering values offered in selectbox

2009-08-07 Thread David Zejda

-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

Hello!

Is it possible to restrict or filter choices listed in a select box
generated by SQLFORM for a field referring to other table?

E.g. I have a field person_id with reference to person.id. I wish to
allow only persons, who meet some criteria according to other fields in
the person table or based on certain joins, to be offered in the select box.

Thank you!

David.
-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.9 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iEYEARECAAYFAkp8qvoACgkQ3oCkkciamVFHkQCcC0TyPb9QMSjfrDl7ly+1NxOa
ERoAn0s5kfjMDwAvf8KUXWG7vPSFzj03
=8cOP
-END PGP SIGNATURE-

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To post to this group, send email to web2py@googlegroups.com
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en
-~--~~~~--~~--~--~---



[web2py:27926] chage the sort order for generated selectbox

2009-08-04 Thread David Zejda

-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

Hello,

I have two tables, table book with fields code and name, filled
with values e.g.:

id  codename
1   bz  Book 1
2   f4r Other book

and the second table with field:

SQLField('book', db.book, requires = \
IS_IN_DB(db, 'book.code', 'book.name'))

Web2py is able to generate a form with the selectbox for the field
book, it is good. But I need other sort order of entries in the
selectbox, it should be ordered by book.id whereas the name displayed
should be the 'name' as defined above. Is it possible?

Thanks!

David
-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.9 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iEYEARECAAYFAkp37LUACgkQ3oCkkciamVFzpgCfe9RZzV5HLZg1gouac1Gzlz0L
FoAAn08JFJNQi3Sogg4dn+7833bh86lz
=oL/m
-END PGP SIGNATURE-

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To post to this group, send email to web2py@googlegroups.com
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en
-~--~~~~--~~--~--~---



[web2py:27597] Re: Auth: mail validation

2009-07-30 Thread David Zejda

-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

Thanks, it works.. :)

D.

 auth.settings.registration_requires_verification = True
-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.9 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iEYEARECAAYFAkpxZVAACgkQ3oCkkciamVHU8gCfUMTFQjDdOrQEOOUl9kZA+scd
+n4An2sahi4ig7rQkbnU/f4YBQIQnVn6
=1IYQ
-END PGP SIGNATURE-

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To post to this group, send email to web2py@googlegroups.com
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en
-~--~~~~--~~--~--~---



[web2py:27648] IS_NULL_OR(IS_IMAGE causes AttributeError

2009-07-30 Thread David Zejda

-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

Hello,

if I have

IS_NULL_OR(IS_IMAGE(maxsize=(5000,4000), minsize=(50,50),
extensions=('jpeg', 'png', 'gif')))

as a field validator, the form.accepts with no image to upload causes:

File /web2py/gluon/sqlhtml.py, line 802, in accepts
(source_file, original_filename) = (f.file,f.filename)
AttributeError: 'NoneType' object has no attribute 'file'

Is there anything wrong with my validator settings?

Thanks!

David

-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.9 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iEYEARECAAYFAkpyAeIACgkQ3oCkkciamVGGKQCgnxUFkzlYVODsS4BVqa/gvIbj
07gAnR0cNwp2UrfFFXc7LFkmHR6ZebeS
=Qc1W
-END PGP SIGNATURE-

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To post to this group, send email to web2py@googlegroups.com
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en
-~--~~~~--~~--~--~---



[web2py:27562] Auth: mail validation

2009-07-29 Thread David Zejda

-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

Hello,

I have this code:

from gluon.tools import Mail, Auth, Recaptcha

mail=Mail()
mail.settings.server='mail.mydomain.net:25'
mail.settings.sender='ad...@mydomain.net'
mail.settings.login=None

auth = Auth(globals(), db)
auth.define_tables()
auth.settings.mailer = mail
auth.settings.captcha =
Recaptcha(request,public_key='my_key',private_key='my_key')

The problem is, that there are no validation mails being sent in
registration process. As a result of accepting register form, the user
becomes logged on immediately. I have suspicion, that the problem arised
as a result of web2py upgrade, but I am not sure in this. The mail
object itself works, I can manually send e-mails with no problem.

Please, what should I examine?

Thanks!
D.
-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.9 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iEYEARECAAYFAkpwr9EACgkQ3oCkkciamVFQygCguU+fpInfIq+Up2p4Q1TOEozB
GCgAn2LUqWcIBzdpta7K3QyXN1g+Ljok
=uU9B
-END PGP SIGNATURE-

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To post to this group, send email to web2py@googlegroups.com
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en
-~--~~~~--~~--~--~---



[web2py:27311] Re: MySQL - OperationalError: Error on rename (errno: 150)

2009-07-24 Thread David Zejda

-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

Massimo, would it be possible to let the DAL to drop foreign keys before
dropping index or field itself if dealing with MySQL?

David

David Zejda napsal(a):
 Yes, the problem is connected with dropping the index on interrelated
 field. If I try to manually
 
 DROP INDEX field2__idx ON testing4;
 
 or
 
 ALTER TABLE testing4 DROP field2;
 
 i get the error too. I examined the problem more and the result is:
 
 Field with a FOREIGN KEY can't stay without at least one index defined
 on it. But if you remove the relation first:
 
 ALTER TABLE testing4 DROP FOREIGN KEY testing4_ibfk_1;
 
 Either the index or the whole field may be removed without error..
 
 David
 
 mdipierro napsal(a):
 OK, I see we have a problem with removing fields that have an index
 associated to them.
 Can you try remove the index manually and then attempt the migration?
 
 Massimo
 
 On Jul 21, 5:45 pm, Fran francisb...@googlemail.com wrote:
 On Jul 21, 11:42 pm, Fran francisb...@googlemail.com wrote:

 Confirmed. MySQL-5.1.36 with MySQL-python-1.2.2.win32 on Python-2.5.4
 on Windows XP
 OperationalError: (1025, Error on rename of '.\\db\\#sql-198_4' to '.\
 \db\\testing4' (errno: 150))
 sql.log doesn't show anything interesting:
 timestamp: 2009-07-21T23:39:53.171000
 CREATE TABLE ref2(
 id INT AUTO_INCREMENT NOT NULL,
 name VARCHAR(32),
 PRIMARY KEY(id)
 ) ENGINE=InnoDB CHARACTER SET utf8;
 success!
 timestamp: 2009-07-21T23:39:53.75
 CREATE TABLE testing4(
 id INT AUTO_INCREMENT NOT NULL,
 field VARCHAR(32),
 field2 INT, INDEX field2__idx (field2), FOREIGN KEY (field2)
 REFERENCES ref2(id) ON DELETE CASCADE,
 PRIMARY KEY(id)
 ) ENGINE=InnoDB CHARACTER SET utf8;
 success!
 timestamp: 2009-07-21T23:40:27.906000
 ALTER TABLE testing4 DROP COLUMN field2;

 F

 
 

- 



-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.9 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iEYEARECAAYFAkppi4wACgkQ3oCkkciamVE2+ACgqN6dNMymHfg8csP3ZuDDbIKy
KO8AoLfQ9xi6oXqNzLSbPpKIdWxS3t2J
=rixq
-END PGP SIGNATURE-

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To post to this group, send email to web2py@googlegroups.com
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en
-~--~~~~--~~--~--~---



[web2py:27154] Re: MySQL - OperationalError: Error on rename (errno: 150)

2009-07-22 Thread David Zejda

-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

Yes, the problem is connected with dropping the index on interrelated
field. If I try to manually

DROP INDEX field2__idx ON testing4;

or

ALTER TABLE testing4 DROP field2;

i get the error too. I examined the problem more and the result is:

Field with a FOREIGN KEY can't stay without at least one index defined
on it. But if you remove the relation first:

ALTER TABLE testing4 DROP FOREIGN KEY testing4_ibfk_1;

Either the index or the whole field may be removed without error..

David

mdipierro napsal(a):
 OK, I see we have a problem with removing fields that have an index
 associated to them.
 Can you try remove the index manually and then attempt the migration?
 
 Massimo
 
 On Jul 21, 5:45 pm, Fran francisb...@googlemail.com wrote:
 On Jul 21, 11:42 pm, Fran francisb...@googlemail.com wrote:

 Confirmed. MySQL-5.1.36 with MySQL-python-1.2.2.win32 on Python-2.5.4
 on Windows XP
 OperationalError: (1025, Error on rename of '.\\db\\#sql-198_4' to '.\
 \db\\testing4' (errno: 150))
 sql.log doesn't show anything interesting:
 timestamp: 2009-07-21T23:39:53.171000
 CREATE TABLE ref2(
 id INT AUTO_INCREMENT NOT NULL,
 name VARCHAR(32),
 PRIMARY KEY(id)
 ) ENGINE=InnoDB CHARACTER SET utf8;
 success!
 timestamp: 2009-07-21T23:39:53.75
 CREATE TABLE testing4(
 id INT AUTO_INCREMENT NOT NULL,
 field VARCHAR(32),
 field2 INT, INDEX field2__idx (field2), FOREIGN KEY (field2)
 REFERENCES ref2(id) ON DELETE CASCADE,
 PRIMARY KEY(id)
 ) ENGINE=InnoDB CHARACTER SET utf8;
 success!
 timestamp: 2009-07-21T23:40:27.906000
 ALTER TABLE testing4 DROP COLUMN field2;

 F
  
 
 
 
-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.9 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iEYEARECAAYFAkpnK/MACgkQ3oCkkciamVG82gCfU1iFnZ+WU/AqHY1tu22o6EcS
XoQAoJKFIXXer/Die/C+PeroJLXfQSzO
=maIc
-END PGP SIGNATURE-

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To post to this group, send email to web2py@googlegroups.com
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en
-~--~~~~--~~--~--~---



[web2py:27038] Re: MySQL - OperationalError: Error on rename (errno: 150)

2009-07-21 Thread David Zejda

-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

The same error occurs, if I remove from the table model SQLField, which
relates to an another table, like this:

SQLField('name', db.permission_level, default=1, requires =
IS_IN_DB(db, 'permission_level.id', '%(level)s - %(name)s'))

I don't know - maybe there is no relation to MySQL and it's table
engines. My project is under development, so it is not so painful to
delete whole db and let the web2py to regenerate it, but in the full
operation it would be bad..

Thanks for ideas..

David

mdipierro napsal(a):
 The DAL assumes InnoDB, not MYISAM. Perhaps that is the problem?
 
 On Jul 20, 12:05 pm, David Zejda d...@atlas.cz wrote:
 Hello,
 
 my db backend is MySQL 5.0.51a-24 on Linux.
 
 If I try to gently alter already generated table schema, like to rename
 
 SQLField('relation', 'text', requires = \
IS_NULL_OR(IS_IN_DB(db, 'relation_type.id', 'relation_type.id',
 multiple=True)))
 
 to
 
 SQLField('relation_type', 'text', requires = \
IS_NULL_OR(IS_IN_DB(db, 'relation_type.id', 'relation_type.id',
 multiple=True)))
 
 i get this:
 
 Traceback (most recent call last):
   File /home/zejdad/!a/jfind/web2py/gluon/restricted.py, line 98, in
 restricted
 exec ccode in environment
   File /home/zejdad/!a/jfind/web2py/applications/jfind/models/db.py,
 line 346, in module
 migrate=person
   File /home/zejdad/!a/jfind/web2py/gluon/sql.py, line 938, in
 define_table
 raise e
 OperationalError: (1025, Error on rename of './jfind/#sql-ac1_5e' to
 './jfind/person' (errno: 150))
 
 Maybe, it is related to the troubles mentioned there:
 
 http://forums.mysql.com/read.php?22,95361
 
 Please, do you have any experiences with a such type of errors?
 
 I would like to test it with MyISAM instead of InnoDB tables, but it is
 not easy to change it in already generated and interrelated tables:
 
 ALTER TABLE `person` ENGINE = MYISAM
 
 #1217 - Cannot delete or update a parent row: a foreign key constraint
 fails
 
 Or should I try other MySQL version?
 
 Thank you for advices!
 
 David
 
-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.9 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iEYEARECAAYFAkplqaYACgkQ3oCkkciamVHxZwCeKBTaVXkc1e1X1cgeAub3x2t/
fmAAn1DsiGEALo8CddJvulnNGBsCMuen
=U4K0
-END PGP SIGNATURE-

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To post to this group, send email to web2py@googlegroups.com
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en
-~--~~~~--~~--~--~---



[web2py:26952] MySQL - OperationalError: Error on rename (errno: 150)

2009-07-20 Thread David Zejda

-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

Hello,

my db backend is MySQL 5.0.51a-24 on Linux.

If I try to gently alter already generated table schema, like to rename

SQLField('relation', 'text', requires = \
   IS_NULL_OR(IS_IN_DB(db, 'relation_type.id', 'relation_type.id',
multiple=True)))

to

SQLField('relation_type', 'text', requires = \
   IS_NULL_OR(IS_IN_DB(db, 'relation_type.id', 'relation_type.id',
multiple=True)))

i get this:

Traceback (most recent call last):
  File /home/zejdad/!a/jfind/web2py/gluon/restricted.py, line 98, in
restricted
exec ccode in environment
  File /home/zejdad/!a/jfind/web2py/applications/jfind/models/db.py,
line 346, in module
migrate=person
  File /home/zejdad/!a/jfind/web2py/gluon/sql.py, line 938, in
define_table
raise e
OperationalError: (1025, Error on rename of './jfind/#sql-ac1_5e' to
'./jfind/person' (errno: 150))

Maybe, it is related to the troubles mentioned there:

http://forums.mysql.com/read.php?22,95361

Please, do you have any experiences with a such type of errors?

I would like to test it with MyISAM instead of InnoDB tables, but it is
not easy to change it in already generated and interrelated tables:

ALTER TABLE `person` ENGINE = MYISAM

#1217 - Cannot delete or update a parent row: a foreign key constraint
fails

Or should I try other MySQL version?

Thank you for advices!

David
-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.9 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iEYEARECAAYFAkpko+cACgkQ3oCkkciamVF3nACfdej9+FBUseSRBgMtJyBm0elR
wKUAnjx/qSTnNzG+Dr47AKmHm40PxJUK
=HqDy
-END PGP SIGNATURE-

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To post to this group, send email to web2py@googlegroups.com
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en
-~--~~~~--~~--~--~---



[web2py:26953] SQLForm and IS_NULL_OR(IS_IN_DB( ... multiple=True))

2009-07-20 Thread David Zejda

-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

Hello,

for
IS_NULL_OR(IS_IN_DB(db, 'table.id', 'table.name'))
SQLForm generates a combo with a None as a selectable value.

There is also a relatively new support for multiple fields:
IS_IN_DB(db, 'table.id', 'table.name', multiple=True)
It generates a simple multi-select widget.

It would be nice to combine both functionalities to have a SQLForm
support for:
IS_NULL_OR(IS_IN_DB(db, 'table.id', 'table.name', multiple=True))
I think, the easiest way would be to add None to the multi-select values.

Thank you...

With regards
David
-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.9 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iEYEARECAAYFAkpkrkIACgkQ3oCkkciamVEUCgCcDDvUNa3Y63ltbVVejtkw7N7L
LegAn1ek/u4E67MlHqj85RhVZu/Il8K9
=CAlm
-END PGP SIGNATURE-

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To post to this group, send email to web2py@googlegroups.com
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en
-~--~~~~--~~--~--~---



[web2py:26983] Re: MySQL - OperationalError: Error on rename (errno: 150)

2009-07-20 Thread David Zejda

-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

My tables are actually InnoDB - they are generated by DAL.

D.

mdipierro napsal(a):
 The DAL assumes InnoDB, not MYISAM. Perhaps that is the problem?
 
 On Jul 20, 12:05 pm, David Zejda d...@atlas.cz wrote:
 Hello,
 
 my db backend is MySQL 5.0.51a-24 on Linux.
 
 If I try to gently alter already generated table schema, like to rename
 
 SQLField('relation', 'text', requires = \
IS_NULL_OR(IS_IN_DB(db, 'relation_type.id', 'relation_type.id',
 multiple=True)))
 
 to
 
 SQLField('relation_type', 'text', requires = \
IS_NULL_OR(IS_IN_DB(db, 'relation_type.id', 'relation_type.id',
 multiple=True)))
 
 i get this:
 
 Traceback (most recent call last):
   File /home/zejdad/!a/jfind/web2py/gluon/restricted.py, line 98, in
 restricted
 exec ccode in environment
   File /home/zejdad/!a/jfind/web2py/applications/jfind/models/db.py,
 line 346, in module
 migrate=person
   File /home/zejdad/!a/jfind/web2py/gluon/sql.py, line 938, in
 define_table
 raise e
 OperationalError: (1025, Error on rename of './jfind/#sql-ac1_5e' to
 './jfind/person' (errno: 150))
 
 Maybe, it is related to the troubles mentioned there:
 
 http://forums.mysql.com/read.php?22,95361
 
 Please, do you have any experiences with a such type of errors?
 
 I would like to test it with MyISAM instead of InnoDB tables, but it is
 not easy to change it in already generated and interrelated tables:
 
 ALTER TABLE `person` ENGINE = MYISAM
 
 #1217 - Cannot delete or update a parent row: a foreign key constraint
 fails
 
 Or should I try other MySQL version?
 
 Thank you for advices!
 
 David
 
-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.9 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iEYEARECAAYFAkpk4xUACgkQ3oCkkciamVHpegCdGv/WIBedzYdwvC7AitzbIXcu
5x4AoLAnieI0p68loUsdiyX7Vde/ScrU
=3bHg
-END PGP SIGNATURE-

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To post to this group, send email to web2py@googlegroups.com
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en
-~--~~~~--~~--~--~---



[web2py:26985] Re: SQLForm and IS_NULL_OR(IS_IN_DB( ... multiple=True))

2009-07-20 Thread David Zejda

-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

OK, I will go without None, zero choice will be sufficient, if I alter
the program a bit...

mdipierro napsal(a):
 You should not combine
 
 IS_IN_DB(db, 'table.id', 'table.name', multiple=True)
 with
 IS_NULL_OR()
 
 because if multiple choices are permitted, zero choices are also
 permitted.
 
 Massimo
-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.9 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iEYEARECAAYFAkpk5J0ACgkQ3oCkkciamVGG+gCgh3+SniHQ+jU2ZvJDCFPpbSAo
TbAAnR1eqyMUT8loA90H95DuaQg7oAnM
=nPhF
-END PGP SIGNATURE-

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To post to this group, send email to web2py@googlegroups.com
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en
-~--~~~~--~~--~--~---



[web2py:26987] Re: override default model values in SQLFORM

2009-07-20 Thread David Zejda

-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

Oh sorry, I just overlooked the initial reply.. :o)

Hans Donner napsal(a):
 David, 10 minutes after your original post there was already a reply:
 
 http://groups.google.com/group/web2py/browse_thread/thread/de36120b9337f00d/1fde78aa5827a84c?hl=enlnk=gstq=override+default+model+values+in+SQLFORM#1fde78aa5827a84c
-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.9 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iEYEARECAAYFAkpk5YEACgkQ3oCkkciamVFtJwCdE1ARh9teph1nzhtN70gdKWXU
sNQAoJ3lEgXwgGCidr4wpnAmKleyc3UA
=DlnB
-END PGP SIGNATURE-

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To post to this group, send email to web2py@googlegroups.com
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en
-~--~~~~--~~--~--~---



[web2py:26124] Re: override default model values in SQLFORM

2009-07-10 Thread David Zejda

-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

Please, do you have any advices?

David Zejda napsal(a):
 Hello,
 
 I have table with a subject field, with default value specified in model.
 
 Now I would like to generate forms to add and update records.
 In the forms the default value specified in the model has to be
 overriden on certain conditions.
 
 I tried these:
 
 form.vars.subject = another default value
 
 form.custom.dspval.subject = another default value
 
 form.custom.inpval.subject = another default value
 
 But none of them works, still there are model default values pre-filled in
 the form fields.
 
 Please, could you help?
 
 Thanks in advance..
 
 David
-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.9 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iEYEARECAAYFAkpXPrEACgkQ3oCkkciamVGzkACgo5qrBcRjdXm975QkirF85B9F
qOAAoIaIojQTG4Jfx2bhdet7Hx0VzQMz
=02Cn
-END PGP SIGNATURE-

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
web2py Web Framework group.
To post to this group, send email to web2py@googlegroups.com
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en
-~--~~~~--~~--~--~---



[web2py:25576] override default model values in SQLFORM

2009-07-03 Thread David Zejda

-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

Hello,

I have table with a subject field, with default value specified in model.

Now I would like to generate forms to add and update records.
In the forms the default value specified in the model has to be
overriden on certain conditions.

I tried these:

form.vars.subject = another default value

form.custom.dspval.subject = another default value

form.custom.inpval.subject = another default value

But none of them works, still there are model default values filled in
the form fields.

Please, could you help?

Thanks in advance..

David
-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.9 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iEYEARECAAYFAkpOSuIACgkQ3oCkkciamVGjGACeNxJre32E0Kg60BDZCSC3LG1E
gL0An2cy1fws0OaHvhaIkBrnNN5WgYSZ
=zZus
-END PGP SIGNATURE-

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
web2py Web Framework group.
To post to this group, send email to web2py@googlegroups.com
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en
-~--~~~~--~~--~--~---



[web2py:24883] Re: IDE with debugging support for web2py

2009-06-24 Thread David Zejda

-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

Hello, I added the entire web2py. Then I start the debugging process on
web2py.py. Breakpoints in app sources works for me this way.

David

Randell Benavidez napsal(a):
 When adding web2py as a new project in Eclipse, do you add the entire
 web2py folder or just the applications folder or just the specific
 applications?
 
 On Jun 14, 5:49 am, David Zejda d...@atlas.cz wrote:
 Hello,
 
 I did not perform a deep comparison. I only installed the tools and
 checked the basic functionality with emphasize on debugging of web2py,
 which effectively disqualified half of them. Maybe, if Wing IDE is
 opensoureced and free, I would examine it more deeply, but Eclipse/PyDev
 satisfies my needs till now, so I do not feel need to do so..
 
 David
 
 Randell napsal(a):
 
 Hi, I was googling for the comparison between PyDev and Wing IDE and
 one of the results led me in this thread.  I was wondering whether you
 were able to compare PyDev and Wing IDE deeply and what the results
 are.  You response will be greatly appreciated.  Thank you!
 On May 1, 4:26 am, David Zejda d...@atlas.cz wrote:
 Today I evaluated several Python IDEs, with results:
 Idle
  for me, debugging does not work
 Eric4
  debugging does not work, breakpoints in models and controllers
  are silently passed over
 Netbeans/Python
  debugging does not work; debugging session is terminated by error
  during the web2py startup
 Wing IDE
  debugging seems to work
 Eclipse/PyDev
  debugging seems to work
 I'm going to examine the Eclipse/PyDev more deeply..
 D.
-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.9 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iEYEARECAAYFAkpCB78ACgkQ3oCkkciamVE4MgCcCkgAGkm4G77SaSphrI8hRBxj
SEoAoJ+5dLGVFFHrjmT6VlKbVwIzx5bi
=pREV
-END PGP SIGNATURE-

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
web2py Web Framework group.
To post to this group, send email to web2py@googlegroups.com
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en
-~--~~~~--~~--~--~---



[web2py:24805] simple wysiwyg editor for SQLFORM

2009-06-23 Thread David Zejda

-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

Hello,

thanks for web2py, I still feel the fresh air of a productive development :)

And now the question. There is a table with a text field. I'd like to
integrate SQLFORM and a wysiwyg editor of some kind to operate on the
field. I do not have any special requirements on tha markup at the
background, I just want to allow users to decorate the text in a fun
way, and than to be able to display it respectively as a part of a page
content. Maybe, the background markup could be ReST, MediaWiki or even
pure HTML subset, it does not matter. I do not need anything
complicated, e.g. image embedding or tables, just paragraphs, bold,
italic, font size and color.

Please, have you any ideas, which editor and how to interconnect it with
a web2py app?

Thank you
with regards
David
-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.9 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iEYEARECAAYFAkpBCX4ACgkQ3oCkkciamVHj1ACdF2ugAfvV98CVH1maDqLY9doN
zJwAoLLDvM2xOJFjQx4qOw5VHOKJj4xO
=vrdN
-END PGP SIGNATURE-

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
web2py Web Framework group.
To post to this group, send email to web2py@googlegroups.com
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en
-~--~~~~--~~--~--~---



[web2py:24811] Re: simple wysiwyg editor for SQLFORM

2009-06-23 Thread David Zejda

-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

I just see nicEdit and the correspodning thread

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

sorry for asking. I'll give it a try.

D.

David Zejda napsal(a):
 Hello,
 
 thanks for web2py, I still feel the fresh air of a productive development :)
 
 And now the question. There is a table with a text field. I'd like to
 integrate SQLFORM and a wysiwyg editor of some kind to operate on the
 field. I do not have any special requirements on tha markup at the
 background, I just want to allow users to decorate the text in a fun
 way, and than to be able to display it respectively as a part of a page
 content. Maybe, the background markup could be ReST, MediaWiki or even
 pure HTML subset, it does not matter. I do not need anything
 complicated, e.g. image embedding or tables, just paragraphs, bold,
 italic, font size and color.
 
 Please, have you any ideas, which editor and how to interconnect it with
 a web2py app?
 
 Thank you
 with regards
 David
-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.9 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iEYEARECAAYFAkpBEdMACgkQ3oCkkciamVGMHQCgiihI6nOqHJENZgVH94O/bMoK
x9YAoI7WmWtvWOSnNlYqwIIGgZ4HKDbL
=33bx
-END PGP SIGNATURE-

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
web2py Web Framework group.
To post to this group, send email to web2py@googlegroups.com
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en
-~--~~~~--~~--~--~---



[web2py:24107] Re: IDE with debugging support for web2py

2009-06-13 Thread David Zejda

-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

Hello,

I did not perform a deep comparison. I only installed the tools and
checked the basic functionality with emphasize on debugging of web2py,
which effectively disqualified half of them. Maybe, if Wing IDE is
opensoureced and free, I would examine it more deeply, but Eclipse/PyDev
satisfies my needs till now, so I do not feel need to do so..

David

Randell napsal(a):
 Hi, I was googling for the comparison between PyDev and Wing IDE and
 one of the results led me in this thread.  I was wondering whether you
 were able to compare PyDev and Wing IDE deeply and what the results
 are.  You response will be greatly appreciated.  Thank you!
 
 On May 1, 4:26 am, David Zejda d...@atlas.cz wrote:
 Today I evaluated several Python IDEs, with results:
 
 Idle
  for me, debugging does not work
 
 Eric4
  debugging does not work, breakpoints in models and controllers
  are silently passed over
 
 Netbeans/Python
  debugging does not work; debugging session is terminated by error
  during the web2py startup
 
 Wing IDE
  debugging seems to work
 
 Eclipse/PyDev
  debugging seems to work
 
 I'm going to examine the Eclipse/PyDev more deeply..
 
 D.
-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.9 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iEYEARECAAYFAko0HuAACgkQ3oCkkciamVFP8QCeN+eI/ZRkLevpI8lScdeC1JJq
dMMAn1aKZTg06O7Fytv7Ix/6IXfQwT5C
=epTP
-END PGP SIGNATURE-

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
web2py Web Framework group.
To post to this group, send email to web2py@googlegroups.com
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en
-~--~~~~--~~--~--~---



[web2py:20892] IDE with debugging support for web2py

2009-04-30 Thread David Zejda

-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

Today I evaluated several Python IDEs, with results:

Idle
 for me, debugging does not work

Eric4
 debugging does not work, breakpoints in models and controllers
 are silently passed over

Netbeans/Python
 debugging does not work; debugging session is terminated by error
 during the web2py startup

Wing IDE
 debugging seems to work

Eclipse/PyDev
 debugging seems to work

I'm going to examine the Eclipse/PyDev more deeply..

D.
-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.9 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iEYEARECAAYFAkn6CXcACgkQ3oCkkciamVEtgQCfdQMrjiqieBi32UgHK54fMsXt
WnEAn3QU/6cbr95+byFxoJMRCJ1xUxoZ
=q3Ct
-END PGP SIGNATURE-

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
web2py Web Framework group.
To post to this group, send email to web2py@googlegroups.com
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en
-~--~~~~--~~--~--~---



[web2py:20623] insert() values provided in a dictionary

2009-04-27 Thread David Zejda

-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

There is a table:

db.define_table('country',
SQLField('code'),
SQLField('name'))

I know, I can do:

db.country.insert(code=UK, name=United Kingdom)

But I have values to be inserted in a dictionary:

row = { code:UK, name:United Kingdom }

I would like to do it in a general way:

db.country.insert(row)

Or so. Is it possible somehow?

Thank you!
David
-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.9 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iEYEARECAAYFAkn1skoACgkQ3oCkkciamVH7cQCfbJNDypx0+UDlEHWcKOt4EVDe
XZEAn0zlhLrdyZ+0uNwLKpg+4wNPYBuS
=i4qG
-END PGP SIGNATURE-

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
web2py Web Framework group.
To post to this group, send email to web2py@googlegroups.com
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en
-~--~~~~--~~--~--~---



[web2py:20572] Re: Using local CAS provider with app in the same web2py instance

2009-04-26 Thread David Zejda

-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

Massimo, thanks.

Now, if I try the exposed login controller in my application, I'm
getting ticket with

id,email,name=session.token
TypeError: 'NoneType' object is not iterable

instead of login page being shown.

In CAS.login_url there is a http://localhost:8000/cas/cas/login, which
is correct - on this URL there a functional CAS login page sits.

Should I do something more in the application, than to

1) add unmodified cas.py to the models
2) set the CAS.login_url, CAS.check_url, CAS.logout_url and CAS.my_url
3) expose the login()
?

BTW the CAS.my_url contains link to the login() exposed above, I hope,
this is correct.

With regards,

David

mdipierro napsal(a):
 In one of the model files you need to setup HOST, this is something
 like http://hostname:port; as visible by your authentication
 provider. web2py does not always gets it right because may be running
 behind a proxy.
 
 Massimo
 
 
 On Apr 23, 5:49 pm, dvid d...@atlas.cz wrote:
 I added the CAS service provider as a cas application to my web2py,
 changed db to MySQL and configured email.py. Itself it seems to work,
 or at least, there are no errors reported. I can successfully
 register, login, logout, change password.

 But I'm doing something wrong, when trying to use it as a provider in
 the separate app called jfind.

 I added the cas.py to the jfind models without modifications.

 Currently, my controller called users in the jfind app begins with:

 CAS.login_url='%s/cas/cas/login' % (HOST)
 CAS.check_url='%s/cas/cas/check' % (HOST)
 CAS.logout_url='%s/cas/cas/logout' % (HOST)
 CAS.my_url='%s/%s/users/login' % (HOST,request.application)

 def login():
 session.token=CAS.login(request)
 id,email,name=session.token
 return dict()
 ...

 Now the login function, instead of HTML with something more
 meaningful, generates only:

 You are being redirected a href=localhost:8000/cas/cas/login?
 service=localhost:8000/jfind/users/loginhere/a

 Please, what I'm missing?

 Thanks!
-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.9 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iEYEARECAAYFAkn02UsACgkQ3oCkkciamVG2YQCgqQvX+LQx8LJ135T1ihlWfJ98
cbkAn2f+uOCP4/DrAwOs17Gg7jlUmev3
=x77y
-END PGP SIGNATURE-

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
web2py Web Framework group.
To post to this group, send email to web2py@googlegroups.com
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en
-~--~~~~--~~--~--~---