[web2py] Re: Using Jython with web2py

2010-11-27 Thread mdipierro
did you add the driver to the java classpath?
as I said the bug is not the cause of the problem. this is not a
web2py problem in fact. As you can see from man posts:

http://www.google.com/search?q=SQLException%3A+java.sql.SQLException%3A+No+suitable+driver+found+sqlite&ie=utf-8&oe=utf-8&aq=t&rls=org.mozilla:en-US:official&client=firefox-a

this is a java.sql misconfiguration.



On Nov 28, 1:28 am, pierreth  wrote:
> On Nov 28, 1:49 am, mdipierro  wrote:
>
>
>
> > I found a bug. In gluon/sql.py
>
> > replace
>
> >         elif is_jdbc and self._uri.startswith('sqlite://'):
> >             self._dbname='sqlite'
> >             if uri[9] != '/':
> >                 dbpath = os.path.join(self._folder, uri[14:])
> >             else:
> >                 dbpath = uri[14:]
>
> > with
>
> >         elif is_jdbc and self._uri.startswith('sqlite://'):
> >             self._dbname='sqlite'
> >             if uri[9] != '/':
> >                 dbpath = os.path.join(self._folder, uri[9:])
> >             else:
> >                 dbpath = uri[9:]
>
> > Does this fix anything?
>
> Sorry, I have the same error with this new code. And the file
> 'ge.slite' is still not there.


[web2py] Re: Using Jython with web2py

2010-11-27 Thread pierreth
On Nov 28, 1:49 am, mdipierro  wrote:
> I found a bug. In gluon/sql.py
>
> replace
>
>         elif is_jdbc and self._uri.startswith('sqlite://'):
>             self._dbname='sqlite'
>             if uri[9] != '/':
>                 dbpath = os.path.join(self._folder, uri[14:])
>             else:
>                 dbpath = uri[14:]
>
> with
>
>         elif is_jdbc and self._uri.startswith('sqlite://'):
>             self._dbname='sqlite'
>             if uri[9] != '/':
>                 dbpath = os.path.join(self._folder, uri[9:])
>             else:
>                 dbpath = uri[9:]
>
> Does this fix anything?

Sorry, I have the same error with this new code. And the file
'ge.slite' is still not there.


[web2py] Re: Using Jython with web2py

2010-11-27 Thread mdipierro
There are two issues

the bug in the line
dbpath = os.path.join(self._folder, uri[14:])
instread of
dbpath = os.path.join(self._folder, uri[9:])

is cutting "sqlite://storage.sqlite" short into "ge.sqlite" instead of
"storage.sqlite". This can be fixed by replacing 14 with 9.

Yet, the file "ge.sqlite" or "storage.sqlite" is not supposed to be
there but created by the line:

zxJDBC.connect(java.sql.DriverManager.getConnection('jdbc:sqlite:'+dbpath))

you are getting an error at this line:
SQLException: java.sql.SQLException: No suitable driver found for
jdbc:sqlite:/media/pierreth-backup/work/web2py/applications/welcome/
databases/ge.sqlite

That  means that your sqlite driver is not in the java classpath.

On Nov 28, 1:06 am, pierreth  wrote:
> On Nov 28, 1:49 am, mdipierro  wrote:
>
>
>
> > I found a bug. In gluon/sql.py
>
> > replace
>
> >         elif is_jdbc and self._uri.startswith('sqlite://'):
> >             self._dbname='sqlite'
> >             if uri[9] != '/':
> >                 dbpath = os.path.join(self._folder, uri[14:])
> >             else:
> >                 dbpath = uri[14:]
>
> > with
>
> >         elif is_jdbc and self._uri.startswith('sqlite://'):
> >             self._dbname='sqlite'
> >             if uri[9] != '/':
> >                 dbpath = os.path.join(self._folder, uri[9:])
> >             else:
> >                 dbpath = uri[9:]
>
> > Does this fix anything?
>
> Sorry, I have the same error with this new code. And the file
> 'ge.slite' is still not there.


[web2py] Re: Using Jython with web2py

2010-11-27 Thread pierreth
On Nov 28, 1:49 am, mdipierro  wrote:
> I found a bug. In gluon/sql.py
>
> replace
>
>         elif is_jdbc and self._uri.startswith('sqlite://'):
>             self._dbname='sqlite'
>             if uri[9] != '/':
>                 dbpath = os.path.join(self._folder, uri[14:])
>             else:
>                 dbpath = uri[14:]
>
> with
>
>         elif is_jdbc and self._uri.startswith('sqlite://'):
>             self._dbname='sqlite'
>             if uri[9] != '/':
>                 dbpath = os.path.join(self._folder, uri[9:])
>             else:
>                 dbpath = uri[9:]
>
> Does this fix anything?

Sorry, I have the same error with this new code. And the file
'ge.slite' is still not there.


[web2py] Re: Using Jython with web2py

2010-11-27 Thread pierreth
On Nov 28, 12:48 am, mdipierro  wrote:
> In gluon/sql.py there are these lines:
>
> try:
>     from com.ziclix.python.sql import zxJDBC
>     import java.sql
>     from org.sqlite import JDBC
>     drivers.append('zxJDBC')
>     logger.warning('zxJDBC support is experimental')
>     is_jdbc = True
> except:
>     logger.debug('no zxJDBC driver')
>     is_jdbc = False
>
> somehow the exception is raised.

I see the message 'zxJDBC support is experimental' printed at the
console.

I don't know why but now I have a different error:

Traceback (most recent call last):
  File "/media/pierreth-backup/work/web2py/gluon/main.py", line 425,
in wsgibase
serve_controller(request, response, session)
  File "/media/pierreth-backup/work/web2py/gluon/main.py", line 425,
in wsgibase
serve_controller(request, response, session)
  File "/media/pierreth-backup/work/web2py/gluon/main.py", line 187,
in serve_controller
run_models_in(environment)
  File "/media/pierreth-backup/work/web2py/gluon/compileapp.py", line
351, in run_models_in
restricted(code, environment, layer)
  File "/media/pierreth-backup/work/web2py/gluon/restricted.py", line
188, in restricted
exec ccode in environment
  File "/media/pierreth-backup/work/web2py/gluon/restricted.py", line
188, in restricted
exec ccode in environment
  File "/media/pierreth-backup/work/web2py/applications/welcome/models/
db.py", line 15, in 
db = DAL('sqlite://storage.sqlite')   # if not, use SQLite or
other DB
  File "/media/pierreth-backup/work/web2py/gluon/sql.py", line 4064,
in DAL
return SQLDB(uri, pool_size=pool_size, folder=folder,
  File "/media/pierreth-backup/work/web2py/gluon/sql.py", line 4064,
in DAL
return SQLDB(uri, pool_size=pool_size, folder=folder,
  File "/media/pierreth-backup/work/web2py/gluon/sql.py", line 1211,
in __init__
self._pool_connection(lambda dbpath=dbpath:
zxJDBC.connect(java.sql.DriverManager.getConnection('jdbc:sqlite:'+dbpath)))
  File "/media/pierreth-backup/work/web2py/gluon/sql.py", line 893, in
_pool_connection
self._connection = f()
  File "/media/pierreth-backup/work/web2py/gluon/sql.py", line 1211,
in 
self._pool_connection(lambda dbpath=dbpath:
zxJDBC.connect(java.sql.DriverManager.getConnection('jdbc:sqlite:'+dbpath)))
SQLException: java.sql.SQLException: No suitable driver found for
jdbc:sqlite:/media/pierreth-backup/work/web2py/applications/welcome/
databases/ge.sqlite


The file '/media/pierreth-backup/work/web2py/applications/welcome/
databases/ge.sqlite' does not exists in the directory.


[web2py] Re: Using Jython with web2py

2010-11-27 Thread mdipierro
I found a bug. In gluon/sql.py

replace

elif is_jdbc and self._uri.startswith('sqlite://'):
self._dbname='sqlite'
if uri[9] != '/':
dbpath = os.path.join(self._folder, uri[14:])
else:
dbpath = uri[14:]


with

elif is_jdbc and self._uri.startswith('sqlite://'):
self._dbname='sqlite'
if uri[9] != '/':
dbpath = os.path.join(self._folder, uri[9:])
else:
dbpath = uri[9:]


Does this fix anything?



On Nov 28, 12:40 am, pierreth  wrote:
> On Nov 28, 12:48 am, mdipierro  wrote:
>
> > In gluon/sql.py there are these lines:
>
> > try:
> >     from com.ziclix.python.sql import zxJDBC
> >     import java.sql
> >     from org.sqlite import JDBC
> >     drivers.append('zxJDBC')
> >     logger.warning('zxJDBC support is experimental')
> >     is_jdbc = True
> > except:
> >     logger.debug('no zxJDBC driver')
> >     is_jdbc = False
>
> > somehow the exception is raised.
>
> I see the message 'zxJDBC support is experimental' printed at the
> console.
>
> I don't know why but now I have a different error:
>
> Traceback (most recent call last):
>   File "/media/pierreth-backup/work/web2py/gluon/main.py", line 425,
> in wsgibase
>     serve_controller(request, response, session)
>   File "/media/pierreth-backup/work/web2py/gluon/main.py", line 425,
> in wsgibase
>     serve_controller(request, response, session)
>   File "/media/pierreth-backup/work/web2py/gluon/main.py", line 187,
> in serve_controller
>     run_models_in(environment)
>   File "/media/pierreth-backup/work/web2py/gluon/compileapp.py", line
> 351, in run_models_in
>     restricted(code, environment, layer)
>   File "/media/pierreth-backup/work/web2py/gluon/restricted.py", line
> 188, in restricted
>     exec ccode in environment
>   File "/media/pierreth-backup/work/web2py/gluon/restricted.py", line
> 188, in restricted
>     exec ccode in environment
>   File "/media/pierreth-backup/work/web2py/applications/welcome/models/
> db.py", line 15, in 
>     db = DAL('sqlite://storage.sqlite')       # if not, use SQLite or
> other DB
>   File "/media/pierreth-backup/work/web2py/gluon/sql.py", line 4064,
> in DAL
>     return SQLDB(uri, pool_size=pool_size, folder=folder,
>   File "/media/pierreth-backup/work/web2py/gluon/sql.py", line 4064,
> in DAL
>     return SQLDB(uri, pool_size=pool_size, folder=folder,
>   File "/media/pierreth-backup/work/web2py/gluon/sql.py", line 1211,
> in __init__
>     self._pool_connection(lambda dbpath=dbpath:
> zxJDBC.connect(java.sql.DriverManager.getConnection('jdbc:sqlite:'+dbpath)))
>   File "/media/pierreth-backup/work/web2py/gluon/sql.py", line 893, in
> _pool_connection
>     self._connection = f()
>   File "/media/pierreth-backup/work/web2py/gluon/sql.py", line 1211,
> in 
>     self._pool_connection(lambda dbpath=dbpath:
> zxJDBC.connect(java.sql.DriverManager.getConnection('jdbc:sqlite:'+dbpath)))
> SQLException: java.sql.SQLException: No suitable driver found for
> jdbc:sqlite:/media/pierreth-backup/work/web2py/applications/welcome/
> databases/ge.sqlite
>
> The file '/media/pierreth-backup/work/web2py/applications/welcome/
> databases/ge.sqlite' does not exists in the directory.


[web2py] Re: Using Jython with web2py

2010-11-27 Thread pierreth
On Nov 28, 12:48 am, mdipierro  wrote:
> In gluon/sql.py there are these lines:
>
> try:
>     from com.ziclix.python.sql import zxJDBC
>     import java.sql
>     from org.sqlite import JDBC
>     drivers.append('zxJDBC')
>     logger.warning('zxJDBC support is experimental')
>     is_jdbc = True
> except:
>     logger.debug('no zxJDBC driver')
>     is_jdbc = False
>
> somehow the exception is raised.

I see the message 'zxJDBC support is experimental' printed at the
console.

I don't know why but now I have a different error:

Traceback (most recent call last):
  File "/media/pierreth-backup/work/web2py/gluon/main.py", line 425,
in wsgibase
serve_controller(request, response, session)
  File "/media/pierreth-backup/work/web2py/gluon/main.py", line 425,
in wsgibase
serve_controller(request, response, session)
  File "/media/pierreth-backup/work/web2py/gluon/main.py", line 187,
in serve_controller
run_models_in(environment)
  File "/media/pierreth-backup/work/web2py/gluon/compileapp.py", line
351, in run_models_in
restricted(code, environment, layer)
  File "/media/pierreth-backup/work/web2py/gluon/restricted.py", line
188, in restricted
exec ccode in environment
  File "/media/pierreth-backup/work/web2py/gluon/restricted.py", line
188, in restricted
exec ccode in environment
  File "/media/pierreth-backup/work/web2py/applications/welcome/models/
db.py", line 15, in 
db = DAL('sqlite://storage.sqlite')   # if not, use SQLite or
other DB
  File "/media/pierreth-backup/work/web2py/gluon/sql.py", line 4064,
in DAL
return SQLDB(uri, pool_size=pool_size, folder=folder,
  File "/media/pierreth-backup/work/web2py/gluon/sql.py", line 4064,
in DAL
return SQLDB(uri, pool_size=pool_size, folder=folder,
  File "/media/pierreth-backup/work/web2py/gluon/sql.py", line 1211,
in __init__
self._pool_connection(lambda dbpath=dbpath:
zxJDBC.connect(java.sql.DriverManager.getConnection('jdbc:sqlite:'+dbpath)))
  File "/media/pierreth-backup/work/web2py/gluon/sql.py", line 893, in
_pool_connection
self._connection = f()
  File "/media/pierreth-backup/work/web2py/gluon/sql.py", line 1211,
in 
self._pool_connection(lambda dbpath=dbpath:
zxJDBC.connect(java.sql.DriverManager.getConnection('jdbc:sqlite:'+dbpath)))
SQLException: java.sql.SQLException: No suitable driver found for
jdbc:sqlite:/media/pierreth-backup/work/web2py/applications/welcome/
databases/ge.sqlite


The file '/media/pierreth-backup/work/web2py/applications/welcome/
databases/ge.sqlite' does not exists in the directory.


[web2py] Re: Using Jython with web2py

2010-11-27 Thread pierreth
On Nov 28, 12:46 am, mdipierro  wrote:
> good. Can you try these three statements form shell?
>
> from com.ziclix.python.sql import zxJDBC
> import java.sql
> from org.sqlite import JDBC
>
> Massimo

All these statements work without problem.


[web2py] Re: Using Jython with web2py

2010-11-27 Thread mdipierro
In gluon/sql.py there are these lines:

try:
from com.ziclix.python.sql import zxJDBC
import java.sql
from org.sqlite import JDBC
drivers.append('zxJDBC')
logger.warning('zxJDBC support is experimental')
is_jdbc = True
except:
logger.debug('no zxJDBC driver')
is_jdbc = False

somehow the exception is raised.



On Nov 27, 11:46 pm, mdipierro  wrote:
> good. Can you try these three statements form shell?
>
> from com.ziclix.python.sql import zxJDBC
> import java.sql
> from org.sqlite import JDBC
>
> Massimo
>
> On Nov 27, 10:54 pm, pierreth  wrote:
>
> > On Nov 26, 6:41 pm, mdipierro  wrote:
>
> > > The instructions are here:http://web2py.com/book/default/chapter/12#Jython
>
> > > Make sure you have zxJDBC.
>
> > I don't understand. zxJDBC is included with Jython from long time ago.
>
> > I can do:
>
> > from com.ziclix.python.sql import zxJDBC
>
> > I don't remember having done the installation of this separately.
>
> > Could you explain?
>
>


[web2py] Re: Using Jython with web2py

2010-11-27 Thread mdipierro
good. Can you try these three statements form shell?

from com.ziclix.python.sql import zxJDBC
import java.sql
from org.sqlite import JDBC

Massimo

On Nov 27, 10:54 pm, pierreth  wrote:
> On Nov 26, 6:41 pm, mdipierro  wrote:
>
> > The instructions are here:http://web2py.com/book/default/chapter/12#Jython
>
> > Make sure you have zxJDBC.
>
> I don't understand. zxJDBC is included with Jython from long time ago.
>
> I can do:
>
> from com.ziclix.python.sql import zxJDBC
>
> I don't remember having done the installation of this separately.
>
> Could you explain?


[web2py] Re: Using Jython with web2py

2010-11-27 Thread pierreth
On Nov 26, 6:41 pm, mdipierro  wrote:
> The instructions are here:http://web2py.com/book/default/chapter/12#Jython
>
> Make sure you have zxJDBC.

I don't understand. zxJDBC is included with Jython from long time ago.

I can do:

from com.ziclix.python.sql import zxJDBC

I don't remember having done the installation of this separately.

Could you explain?


[web2py] Re: onvalidation only called if there are no form errors

2010-11-27 Thread mr.freeze
Thanks. I will make a patch and test it.

On Nov 27, 10:13 pm, mdipierro  wrote:
> > if isinstance(onvalidation, dict):
> >     before = onvalidation.get('before',lambda form: None)
> >     after = onvalidation.get('after',lambda form: None)
> >     if before:
> >         before(self)
> >     if status and after:
> >         after(self)
>
> ok with the part above
>
> > elif isinstance(onvalidation, (list,tuple):
> >     [f(self) for f in onvalidation]
>
> this is done already inside FORM.accepts (which means
> onvalidation['before'] can be a list or tuple.
>
> It is more complex than it needs to be but if it works for you, works
> for me.


[web2py] Re: onvalidation only called if there are no form errors

2010-11-27 Thread mdipierro
> if isinstance(onvalidation, dict):
>     before = onvalidation.get('before',lambda form: None)
>     after = onvalidation.get('after',lambda form: None)
>     if before:
>         before(self)
>     if status and after:
>         after(self)

ok with the part above

> elif isinstance(onvalidation, (list,tuple):
>     [f(self) for f in onvalidation]

this is done already inside FORM.accepts (which means
onvalidation['before'] can be a list or tuple.

It is more complex than it needs to be but if it works for you, works
for me.


[web2py] Re: onvalidation only called if there are no form errors

2010-11-27 Thread mr.freeze
What about a dict? This isn't complete but you get the idea. Would it
break something too?

if isinstance(onvalidation, dict):
before = onvalidation.get('before',lambda form: None)
after = onvalidation.get('after',lambda form: None)
if before:
before(self)
if status and after:
after(self)
elif isinstance(onvalidation, (list,tuple):
[f(self) for f in onvalidation]
else:
onvalidation(self)


On Nov 27, 9:37 pm, mdipierro  wrote:
> Ignor my current proposal. It would break something else. Needs more
> thought.
>
> Massimo
>
> On Nov 27, 9:35 pm, mdipierro  wrote:
>
> > Here is my proposal.
>
> > if isinstance(onvalidation,tuple):
> >     use onvalidation[0] as Nathan suggests (pre validation)
> >     use onvalidation[1] as currently used (post validation)
> > else:
> >     everything works as it does now. (post validation only)
>
> > If this works for Nathan, please send me a patch. I do not want to
> > have another config flag for this.
>
> > Massimo
>
> > On Nov 27, 7:03 pm, "mr.freeze"  wrote:
>
> > > Thanks Denes. The example is over-simplified. My actual forms are much
> > > more complex and have many inter-dependencies. It sounds like the
> > > change is not backwards compatible so I will probably just branch
> > > html.py.
>
> > > On Nov 27, 6:02 pm, DenesL  wrote:
>
> > > > ... or just change your catalytic_converter_type requires to
>
> > > > IS_IN_SET(['', 'one','two','three'], zero=None),
>
> > > > and use your code.
>
> > > > On Nov 27, 6:20 pm, DenesL  wrote:
>
> > > > > mr.freeze, you can still use the top part as posted (or similar) and
> > > > > change the bottom to use crud.
>
> > > > > On Nov 27, 5:25 pm, "mr.freeze"  wrote:
>
> > > > > > I want catalytic_converter_type (abbreviated to cc_type below) to be
> > > > > > required for cars after 1975 and be invalid for cars before 1975.
> > > > > > I want to be able to do this:
>
> > > > > > def check_form(form):
> > > > > >     if form.errors.year: return
> > > > > >     if form.vars.year >= 1975:
> > > > > >         if not form.vars.cc_type:
> > > > > >             form.errors.cc_type = 'Required for cars after 1975'
> > > > > >     elif form.vars.cc_type:
> > > > > >         form.errors.cc_type = 'Not valid for cars before 1975'
>
> > > > > > form = crud.create(db.cars,onvalidation=check_form)
>
> > > > > > I can't currently do it because onvalidation will never be called
> > > > > > since validation fails if no cc_type is selected. I know I can hack
> > > > > > around it by switching validators but onvalidation seems like the
> > > > > > proper place for it. It seems like the developer should get a chance
> > > > > > to inspect validation errors but they don't.
>
> > > > > > On Nov 27, 3:19 pm, mdipierro  wrote:
>
> > > > > > > Not sure I understand the test case.
> > > > > > > I do not see how this relevant to the onvalidation issue.
>
> > > > > > > If year>1975 than you want to display and validate the field. If
> > > > > > > year<=1975 you do not want to display the dropbox and/or ignore 
> > > > > > > its
> > > > > > > value.
>
> > > > > > > script=SCRIPT("jQuery('document').ready(function(){var
> > > > > > > y=jQuery('year'); y.keyup(function(){var
> > > > > > > c=jQuery('#cars_catalytic_converter_type__row');if(parseInt(y.val()>1975)c.show();elsec.hide();});});");
>
> > > > > > > db.define_table('cars',
> > > > > > >     Field('make'),
> > > > > > >     Field('model'),
> > > > > > >     Field('year'),
> > > > > > >     Field('catalytic_converter_type',requires =
> > > > > > > IS_IN_SET(('one','two','three'),zero=None),
> > > > > > > comment=script))
>
> > > > > > > On Nov 26, 6:17 pm, "mr.freeze"  wrote:
>
> > > > > > > > Good point. Here is my use case:
>
> > > > > > > > db.define_table('cars',
> > > > > > > >     Field('make'),
> > > > > > > >     Field('model'),
> > > > > > > >     Field('year'),
> > > > > > > >     Field('catalytic_converter_type',requires =
> > > > > > > > IS_IN_SET('one','two','three'),
> > > > > > > > comment='for cars later than 1975'))
>
> > > > > > > > I want catalytic_converter_type to be required if the car year 
> > > > > > > > is
> > > > > > > > greater than 1975. I also want to show an error if
> > > > > > > > catalytic_converter_type is selected and the year is less than 
> > > > > > > > 1975.
> > > > > > > > Allowing the user to see all errors at once would be a bonus 
> > > > > > > > but not a
> > > > > > > > deal breaker. onvalidation seems like the place to handle it 
> > > > > > > > but let
> > > > > > > > me know if there is a better way.
>
> > > > > > > > On Nov 26, 5:48 pm, mdipierro  wrote:
>
> > > > > > > > > Consider this case:
>
> > > > > > > > > db.define_table('numbers',Field('a','integre'),Field('b','integer'))
> > > > > > > > > def validate(form):
> > > > > > > > >     if form.vars.a+form.vars.b>100:
> > > > > > > > >         form.errors.b="a+b must not exceed 100"
> > > > > > > > > form=crud.create(db.numbers,onvalidation=validate)
>
> > > > > > >

[web2py] css food for thought

2010-11-27 Thread Massimo Di Pierro
http://sonspring.com/journal/formalize-css


[web2py] Re: onvalidation only called if there are no form errors

2010-11-27 Thread mdipierro
Ignor my current proposal. It would break something else. Needs more
thought.

Massimo

On Nov 27, 9:35 pm, mdipierro  wrote:
> Here is my proposal.
>
> if isinstance(onvalidation,tuple):
>     use onvalidation[0] as Nathan suggests (pre validation)
>     use onvalidation[1] as currently used (post validation)
> else:
>     everything works as it does now. (post validation only)
>
> If this works for Nathan, please send me a patch. I do not want to
> have another config flag for this.
>
> Massimo
>
> On Nov 27, 7:03 pm, "mr.freeze"  wrote:
>
> > Thanks Denes. The example is over-simplified. My actual forms are much
> > more complex and have many inter-dependencies. It sounds like the
> > change is not backwards compatible so I will probably just branch
> > html.py.
>
> > On Nov 27, 6:02 pm, DenesL  wrote:
>
> > > ... or just change your catalytic_converter_type requires to
>
> > > IS_IN_SET(['', 'one','two','three'], zero=None),
>
> > > and use your code.
>
> > > On Nov 27, 6:20 pm, DenesL  wrote:
>
> > > > mr.freeze, you can still use the top part as posted (or similar) and
> > > > change the bottom to use crud.
>
> > > > On Nov 27, 5:25 pm, "mr.freeze"  wrote:
>
> > > > > I want catalytic_converter_type (abbreviated to cc_type below) to be
> > > > > required for cars after 1975 and be invalid for cars before 1975.
> > > > > I want to be able to do this:
>
> > > > > def check_form(form):
> > > > >     if form.errors.year: return
> > > > >     if form.vars.year >= 1975:
> > > > >         if not form.vars.cc_type:
> > > > >             form.errors.cc_type = 'Required for cars after 1975'
> > > > >     elif form.vars.cc_type:
> > > > >         form.errors.cc_type = 'Not valid for cars before 1975'
>
> > > > > form = crud.create(db.cars,onvalidation=check_form)
>
> > > > > I can't currently do it because onvalidation will never be called
> > > > > since validation fails if no cc_type is selected. I know I can hack
> > > > > around it by switching validators but onvalidation seems like the
> > > > > proper place for it. It seems like the developer should get a chance
> > > > > to inspect validation errors but they don't.
>
> > > > > On Nov 27, 3:19 pm, mdipierro  wrote:
>
> > > > > > Not sure I understand the test case.
> > > > > > I do not see how this relevant to the onvalidation issue.
>
> > > > > > If year>1975 than you want to display and validate the field. If
> > > > > > year<=1975 you do not want to display the dropbox and/or ignore its
> > > > > > value.
>
> > > > > > script=SCRIPT("jQuery('document').ready(function(){var
> > > > > > y=jQuery('year'); y.keyup(function(){var
> > > > > > c=jQuery('#cars_catalytic_converter_type__row');if(parseInt(y.val()>1975)c.show();elsec.hide();});});");
>
> > > > > > db.define_table('cars',
> > > > > >     Field('make'),
> > > > > >     Field('model'),
> > > > > >     Field('year'),
> > > > > >     Field('catalytic_converter_type',requires =
> > > > > > IS_IN_SET(('one','two','three'),zero=None),
> > > > > > comment=script))
>
> > > > > > On Nov 26, 6:17 pm, "mr.freeze"  wrote:
>
> > > > > > > Good point. Here is my use case:
>
> > > > > > > db.define_table('cars',
> > > > > > >     Field('make'),
> > > > > > >     Field('model'),
> > > > > > >     Field('year'),
> > > > > > >     Field('catalytic_converter_type',requires =
> > > > > > > IS_IN_SET('one','two','three'),
> > > > > > > comment='for cars later than 1975'))
>
> > > > > > > I want catalytic_converter_type to be required if the car year is
> > > > > > > greater than 1975. I also want to show an error if
> > > > > > > catalytic_converter_type is selected and the year is less than 
> > > > > > > 1975.
> > > > > > > Allowing the user to see all errors at once would be a bonus but 
> > > > > > > not a
> > > > > > > deal breaker. onvalidation seems like the place to handle it but 
> > > > > > > let
> > > > > > > me know if there is a better way.
>
> > > > > > > On Nov 26, 5:48 pm, mdipierro  wrote:
>
> > > > > > > > Consider this case:
>
> > > > > > > > db.define_table('numbers',Field('a','integre'),Field('b','integer'))
> > > > > > > > def validate(form):
> > > > > > > >     if form.vars.a+form.vars.b>100:
> > > > > > > >         form.errors.b="a+b must not exceed 100"
> > > > > > > > form=crud.create(db.numbers,onvalidation=validate)
>
> > > > > > > > Before the change the function validate is not called if a and 
> > > > > > > > b are
> > > > > > > > not valid integer this never triggering an exception, only 
> > > > > > > > validation
> > > > > > > > errors.
>
> > > > > > > > With your proposed change this would cause an error because
> > > > > > > > form.vars.a is None if request.vars.a does ot pass the default 
> > > > > > > > integer
> > > > > > > > validation. The function validation would be called again and 
> > > > > > > > issue a
> > > > > > > > ticket.
>
> > > > > > > > This is a change of behavior. I am not convinced this change is 
> > > > > > > > a good
> > > > > > > > idea.
>
> > > > > > > > Wh

[web2py] Re: onvalidation only called if there are no form errors

2010-11-27 Thread mdipierro
Here is my proposal.

if isinstance(onvalidation,tuple):
use onvalidation[0] as Nathan suggests (pre validation)
use onvalidation[1] as currently used (post validation)
else:
everything works as it does now. (post validation only)

If this works for Nathan, please send me a patch. I do not want to
have another config flag for this.

Massimo

On Nov 27, 7:03 pm, "mr.freeze"  wrote:
> Thanks Denes. The example is over-simplified. My actual forms are much
> more complex and have many inter-dependencies. It sounds like the
> change is not backwards compatible so I will probably just branch
> html.py.
>
> On Nov 27, 6:02 pm, DenesL  wrote:
>
> > ... or just change your catalytic_converter_type requires to
>
> > IS_IN_SET(['', 'one','two','three'], zero=None),
>
> > and use your code.
>
> > On Nov 27, 6:20 pm, DenesL  wrote:
>
> > > mr.freeze, you can still use the top part as posted (or similar) and
> > > change the bottom to use crud.
>
> > > On Nov 27, 5:25 pm, "mr.freeze"  wrote:
>
> > > > I want catalytic_converter_type (abbreviated to cc_type below) to be
> > > > required for cars after 1975 and be invalid for cars before 1975.
> > > > I want to be able to do this:
>
> > > > def check_form(form):
> > > >     if form.errors.year: return
> > > >     if form.vars.year >= 1975:
> > > >         if not form.vars.cc_type:
> > > >             form.errors.cc_type = 'Required for cars after 1975'
> > > >     elif form.vars.cc_type:
> > > >         form.errors.cc_type = 'Not valid for cars before 1975'
>
> > > > form = crud.create(db.cars,onvalidation=check_form)
>
> > > > I can't currently do it because onvalidation will never be called
> > > > since validation fails if no cc_type is selected. I know I can hack
> > > > around it by switching validators but onvalidation seems like the
> > > > proper place for it. It seems like the developer should get a chance
> > > > to inspect validation errors but they don't.
>
> > > > On Nov 27, 3:19 pm, mdipierro  wrote:
>
> > > > > Not sure I understand the test case.
> > > > > I do not see how this relevant to the onvalidation issue.
>
> > > > > If year>1975 than you want to display and validate the field. If
> > > > > year<=1975 you do not want to display the dropbox and/or ignore its
> > > > > value.
>
> > > > > script=SCRIPT("jQuery('document').ready(function(){var
> > > > > y=jQuery('year'); y.keyup(function(){var
> > > > > c=jQuery('#cars_catalytic_converter_type__row');if(parseInt(y.val()>1975)c.show();elsec.hide();});});");
>
> > > > > db.define_table('cars',
> > > > >     Field('make'),
> > > > >     Field('model'),
> > > > >     Field('year'),
> > > > >     Field('catalytic_converter_type',requires =
> > > > > IS_IN_SET(('one','two','three'),zero=None),
> > > > > comment=script))
>
> > > > > On Nov 26, 6:17 pm, "mr.freeze"  wrote:
>
> > > > > > Good point. Here is my use case:
>
> > > > > > db.define_table('cars',
> > > > > >     Field('make'),
> > > > > >     Field('model'),
> > > > > >     Field('year'),
> > > > > >     Field('catalytic_converter_type',requires =
> > > > > > IS_IN_SET('one','two','three'),
> > > > > > comment='for cars later than 1975'))
>
> > > > > > I want catalytic_converter_type to be required if the car year is
> > > > > > greater than 1975. I also want to show an error if
> > > > > > catalytic_converter_type is selected and the year is less than 1975.
> > > > > > Allowing the user to see all errors at once would be a bonus but 
> > > > > > not a
> > > > > > deal breaker. onvalidation seems like the place to handle it but let
> > > > > > me know if there is a better way.
>
> > > > > > On Nov 26, 5:48 pm, mdipierro  wrote:
>
> > > > > > > Consider this case:
>
> > > > > > > db.define_table('numbers',Field('a','integre'),Field('b','integer'))
> > > > > > > def validate(form):
> > > > > > >     if form.vars.a+form.vars.b>100:
> > > > > > >         form.errors.b="a+b must not exceed 100"
> > > > > > > form=crud.create(db.numbers,onvalidation=validate)
>
> > > > > > > Before the change the function validate is not called if a and b 
> > > > > > > are
> > > > > > > not valid integer this never triggering an exception, only 
> > > > > > > validation
> > > > > > > errors.
>
> > > > > > > With your proposed change this would cause an error because
> > > > > > > form.vars.a is None if request.vars.a does ot pass the default 
> > > > > > > integer
> > > > > > > validation. The function validation would be called again and 
> > > > > > > issue a
> > > > > > > ticket.
>
> > > > > > > This is a change of behavior. I am not convinced this change is a 
> > > > > > > good
> > > > > > > idea.
>
> > > > > > > Why do you need it?
> > > > > > > Other opinions?
>
> > > > > > > Massimo
>
> > > > > > > On Nov 26, 11:34 am, "mr.freeze"  wrote:
>
> > > > > > > > Changing line 1565 of html.py from...
> > > > > > > >         if status and onvalidation:
> > > > > > > > to...
> > > > > > > >         if vars and onvalidation:
>
> > > > > > > > On Nov 26, 11:28 am

[web2py] Re: onvalidation only called if there are no form errors

2010-11-27 Thread mr.freeze
Thanks Denes. The example is over-simplified. My actual forms are much
more complex and have many inter-dependencies. It sounds like the
change is not backwards compatible so I will probably just branch
html.py.

On Nov 27, 6:02 pm, DenesL  wrote:
> ... or just change your catalytic_converter_type requires to
>
> IS_IN_SET(['', 'one','two','three'], zero=None),
>
> and use your code.
>
> On Nov 27, 6:20 pm, DenesL  wrote:
>
> > mr.freeze, you can still use the top part as posted (or similar) and
> > change the bottom to use crud.
>
> > On Nov 27, 5:25 pm, "mr.freeze"  wrote:
>
> > > I want catalytic_converter_type (abbreviated to cc_type below) to be
> > > required for cars after 1975 and be invalid for cars before 1975.
> > > I want to be able to do this:
>
> > > def check_form(form):
> > >     if form.errors.year: return
> > >     if form.vars.year >= 1975:
> > >         if not form.vars.cc_type:
> > >             form.errors.cc_type = 'Required for cars after 1975'
> > >     elif form.vars.cc_type:
> > >         form.errors.cc_type = 'Not valid for cars before 1975'
>
> > > form = crud.create(db.cars,onvalidation=check_form)
>
> > > I can't currently do it because onvalidation will never be called
> > > since validation fails if no cc_type is selected. I know I can hack
> > > around it by switching validators but onvalidation seems like the
> > > proper place for it. It seems like the developer should get a chance
> > > to inspect validation errors but they don't.
>
> > > On Nov 27, 3:19 pm, mdipierro  wrote:
>
> > > > Not sure I understand the test case.
> > > > I do not see how this relevant to the onvalidation issue.
>
> > > > If year>1975 than you want to display and validate the field. If
> > > > year<=1975 you do not want to display the dropbox and/or ignore its
> > > > value.
>
> > > > script=SCRIPT("jQuery('document').ready(function(){var
> > > > y=jQuery('year'); y.keyup(function(){var
> > > > c=jQuery('#cars_catalytic_converter_type__row');if(parseInt(y.val()>1975)c.show();elsec.hide();});});");
>
> > > > db.define_table('cars',
> > > >     Field('make'),
> > > >     Field('model'),
> > > >     Field('year'),
> > > >     Field('catalytic_converter_type',requires =
> > > > IS_IN_SET(('one','two','three'),zero=None),
> > > > comment=script))
>
> > > > On Nov 26, 6:17 pm, "mr.freeze"  wrote:
>
> > > > > Good point. Here is my use case:
>
> > > > > db.define_table('cars',
> > > > >     Field('make'),
> > > > >     Field('model'),
> > > > >     Field('year'),
> > > > >     Field('catalytic_converter_type',requires =
> > > > > IS_IN_SET('one','two','three'),
> > > > > comment='for cars later than 1975'))
>
> > > > > I want catalytic_converter_type to be required if the car year is
> > > > > greater than 1975. I also want to show an error if
> > > > > catalytic_converter_type is selected and the year is less than 1975.
> > > > > Allowing the user to see all errors at once would be a bonus but not a
> > > > > deal breaker. onvalidation seems like the place to handle it but let
> > > > > me know if there is a better way.
>
> > > > > On Nov 26, 5:48 pm, mdipierro  wrote:
>
> > > > > > Consider this case:
>
> > > > > > db.define_table('numbers',Field('a','integre'),Field('b','integer'))
> > > > > > def validate(form):
> > > > > >     if form.vars.a+form.vars.b>100:
> > > > > >         form.errors.b="a+b must not exceed 100"
> > > > > > form=crud.create(db.numbers,onvalidation=validate)
>
> > > > > > Before the change the function validate is not called if a and b are
> > > > > > not valid integer this never triggering an exception, only 
> > > > > > validation
> > > > > > errors.
>
> > > > > > With your proposed change this would cause an error because
> > > > > > form.vars.a is None if request.vars.a does ot pass the default 
> > > > > > integer
> > > > > > validation. The function validation would be called again and issue 
> > > > > > a
> > > > > > ticket.
>
> > > > > > This is a change of behavior. I am not convinced this change is a 
> > > > > > good
> > > > > > idea.
>
> > > > > > Why do you need it?
> > > > > > Other opinions?
>
> > > > > > Massimo
>
> > > > > > On Nov 26, 11:34 am, "mr.freeze"  wrote:
>
> > > > > > > Changing line 1565 of html.py from...
> > > > > > >         if status and onvalidation:
> > > > > > > to...
> > > > > > >         if vars and onvalidation:
>
> > > > > > > On Nov 26, 11:28 am, mdipierro  wrote:
>
> > > > > > > > What would you suggest?
>
> > > > > > > > On Nov 26, 11:10 am, "mr.freeze"  wrote:
>
> > > > > > > > > I see two issues with this:
> > > > > > > > > 1) The form errors found in onvalidation will not be 
> > > > > > > > > displayed if
> > > > > > > > > there are already form errors
> > > > > > > > > 2) The developer never gets a chance to remove form errors 
> > > > > > > > > for certain
> > > > > > > > > conditions (think contingent form fields)
> > > > > > > > > For example, I am using IS_IN_DB on a field but I only want 
> > > > > > > > > it to be
> > > > >

[web2py] Re: onvalidation only called if there are no form errors

2010-11-27 Thread DenesL
... or just change your catalytic_converter_type requires to

IS_IN_SET(['', 'one','two','three'], zero=None),

and use your code.


On Nov 27, 6:20 pm, DenesL  wrote:
> mr.freeze, you can still use the top part as posted (or similar) and
> change the bottom to use crud.
>
> On Nov 27, 5:25 pm, "mr.freeze"  wrote:
>
> > I want catalytic_converter_type (abbreviated to cc_type below) to be
> > required for cars after 1975 and be invalid for cars before 1975.
> > I want to be able to do this:
>
> > def check_form(form):
> >     if form.errors.year: return
> >     if form.vars.year >= 1975:
> >         if not form.vars.cc_type:
> >             form.errors.cc_type = 'Required for cars after 1975'
> >     elif form.vars.cc_type:
> >         form.errors.cc_type = 'Not valid for cars before 1975'
>
> > form = crud.create(db.cars,onvalidation=check_form)
>
> > I can't currently do it because onvalidation will never be called
> > since validation fails if no cc_type is selected. I know I can hack
> > around it by switching validators but onvalidation seems like the
> > proper place for it. It seems like the developer should get a chance
> > to inspect validation errors but they don't.
>
> > On Nov 27, 3:19 pm, mdipierro  wrote:
>
> > > Not sure I understand the test case.
> > > I do not see how this relevant to the onvalidation issue.
>
> > > If year>1975 than you want to display and validate the field. If
> > > year<=1975 you do not want to display the dropbox and/or ignore its
> > > value.
>
> > > script=SCRIPT("jQuery('document').ready(function(){var
> > > y=jQuery('year'); y.keyup(function(){var
> > > c=jQuery('#cars_catalytic_converter_type__row');if(parseInt(y.val()>1975)c.show();elsec.hide();});});");
>
> > > db.define_table('cars',
> > >     Field('make'),
> > >     Field('model'),
> > >     Field('year'),
> > >     Field('catalytic_converter_type',requires =
> > > IS_IN_SET(('one','two','three'),zero=None),
> > > comment=script))
>
> > > On Nov 26, 6:17 pm, "mr.freeze"  wrote:
>
> > > > Good point. Here is my use case:
>
> > > > db.define_table('cars',
> > > >     Field('make'),
> > > >     Field('model'),
> > > >     Field('year'),
> > > >     Field('catalytic_converter_type',requires =
> > > > IS_IN_SET('one','two','three'),
> > > > comment='for cars later than 1975'))
>
> > > > I want catalytic_converter_type to be required if the car year is
> > > > greater than 1975. I also want to show an error if
> > > > catalytic_converter_type is selected and the year is less than 1975.
> > > > Allowing the user to see all errors at once would be a bonus but not a
> > > > deal breaker. onvalidation seems like the place to handle it but let
> > > > me know if there is a better way.
>
> > > > On Nov 26, 5:48 pm, mdipierro  wrote:
>
> > > > > Consider this case:
>
> > > > > db.define_table('numbers',Field('a','integre'),Field('b','integer'))
> > > > > def validate(form):
> > > > >     if form.vars.a+form.vars.b>100:
> > > > >         form.errors.b="a+b must not exceed 100"
> > > > > form=crud.create(db.numbers,onvalidation=validate)
>
> > > > > Before the change the function validate is not called if a and b are
> > > > > not valid integer this never triggering an exception, only validation
> > > > > errors.
>
> > > > > With your proposed change this would cause an error because
> > > > > form.vars.a is None if request.vars.a does ot pass the default integer
> > > > > validation. The function validation would be called again and issue a
> > > > > ticket.
>
> > > > > This is a change of behavior. I am not convinced this change is a good
> > > > > idea.
>
> > > > > Why do you need it?
> > > > > Other opinions?
>
> > > > > Massimo
>
> > > > > On Nov 26, 11:34 am, "mr.freeze"  wrote:
>
> > > > > > Changing line 1565 of html.py from...
> > > > > >         if status and onvalidation:
> > > > > > to...
> > > > > >         if vars and onvalidation:
>
> > > > > > On Nov 26, 11:28 am, mdipierro  wrote:
>
> > > > > > > What would you suggest?
>
> > > > > > > On Nov 26, 11:10 am, "mr.freeze"  wrote:
>
> > > > > > > > I see two issues with this:
> > > > > > > > 1) The form errors found in onvalidation will not be displayed 
> > > > > > > > if
> > > > > > > > there are already form errors
> > > > > > > > 2) The developer never gets a chance to remove form errors for 
> > > > > > > > certain
> > > > > > > > conditions (think contingent form fields)
> > > > > > > > For example, I am using IS_IN_DB on a field but I only want it 
> > > > > > > > to be
> > > > > > > > required if another field is a certain value.
>
> > > > > > > > Is there a better way?
>
>


Re: [web2py] Re: can I add a hover text ( like image:alt) to the default menu ?

2010-11-27 Thread Stef Mientki
hello Massimo,
couldn't  it try it out, unitl I had a JavaScript.

So I found this one:
http://www.freejavascriptkit.com/free_javascripts/tooltip_hint/dhtml_mouseover_tooltip.html

And here is my (relevant) code,
if i != 1 :
  LSB_Menu.append ( [ My_Text, False, URL ( My_URL ) ] )
else :
  LSB_Menu.append ( [ '', False, A ( My_Text, _href=URL(My_URL ),
_onmouseover = "ddrivetip( %s,'blue', 300)"%( My_Tooltip ),
_onmouseout  = "hideddrivetip()" )])

The tooltip works good,
but my menu lookss a little weird.
As you can see I only used the helper function on the second menu item.
Any idea what's going wrong ?

thanks,
Stef



On 27-11-2010 17:22, mdipierro wrote:
> a="title"
> b=True or False
> c=URL(...)
> d=[] # submenu
> response.menu=[(a,b,c,d)]
>
>
> instead of a URL, c can be a helper
>
> c=A('title',_href=URL(...),_onmouseover='')
>
> On Nov 27, 5:22 am, Stef Mientki  wrote:
>> hello,
>>
>> Can I add a hover text ( like image:alt) to the default menu ?
>>
>> thanks,
>> Stef Mientki

<>

[web2py] Re: onvalidation only called if there are no form errors

2010-11-27 Thread DenesL

mr.freeze, you can still use the top part as posted (or similar) and
change the bottom to use crud.


On Nov 27, 5:25 pm, "mr.freeze"  wrote:
> I want catalytic_converter_type (abbreviated to cc_type below) to be
> required for cars after 1975 and be invalid for cars before 1975.
> I want to be able to do this:
>
> def check_form(form):
>     if form.errors.year: return
>     if form.vars.year >= 1975:
>         if not form.vars.cc_type:
>             form.errors.cc_type = 'Required for cars after 1975'
>     elif form.vars.cc_type:
>         form.errors.cc_type = 'Not valid for cars before 1975'
>
> form = crud.create(db.cars,onvalidation=check_form)
>
> I can't currently do it because onvalidation will never be called
> since validation fails if no cc_type is selected. I know I can hack
> around it by switching validators but onvalidation seems like the
> proper place for it. It seems like the developer should get a chance
> to inspect validation errors but they don't.
>
> On Nov 27, 3:19 pm, mdipierro  wrote:
>
> > Not sure I understand the test case.
> > I do not see how this relevant to the onvalidation issue.
>
> > If year>1975 than you want to display and validate the field. If
> > year<=1975 you do not want to display the dropbox and/or ignore its
> > value.
>
> > script=SCRIPT("jQuery('document').ready(function(){var
> > y=jQuery('year'); y.keyup(function(){var
> > c=jQuery('#cars_catalytic_converter_type__row');if(parseInt(y.val()>1975)c.show();elsec.hide();});});");
>
> > db.define_table('cars',
> >     Field('make'),
> >     Field('model'),
> >     Field('year'),
> >     Field('catalytic_converter_type',requires =
> > IS_IN_SET(('one','two','three'),zero=None),
> > comment=script))
>
> > On Nov 26, 6:17 pm, "mr.freeze"  wrote:
>
> > > Good point. Here is my use case:
>
> > > db.define_table('cars',
> > >     Field('make'),
> > >     Field('model'),
> > >     Field('year'),
> > >     Field('catalytic_converter_type',requires =
> > > IS_IN_SET('one','two','three'),
> > > comment='for cars later than 1975'))
>
> > > I want catalytic_converter_type to be required if the car year is
> > > greater than 1975. I also want to show an error if
> > > catalytic_converter_type is selected and the year is less than 1975.
> > > Allowing the user to see all errors at once would be a bonus but not a
> > > deal breaker. onvalidation seems like the place to handle it but let
> > > me know if there is a better way.
>
> > > On Nov 26, 5:48 pm, mdipierro  wrote:
>
> > > > Consider this case:
>
> > > > db.define_table('numbers',Field('a','integre'),Field('b','integer'))
> > > > def validate(form):
> > > >     if form.vars.a+form.vars.b>100:
> > > >         form.errors.b="a+b must not exceed 100"
> > > > form=crud.create(db.numbers,onvalidation=validate)
>
> > > > Before the change the function validate is not called if a and b are
> > > > not valid integer this never triggering an exception, only validation
> > > > errors.
>
> > > > With your proposed change this would cause an error because
> > > > form.vars.a is None if request.vars.a does ot pass the default integer
> > > > validation. The function validation would be called again and issue a
> > > > ticket.
>
> > > > This is a change of behavior. I am not convinced this change is a good
> > > > idea.
>
> > > > Why do you need it?
> > > > Other opinions?
>
> > > > Massimo
>
> > > > On Nov 26, 11:34 am, "mr.freeze"  wrote:
>
> > > > > Changing line 1565 of html.py from...
> > > > >         if status and onvalidation:
> > > > > to...
> > > > >         if vars and onvalidation:
>
> > > > > On Nov 26, 11:28 am, mdipierro  wrote:
>
> > > > > > What would you suggest?
>
> > > > > > On Nov 26, 11:10 am, "mr.freeze"  wrote:
>
> > > > > > > I see two issues with this:
> > > > > > > 1) The form errors found in onvalidation will not be displayed if
> > > > > > > there are already form errors
> > > > > > > 2) The developer never gets a chance to remove form errors for 
> > > > > > > certain
> > > > > > > conditions (think contingent form fields)
> > > > > > > For example, I am using IS_IN_DB on a field but I only want it to 
> > > > > > > be
> > > > > > > required if another field is a certain value.
>
> > > > > > > Is there a better way?
>
>


Re: [web2py] Re: very weird + how do I align text around images ?

2010-11-27 Thread Stef Mientki
GREAT !!
MANY THANKS Massimo,
cheers,
Stef

On 27-11-2010 23:39, mdipierro wrote:
> I am not sure this should have ever worked. I think you want:
>
>   result = DIV()  <---



[web2py] Re: very weird + how do I align text around images ?

2010-11-27 Thread mdipierro
I am not sure this should have ever worked. I think you want:

  result = DIV()  <---
  result.append ( H2('hello') )
  result.append ( IMG ( _src="../static/images/" + parts[1], _align =
'left' ))
  result.append ( H1('world') )
  result.append ( H1('world') )
  result.append ( H1('world') )
  response.content = result

and

  {{=response.content}}


On Nov 27, 4:16 pm, Stef Mientki  wrote:
> hello,
>
> probably this sounds very weird, my program worked great, but after changing 
> a few unimportant words
> it didn't anymore.
>
> In a controller, I build a list of html elements and assigned it to
>
>   Result = []
>   Result.append ( H2('hello') )
>   Result.append ( IMG ( _src="../static/images/" + parts[1], _align = 'left' 
> ))
>   Result.append ( H1('world') )
>   Result.append ( H1('world') )
>   Result.append ( H1('world') )
>   response.Content = Result
>
> I displayed it with the following lines in the viewer
>
> {{=response.Content or 'No Content'}}
>
> and it worked perfect,
> i.e. the 3 lines of text 'world' were neatly placed next to the image on the 
> right.
>
> Suddenly it stopped working, and instead of the content, the list objects 
> were displayed, like here
> (a simpeler list)
>
> [, ]
>
> So I realized, I needed "BEAUTIFY", but I'm absolutely sure I didn't use 
> BEAUTIFY before !!
> and indeed after using BEAUTIFY, the content was displayed again,
> but my text around images is totally gone :-(
>
> How could my program worked before ???
>
> And of course more important, how can I get my text around the image ?
>
> thanks,
> Stef Mientki


[web2py] Re: onvalidation only called if there are no form errors

2010-11-27 Thread mr.freeze
I want catalytic_converter_type (abbreviated to cc_type below) to be
required for cars after 1975 and be invalid for cars before 1975.
I want to be able to do this:

def check_form(form):
if form.errors.year: return
if form.vars.year >= 1975:
if not form.vars.cc_type:
form.errors.cc_type = 'Required for cars after 1975'
elif form.vars.cc_type:
form.errors.cc_type = 'Not valid for cars before 1975'

form = crud.create(db.cars,onvalidation=check_form)

I can't currently do it because onvalidation will never be called
since validation fails if no cc_type is selected. I know I can hack
around it by switching validators but onvalidation seems like the
proper place for it. It seems like the developer should get a chance
to inspect validation errors but they don't.


On Nov 27, 3:19 pm, mdipierro  wrote:
> Not sure I understand the test case.
> I do not see how this relevant to the onvalidation issue.
>
> If year>1975 than you want to display and validate the field. If
> year<=1975 you do not want to display the dropbox and/or ignore its
> value.
>
> script=SCRIPT("jQuery('document').ready(function(){var
> y=jQuery('year'); y.keyup(function(){var
> c=jQuery('#cars_catalytic_converter_type__row');if(parseInt(y.val()>1975)c.show();elsec.hide();});});");
>
> db.define_table('cars',
>     Field('make'),
>     Field('model'),
>     Field('year'),
>     Field('catalytic_converter_type',requires =
> IS_IN_SET(('one','two','three'),zero=None),
> comment=script))
>
> On Nov 26, 6:17 pm, "mr.freeze"  wrote:
>
> > Good point. Here is my use case:
>
> > db.define_table('cars',
> >     Field('make'),
> >     Field('model'),
> >     Field('year'),
> >     Field('catalytic_converter_type',requires =
> > IS_IN_SET('one','two','three'),
> > comment='for cars later than 1975'))
>
> > I want catalytic_converter_type to be required if the car year is
> > greater than 1975. I also want to show an error if
> > catalytic_converter_type is selected and the year is less than 1975.
> > Allowing the user to see all errors at once would be a bonus but not a
> > deal breaker. onvalidation seems like the place to handle it but let
> > me know if there is a better way.
>
> > On Nov 26, 5:48 pm, mdipierro  wrote:
>
> > > Consider this case:
>
> > > db.define_table('numbers',Field('a','integre'),Field('b','integer'))
> > > def validate(form):
> > >     if form.vars.a+form.vars.b>100:
> > >         form.errors.b="a+b must not exceed 100"
> > > form=crud.create(db.numbers,onvalidation=validate)
>
> > > Before the change the function validate is not called if a and b are
> > > not valid integer this never triggering an exception, only validation
> > > errors.
>
> > > With your proposed change this would cause an error because
> > > form.vars.a is None if request.vars.a does ot pass the default integer
> > > validation. The function validation would be called again and issue a
> > > ticket.
>
> > > This is a change of behavior. I am not convinced this change is a good
> > > idea.
>
> > > Why do you need it?
> > > Other opinions?
>
> > > Massimo
>
> > > On Nov 26, 11:34 am, "mr.freeze"  wrote:
>
> > > > Changing line 1565 of html.py from...
> > > >         if status and onvalidation:
> > > > to...
> > > >         if vars and onvalidation:
>
> > > > On Nov 26, 11:28 am, mdipierro  wrote:
>
> > > > > What would you suggest?
>
> > > > > On Nov 26, 11:10 am, "mr.freeze"  wrote:
>
> > > > > > I see two issues with this:
> > > > > > 1) The form errors found in onvalidation will not be displayed if
> > > > > > there are already form errors
> > > > > > 2) The developer never gets a chance to remove form errors for 
> > > > > > certain
> > > > > > conditions (think contingent form fields)
> > > > > > For example, I am using IS_IN_DB on a field but I only want it to be
> > > > > > required if another field is a certain value.
>
> > > > > > Is there a better way?
>
>


[web2py] Re: occasional portalocker errors

2010-11-27 Thread mdipierro
Here there is a thread on the topic:

http://code.activestate.com/lists/python-list/236518/

although it does not help much.

For debugging purporses if you replace


msvcrt.locking(file.fileno(), mode, os.path.getsize(file.name))

with

try: msvcrt.locking(file.fileno(), mode,
os.path.getsize(file.name))
except IOError: pass

do you end up with a session permanently locked or does it fix the
problem?

Massimo

On Nov 27, 3:34 pm, "mr.freeze"  wrote:
> I get this occasionally on Windows 7 and Python 2.5:
>
> Traceback (most recent call last):
>   File "C:\web2py\gluon\restricted.py", line 188, in restricted
>     exec ccode in environment
>   File "C:/web2py/applications/test/models/db.py", line 66, in
> 
>     Field('converter')
>   File "C:\web2py\gluon\sql.py", line 1380, in define_table
>     t._create(migrate=migrate, fake_migrate=fake_migrate)
>   File "C:\web2py\gluon\sql.py", line 1856, in _create
>     portalocker.unlock(tfile)
>   File "C:\web2py\gluon\portalocker.py", line 78, in unlock
>     msvcrt.locking(file.fileno(), mode, os.path.getsize(file.name))
> IOError: [Errno 13] Permission denied
>
> I reload the page and it goes away for a while.


[web2py] very weird + how do I align text around images ?

2010-11-27 Thread Stef Mientki
hello,

probably this sounds very weird, my program worked great, but after changing a 
few unimportant words
it didn't anymore.

In a controller, I build a list of html elements and assigned it to

  Result = []
  Result.append ( H2('hello') )
  Result.append ( IMG ( _src="../static/images/" + parts[1], _align = 'left' ))
  Result.append ( H1('world') )
  Result.append ( H1('world') )
  Result.append ( H1('world') )
  response.Content = Result

I displayed it with the following lines in the viewer

{{=response.Content or 'No Content'}}

and it worked perfect,
i.e. the 3 lines of text 'world' were neatly placed next to the image on the 
right.

Suddenly it stopped working, and instead of the content, the list objects were 
displayed, like here
(a simpeler list)

[, ]

So I realized, I needed "BEAUTIFY", but I'm absolutely sure I didn't use 
BEAUTIFY before !!
and indeed after using BEAUTIFY, the content was displayed again,
but my text around images is totally gone :-(

How could my program worked before ???

And of course more important, how can I get my text around the image ?

thanks,
Stef Mientki


Re: [web2py] Re: AppEngine turning off the routes logging

2010-11-27 Thread Jonathan Lundell
On Nov 26, 2010, at 4:11 PM, Jonathan Lundell wrote:
> 
> I'm not sure why you're logging at the debug level, unless that's the way the 
> GAE installation defaults. Notice that if there's no logging.conf, we rely on 
> logging.basicConfig() for initialization (see main.py). Perhaps we should add 
> level=logging.WARNING or the like to the basicConfig() call (you might 
> experiment with that before you install logging.conf and see what happens; it 
> might make a good patch).

Google says that they're permanently set at debug level, and you should use the 
console log viewing filter to determine what you see.

Strange.

http://books.google.com/books?id=6cL_kCZ4NJ4C&pg=PA94&lpg=PA94&dq=google+app+engine+default+log-level+python&source=bl&ots=sIkaT_PXip&sig=kAWLO4_Xe5bO7uQPKpBbOS6mRVs&hl=en&ei=MoHxTMPiDYu0sAOct-SmCw&sa=X&oi=book_result&ct=result&resnum=8&sqi=2&ved=0CFUQ6AEwBw#v=onepage&q&f=false

Re: [web2py] Re: can I add a hover text ( like image:alt) to the default menu ?

2010-11-27 Thread Stef Mientki
thanks very much Massimo !

cheers,
Stef

On 27-11-2010 17:22, mdipierro wrote:
> a="title"
> b=True or False
> c=URL(...)
> d=[] # submenu
> response.menu=[(a,b,c,d)]
>
>
> instead of a URL, c can be a helper
>
> c=A('title',_href=URL(...),_onmouseover='')
>
> On Nov 27, 5:22 am, Stef Mientki  wrote:
>> hello,
>>
>> Can I add a hover text ( like image:alt) to the default menu ?
>>
>> thanks,
>> Stef Mientki



[web2py] occasional portalocker errors

2010-11-27 Thread mr.freeze
I get this occasionally on Windows 7 and Python 2.5:

Traceback (most recent call last):
  File "C:\web2py\gluon\restricted.py", line 188, in restricted
exec ccode in environment
  File "C:/web2py/applications/test/models/db.py", line 66, in

Field('converter')
  File "C:\web2py\gluon\sql.py", line 1380, in define_table
t._create(migrate=migrate, fake_migrate=fake_migrate)
  File "C:\web2py\gluon\sql.py", line 1856, in _create
portalocker.unlock(tfile)
  File "C:\web2py\gluon\portalocker.py", line 78, in unlock
msvcrt.locking(file.fileno(), mode, os.path.getsize(file.name))
IOError: [Errno 13] Permission denied

I reload the page and it goes away for a while.


[web2py] Re: onvalidation only called if there are no form errors

2010-11-27 Thread mdipierro
Not sure I understand the test case.
I do not see how this relevant to the onvalidation issue.

If year>1975 than you want to display and validate the field. If
year<=1975 you do not want to display the dropbox and/or ignore its
value.

script=SCRIPT("jQuery('document').ready(function(){var
y=jQuery('year'); y.keyup(function(){var
c=jQuery('#cars_catalytic_converter_type__row');if(parseInt(y.val()>1975)c.show();elsec.hide();});});");

db.define_table('cars',
Field('make'),
Field('model'),
Field('year'),
Field('catalytic_converter_type',requires =
IS_IN_SET(('one','two','three'),zero=None),
comment=script))


On Nov 26, 6:17 pm, "mr.freeze"  wrote:
> Good point. Here is my use case:
>
> db.define_table('cars',
>     Field('make'),
>     Field('model'),
>     Field('year'),
>     Field('catalytic_converter_type',requires =
> IS_IN_SET('one','two','three'),
> comment='for cars later than 1975'))
>
> I want catalytic_converter_type to be required if the car year is
> greater than 1975. I also want to show an error if
> catalytic_converter_type is selected and the year is less than 1975.
> Allowing the user to see all errors at once would be a bonus but not a
> deal breaker. onvalidation seems like the place to handle it but let
> me know if there is a better way.
>
> On Nov 26, 5:48 pm, mdipierro  wrote:
>
> > Consider this case:
>
> > db.define_table('numbers',Field('a','integre'),Field('b','integer'))
> > def validate(form):
> >     if form.vars.a+form.vars.b>100:
> >         form.errors.b="a+b must not exceed 100"
> > form=crud.create(db.numbers,onvalidation=validate)
>
> > Before the change the function validate is not called if a and b are
> > not valid integer this never triggering an exception, only validation
> > errors.
>
> > With your proposed change this would cause an error because
> > form.vars.a is None if request.vars.a does ot pass the default integer
> > validation. The function validation would be called again and issue a
> > ticket.
>
> > This is a change of behavior. I am not convinced this change is a good
> > idea.
>
> > Why do you need it?
> > Other opinions?
>
> > Massimo
>
> > On Nov 26, 11:34 am, "mr.freeze"  wrote:
>
> > > Changing line 1565 of html.py from...
> > >         if status and onvalidation:
> > > to...
> > >         if vars and onvalidation:
>
> > > On Nov 26, 11:28 am, mdipierro  wrote:
>
> > > > What would you suggest?
>
> > > > On Nov 26, 11:10 am, "mr.freeze"  wrote:
>
> > > > > I see two issues with this:
> > > > > 1) The form errors found in onvalidation will not be displayed if
> > > > > there are already form errors
> > > > > 2) The developer never gets a chance to remove form errors for certain
> > > > > conditions (think contingent form fields)
> > > > > For example, I am using IS_IN_DB on a field but I only want it to be
> > > > > required if another field is a certain value.
>
> > > > > Is there a better way?
>
>


Re: [web2py] Re: Comment on gluon/contrib/populate.py

2010-11-27 Thread Jonathan Lundell
On Nov 27, 2010, at 12:27 PM, Luis Díaz wrote:
> thanks and quiet
> only was the comment,
> I also thought of the size of line 3
> 
> and I read
> I like to read the code

Here's the code with line 3 truncated:

import re, cPickle, random, datetime

IUP = {'shoebill':{'a':1,'187':1},'trout-like':{'parr':1},

class Learner:
def __init__(self):
self.db={}
def learn(self,text):
replacements1={'[^a-zA-Z0-9\.;:\-]':' ',
   '\s+':' ',', ':' , ', '\. ':' . ',
   ': ':' : ','; ':' ; '}
for key,value in replacements1.items(): text=re.sub(key,value,text)
items=[item.lower() for item in text.split(' ')]
for i in range(len(items)-1):
item=items[i]
nextitem=items[i+1]
if not self.db.has_key(item): self.db[item]={}
if not self.db[item].has_key(nextitem): self.db[item][nextitem]=1
else: self.db[item][nextitem]+=1
def save(self,filename):
cPickle.dump(self.db,open(filename,'wb'))
def load(self,filename):
self.loadd(cPickle.load(open(filename,'rb')))
def loadd(self,db):
self.db=db
def generate(self,length=1,prefix=False):
replacements2={' ,':',', ' \.':'.\n', ' :':':', ' ;':';', '\n\s+':'\n' }
keys=self.db.keys()
key=keys[random.randint(0,len(keys)-1)]
words=key
words=words.capitalize()
regex=re.compile('[a-z]+')
for i in range(length):
okey=key
if not key in self.db: break # should not happen
db=self.db[key]
s=sum(db.values())
i=random.randint(0,s-1)
for key,value in db.items():
if i0.5
elif field.type in ['datetime', 'date']:
record[fieldname] = \
datetime.datetime(2009,1,1) - \
datetime.timedelta(days=random.randint(0,1))
elif field.type == 'time':
h = random.randint(0,23)
m = 15*random.randint(0,3)
record[fieldname] = datetime.time(h,m,0)
elif field.type == 'password':
record[fieldname] = ''
elif field.type == 'upload':
record[fieldname] = None
elif field.type=='integer' and hasattr(field.requires,'options'):   
 
options=field.requires.options()
record[fieldname] = options[random.randint(0,len(options)-1)][0]
elif field.type=='list:integer' and 
hasattr(field.requires,'options'):
options=field.requires.options()
if len(options) > 0:
vals = []
for i in range(0, random.randint(0,len(options)-1)/2):

vals.append(options[random.randint(0,len(options)-1)][0])
record[fieldname] = vals
elif field.type in ['integer','double'] or 
str(field.type).startswith('decimal'):
try:
record[fieldname] = 
random.randint(field.requires.minimum,field.requires.maximum-1)
except:
record[fieldname] = random.randint(0,1000)
elif field.type[:10] == 'reference ':
tablename = field.type[10:]
if not tablename in ids:
if table._db._dbname=='gql':
ids[tablename] = [x.id for x in 
table._db(table._db[field.type[10:]].id>0).select()]
else:
ids[tablename] = [x.id for x in 
table._db(table._db[field.type[10:]].id>0).select()]
n = len(ids[tablename])
if n:
record[fieldname] = ids[tablename][random.randint(0,n-1)]
else:
record[fieldname] = 0
elif field.type[:15] == 'list:reference ':
tablename = field.type[15:]
if not tablename in ids:
if table._db._dbname=='gql':
ids[tablename] = [x.id for x in 
table._db(table._db[field.type[15:]].id>0).select()]
else:
ids[tablename] = [x.id for x in 
table._db(table._db[field.type[15:]].id>0).select()]
n = len(ids[tablename])
if n:
vals = []
for i in range(0, random.randint(0,n-1)/2):
vals.append(ids[tablename][random.randint(0,n-1)])
record[fieldname] = vals
else:
record[fieldname] = 0
elif field.type=='list:string' and 
hasattr(field.requires,'options'):
options=field.requires.options()
if len(options) > 0:
vals = []
for i in range(0, random.randint(0,len(options)-1)/2):

vals.append(options[random.randint(0,

Re: [web2py] Re: Comment on gluon/contrib/populate.py

2010-11-27 Thread Luis Díaz
thanks and quiet
only was the comment,
I also thought of the size of line 3

and I read
I like to read the code


-- 
Díaz Luis
TSU Analisis de Sistemas
Universidad de Carabobo

http://web2pyfacil.blogspot.com/
Facultad de 
Odontología


Re: [web2py] Re: Comment on gluon/contrib/populate.py

2010-11-27 Thread Jonathan Lundell
On Nov 27, 2010, at 12:13 PM, mdipierro wrote:
> 
> we could replace }, with },\n

It'd be an awfully long file then. Better to read it from a file, I think.

> 
> Massimo
> 
> On Nov 27, 1:43 pm, Jonathan Lundell  wrote:
>> On Nov 27, 2010, at 11:31 AM, Luis Díaz wrote:
>> 
>>> I have problems when trying to read the file populate.py
>> 
>>> I just want to see the code and my system is experiencing a strange 
>>> behavior.
>> 
>>> use linux
>>> I tried it with the beaver and Komodo editor
>> 
>>> the problem does not prevent me from working
>>> my apps run perfectly
>> 
>> Your problem is no doubt that line 3 (IUP = ...) is almost 750,000 
>> characters long!




[web2py] Re: onvalidation only called if there are no form errors

2010-11-27 Thread mr.freeze
Thanks Denes. I was hoping to use onvalidation for all of my
validation logic to keep it centralized since I'm using crud. What
about making it configurable by adding 'always_validate=False' ?

On Nov 26, 9:19 pm, DenesL  wrote:
> You can always change requires on the fly
>
> def test():
>   if request.vars.year:
>     try:
>       y = int(request.vars.year)
>     except 'ValueError':
>       y = 0
>     if y > 1975:
>       db.cars.catalytic_converter_type.requires =
> IS_IN_SET(['one','two','three'], error_message='cars later than 1975
> must have at least one')
>     else:
>       db.cars.catalytic_converter_type.requires = IS_EQUAL_TO('',
> error_message='cars before 1975 should not have one')
>   f=SQLFORM(db.cars)
>   if f.accepts(request.vars, session):
>     response.flash='accepted'
>   elif f.errors:
>     response.flash='please fix and re-submit'
>   return dict(f=f)
>
> On Nov 26, 7:17 pm, "mr.freeze"  wrote:
>
> > Good point. Here is my use case:
>
> > db.define_table('cars',
> >     Field('make'),
> >     Field('model'),
> >     Field('year'),
> >     Field('catalytic_converter_type',requires =
> > IS_IN_SET('one','two','three'),
> > comment='for cars later than 1975'))
>
> > I want catalytic_converter_type to be required if the car year is
> > greater than 1975. I also want to show an error if
> > catalytic_converter_type is selected and the year is less than 1975.
> > Allowing the user to see all errors at once would be a bonus but not a
> > deal breaker. onvalidation seems like the place to handle it but let
> > me know if there is a better way.
>
> > On Nov 26, 5:48 pm, mdipierro  wrote:
>
> > > Consider this case:
>
> > > db.define_table('numbers',Field('a','integre'),Field('b','integer'))
> > > def validate(form):
> > >     if form.vars.a+form.vars.b>100:
> > >         form.errors.b="a+b must not exceed 100"
> > > form=crud.create(db.numbers,onvalidation=validate)
>
> > > Before the change the function validate is not called if a and b are
> > > not valid integer this never triggering an exception, only validation
> > > errors.
>
> > > With your proposed change this would cause an error because
> > > form.vars.a is None if request.vars.a does ot pass the default integer
> > > validation. The function validation would be called again and issue a
> > > ticket.
>
> > > This is a change of behavior. I am not convinced this change is a good
> > > idea.
>
> > > Why do you need it?
> > > Other opinions?
>
> > > Massimo
>
> > > On Nov 26, 11:34 am, "mr.freeze"  wrote:
>
> > > > Changing line 1565 of html.py from...
> > > >         if status and onvalidation:
> > > > to...
> > > >         if vars and onvalidation:
>
> > > > On Nov 26, 11:28 am, mdipierro  wrote:
>
> > > > > What would you suggest?
>
> > > > > On Nov 26, 11:10 am, "mr.freeze"  wrote:
>
> > > > > > I see two issues with this:
> > > > > > 1) The form errors found in onvalidation will not be displayed if
> > > > > > there are already form errors
> > > > > > 2) The developer never gets a chance to remove form errors for 
> > > > > > certain
> > > > > > conditions (think contingent form fields)
> > > > > > For example, I am using IS_IN_DB on a field but I only want it to be
> > > > > > required if another field is a certain value.
>
> > > > > > Is there a better way?
>
>


[web2py] Re: Comment on gluon/contrib/populate.py

2010-11-27 Thread mdipierro
we could replace }, with },\n

Massimo

On Nov 27, 1:43 pm, Jonathan Lundell  wrote:
> On Nov 27, 2010, at 11:31 AM, Luis Díaz wrote:
>
> > I have problems when trying to read the file populate.py
>
> > I just want to see the code and my system is experiencing a strange 
> > behavior.
>
> > use linux
> > I tried it with the beaver and Komodo editor
>
> > the problem does not prevent me from working
> > my apps run perfectly
>
> Your problem is no doubt that line 3 (IUP = ...) is almost 750,000 characters 
> long!


Re: [web2py] Comment on gluon/contrib/populate.py

2010-11-27 Thread Jonathan Lundell
On Nov 27, 2010, at 11:31 AM, Luis Díaz wrote:
> I have problems when trying to read the file populate.py
> 
> I just want to see the code and my system is experiencing a strange behavior.
> 
> use linux
> I tried it with the beaver and Komodo editor
> 
> the problem does not prevent me from working
> my apps run perfectly

Your problem is no doubt that line 3 (IUP = ...) is almost 750,000 characters 
long!

[web2py] Re: query incompatible in GAE

2010-11-27 Thread mdipierro
That is why it was never done. I agree with you that there is no
benefit.

Massimo

On Nov 27, 1:41 pm, "mr.freeze"  wrote:
> Massimo, would it be worth the overhead of removing the fields? It
> seems like extra processing with no benefit, IMHO. If you do it, would
> it be the default behavior?
>
> On Nov 27, 12:22 pm, mdipierro  wrote:
>
> > GAE does not support filtering of fields. We could filter at web2py
> > level.
> > Shall I implement this? Anybody against?
>
> > Massimo
>
> > On Nov 27, 11:55 am, appydev  wrote:
>
> > > Greetings.
>
> > > I'm doing a query that returns only some fields.
>
> > > rows = db(db.theacher.id>0).select(db.theacher.subject)
>
> > > Web2py  server works properly.
>
> > > theacher.subject
> > > math
>
> > > But in the GAE development server, it returns all fields.
>
> > > theacher.id theacher.modified_on theacher.subject
> > > 1 2010-11-27 17:12:37.685454 math
>
> > > Does anyone know the cause of the problem?
>
>


[web2py] Re: query incompatible in GAE

2010-11-27 Thread mr.freeze
Massimo, would it be worth the overhead of removing the fields? It
seems like extra processing with no benefit, IMHO. If you do it, would
it be the default behavior?

On Nov 27, 12:22 pm, mdipierro  wrote:
> GAE does not support filtering of fields. We could filter at web2py
> level.
> Shall I implement this? Anybody against?
>
> Massimo
>
> On Nov 27, 11:55 am, appydev  wrote:
>
> > Greetings.
>
> > I'm doing a query that returns only some fields.
>
> > rows = db(db.theacher.id>0).select(db.theacher.subject)
>
> > Web2py  server works properly.
>
> > theacher.subject
> > math
>
> > But in the GAE development server, it returns all fields.
>
> > theacher.id theacher.modified_on theacher.subject
> > 1 2010-11-27 17:12:37.685454 math
>
> > Does anyone know the cause of the problem?
>
>


[web2py] Comment on gluon/contrib/populate.py

2010-11-27 Thread Luis Díaz
Greetings.

I have problems when trying to read the file populate.py

I just want to see the code and my system is experiencing a strange
behavior.

use linux
I tried it with the beaver and Komodo editor

the problem does not prevent me from working
my apps run perfectly

just commented Case

-- 
Díaz Luis
TSU Analisis de Sistemas
Universidad de Carabobo

http://web2pyfacil.blogspot.com/
Facultad de 
Odontología


Re: [web2py] Re: query incompatible in GAE

2010-11-27 Thread appydev
Thanks Massimo.


2010/11/27 mdipierro 

> GAE does not support filtering of fields. We could filter at web2py
> level.
> Shall I implement this? Anybody against?
>
> Massimo
>
> On Nov 27, 11:55 am, appydev  wrote:
> > Greetings.
> >
> > I'm doing a query that returns only some fields.
> >
> > rows = db(db.theacher.id>0).select(db.theacher.subject)
> >
> > Web2py  server works properly.
> >
> > theacher.subject
> > math
> >
> > But in the GAE development server, it returns all fields.
> >
> > theacher.id theacher.modified_on theacher.subject
> > 1 2010-11-27 17:12:37.685454 math
> >
> > Does anyone know the cause of the problem?
>


[web2py] Re: PyPy 1.4 released

2010-11-27 Thread mdipierro
I should add I compared python 2.5 and pypy for mac 1.4 64bits.

Massimo

On Nov 27, 12:20 pm, mdipierro  wrote:
> I tried PyPy 1.4 today.
>
> web2py worked out of the box and I am impressed by this. I run some
> tests:
>
> TEST1 (web2py)
> =
>
> I run some (sloppy) benchmarks on OSX with ab and I found PyPy to be a
> bit lower
>
> no model, no logic, just hello world with trivial template
>
> Cpython: 4ms/request
> PyPy: 8ms/request
>
> More complex example (auth, crud, service): the welcome app
>
> Cpython: 68ms/request
> PyPy: 89ms/request
>
> I found an occasional "segmentation fault" crash of web2py. I could
> not identify the cause.
>
> TEST2 (no web2py, no web server, just loops)
> =
>
> I benchmarked a simple program that performs two nested loops (not
> web2py, not web related) and I found:
>
> cPython: 23s
> pypy: 15s
>
> Pypy is indeed faster in this case.
>
> TEST 3 (no web2py, just rocket and wsgi hello world)
> ==
>
> cpython: 0.849ms/request
> pypy:   2.109ms/request
>
> Massimo
>
> On Nov 26, 6:51 pm, Phyo Arkar  wrote:
>
> > I think its time try to give web2py on pypy 1.4 a try! its production
> > quality they said.
>
> > -- Forwarded message --
> > From: Maciej Fijalkowski 
> > Date: Fri, 26 Nov 2010 20:23:45 +0200
> > Subject: [pypy-dev] PyPy 1.4 released
> > To: PyPy Dev , ""
>
> > , python-annou...@python.org
>
> > ===
> > PyPy 1.4: Ouroboros in practice
> > ===
>
> > We're pleased to announce the 1.4 release of PyPy. This is a major 
> > breakthrough
> > in our long journey, as PyPy 1.4 is the first PyPy release that can 
> > translate
> > itself faster than CPython.  Starting today, we are using PyPy more for
> > our every-day development.  So may you :) You can download it here:
>
> >    http://pypy.org/download.html
>
> > What is PyPy
> > 
>
> > PyPy is a very compliant Python interpreter, almost a drop-in replacement
> > for CPython. It's fast (`pypy 1.4 and cpython 2.6`_ comparison)
>
> > Among its new features, this release includes numerous performance 
> > improvements
> > (which made fast self-hosting possible), a 64-bit JIT backend, as well
> > as serious stabilization. As of now, we can consider the 32-bit and 64-bit
> > linux versions of PyPy stable enough to run `in production`_.
>
> > Numerous speed achievements are described on `our blog`_. Normalized speed
> > charts comparing `pypy 1.4 and pypy 1.3`_ as well as `pypy 1.4 and cpython 
> > 2.6`_
> > are available on benchmark website. For the impatient: yes, we got a lot 
> > faster!
>
> > More highlights
> > ===
>
> > * PyPy's built-in Just-in-Time compiler is fully transparent and
> >   automatically generated; it now also has very reasonable memory
> >   requirements.  The total memory used by a very complex and
> >   long-running process (translating PyPy itself) is within 1.5x to
> >   at most 2x the memory needed by CPython, for a speed-up of 2x.
>
> > * More compact instances.  All instances are as compact as if
> >   they had ``__slots__``.  This can give programs a big gain in
> >   memory.  (In the example of translation above, we already have
> >   carefully placed ``__slots__``, so there is no extra win.)
>
> > * `Virtualenv support`_: now PyPy is fully compatible with
> > virtualenv_: note that
> >   to use it, you need a recent version of virtualenv (>= 1.5).
>
> > * Faster (and JITted) regular expressions - huge boost in speeding up
> >   the `re` module.
>
> > * Other speed improvements, like JITted calls to functions like map().
>
> > .. _virtualenv:http://pypi.python.org/pypi/virtualenv
> > .. _`Virtualenv 
> > support`:http://morepypy.blogspot.com/2010/08/using-virtualenv-with-pypy.html
> > .. _`in 
> > production`:http://morepypy.blogspot.com/2010/11/running-large-radio-telescope-so...
> > .. _`our blog`:http://morepypy.blogspot.com
> > .. _`pypy 1.4 and pypy 
> > 1.3`:http://speed.pypy.org/comparison/?exe=1%2B41,1%2B172&ben=1,2,3,4,5,6,...
> > .. _`pypy 1.4 and cpython 
> > 2.6`:http://speed.pypy.org/comparison/?exe=2%2B35,1%2B172&ben=1,2,3,4,5,6,...
>
> > Cheers,
>
> > Carl Friedrich Bolz, Antonio Cuni, Maciej Fijalkowski,
> > Amaury Forgeot d'Arc, Armin Rigo and the PyPy team
> > ___
> > pypy-...@codespeak.nethttp://codespeak.net/mailman/listinfo/pypy-dev
>
>


[web2py] Re: query incompatible in GAE

2010-11-27 Thread mdipierro
GAE does not support filtering of fields. We could filter at web2py
level.
Shall I implement this? Anybody against?

Massimo

On Nov 27, 11:55 am, appydev  wrote:
> Greetings.
>
> I'm doing a query that returns only some fields.
>
> rows = db(db.theacher.id>0).select(db.theacher.subject)
>
> Web2py  server works properly.
>
> theacher.subject
> math
>
> But in the GAE development server, it returns all fields.
>
> theacher.id theacher.modified_on theacher.subject
> 1 2010-11-27 17:12:37.685454 math
>
> Does anyone know the cause of the problem?


[web2py] Re: [pypy-dev] PyPy 1.4 released

2010-11-27 Thread mdipierro
I tried PyPy 1.4 today.

web2py worked out of the box and I am impressed by this. I run some
tests:

TEST1 (web2py)
=

I run some (sloppy) benchmarks on OSX with ab and I found PyPy to be a
bit lower

no model, no logic, just hello world with trivial template

Cpython: 4ms/request
PyPy: 8ms/request

More complex example (auth, crud, service): the welcome app

Cpython: 68ms/request
PyPy: 89ms/request

I found an occasional "segmentation fault" crash of web2py. I could
not identify the cause.

TEST2 (no web2py, no web server, just loops)
=

I benchmarked a simple program that performs two nested loops (not
web2py, not web related) and I found:

cPython: 23s
pypy: 15s

Pypy is indeed faster in this case.

TEST 3 (no web2py, just rocket and wsgi hello world)
==

cpython: 0.849ms/request
pypy:   2.109ms/request


Massimo


On Nov 26, 6:51 pm, Phyo Arkar  wrote:
> I think its time try to give web2py on pypy 1.4 a try! its production
> quality they said.
>
> -- Forwarded message --
> From: Maciej Fijalkowski 
> Date: Fri, 26 Nov 2010 20:23:45 +0200
> Subject: [pypy-dev] PyPy 1.4 released
> To: PyPy Dev , ""
>
> , python-annou...@python.org
>
> ===
> PyPy 1.4: Ouroboros in practice
> ===
>
> We're pleased to announce the 1.4 release of PyPy. This is a major 
> breakthrough
> in our long journey, as PyPy 1.4 is the first PyPy release that can translate
> itself faster than CPython.  Starting today, we are using PyPy more for
> our every-day development.  So may you :) You can download it here:
>
>    http://pypy.org/download.html
>
> What is PyPy
> 
>
> PyPy is a very compliant Python interpreter, almost a drop-in replacement
> for CPython. It's fast (`pypy 1.4 and cpython 2.6`_ comparison)
>
> Among its new features, this release includes numerous performance 
> improvements
> (which made fast self-hosting possible), a 64-bit JIT backend, as well
> as serious stabilization. As of now, we can consider the 32-bit and 64-bit
> linux versions of PyPy stable enough to run `in production`_.
>
> Numerous speed achievements are described on `our blog`_. Normalized speed
> charts comparing `pypy 1.4 and pypy 1.3`_ as well as `pypy 1.4 and cpython 
> 2.6`_
> are available on benchmark website. For the impatient: yes, we got a lot 
> faster!
>
> More highlights
> ===
>
> * PyPy's built-in Just-in-Time compiler is fully transparent and
>   automatically generated; it now also has very reasonable memory
>   requirements.  The total memory used by a very complex and
>   long-running process (translating PyPy itself) is within 1.5x to
>   at most 2x the memory needed by CPython, for a speed-up of 2x.
>
> * More compact instances.  All instances are as compact as if
>   they had ``__slots__``.  This can give programs a big gain in
>   memory.  (In the example of translation above, we already have
>   carefully placed ``__slots__``, so there is no extra win.)
>
> * `Virtualenv support`_: now PyPy is fully compatible with
> virtualenv_: note that
>   to use it, you need a recent version of virtualenv (>= 1.5).
>
> * Faster (and JITted) regular expressions - huge boost in speeding up
>   the `re` module.
>
> * Other speed improvements, like JITted calls to functions like map().
>
> .. _virtualenv:http://pypi.python.org/pypi/virtualenv
> .. _`Virtualenv 
> support`:http://morepypy.blogspot.com/2010/08/using-virtualenv-with-pypy.html
> .. _`in 
> production`:http://morepypy.blogspot.com/2010/11/running-large-radio-telescope-so...
> .. _`our blog`:http://morepypy.blogspot.com
> .. _`pypy 1.4 and pypy 
> 1.3`:http://speed.pypy.org/comparison/?exe=1%2B41,1%2B172&ben=1,2,3,4,5,6,...
> .. _`pypy 1.4 and cpython 
> 2.6`:http://speed.pypy.org/comparison/?exe=2%2B35,1%2B172&ben=1,2,3,4,5,6,...
>
> Cheers,
>
> Carl Friedrich Bolz, Antonio Cuni, Maciej Fijalkowski,
> Amaury Forgeot d'Arc, Armin Rigo and the PyPy team
> ___
> pypy-...@codespeak.nethttp://codespeak.net/mailman/listinfo/pypy-dev
>
>


[web2py] query incompatible in GAE

2010-11-27 Thread appydev
Greetings.

I'm doing a query that returns only some fields.

rows = db(db.theacher.id>0).select(db.theacher.subject)

Web2py  server works properly.

theacher.subject
math


But in the GAE development server, it returns all fields.

theacher.id theacher.modified_on theacher.subject
1 2010-11-27 17:12:37.685454 math

Does anyone know the cause of the problem?


[web2py] Re: elFinder web file manager

2010-11-27 Thread Carlos
Hi Phyo,

Can you please describe the file upload problem in more detail?, can I
use it as a library (images, videos, docs) gallery mostly for viewing
purposes to end users (while doing the uploads via web2py apps,
therefor avoiding the current upload problem)?.

Furthermore does it work with the 'download' capabilities from
web2py?, is it fully integrated with web2py?.

Thanks!,

   Carlos


On Nov 27, 4:36 am, Phyo Arkar  wrote:
> i am using at production .
>
> There is huge file upload problem coz it dont use web2py's upload
> function.If there any you need feel free to modify and send me patch.
>
> On 11/27/10, Phyo Arkar  wrote:
>
>
>
>
>
>
>
> > here is my work
> >http://code.google.com/p/elfinder-web2py/
>
> > On 11/27/10, mdipierro  wrote:
> >> It is not integrated but there was a plugin for it. If somebody could
> >> post a list to it (and host it on google code somewhere) I would post
> >> a link from appliances. It could be used for admin2.
>
> >> On Nov 26, 9:15 pm, Carlos  wrote:
> >>> Hi,
>
> >>> I'm wondering what ever happened with elFinder web file manager?:
>
> >>>http://elrte.org/elfinder/
>
> >>>http://groups.google.com/group/web2py/browse_thread/thread/3af7b48d32...
>
> >>> Is it already integrated with web2py?, for all types of users (admin,
> >>> appadmin, endusers)?.
>
> >>> Is anybody actually using it in production environments?, or was it
> >>> abandoned (why)?.
>
> >>> Is there something better (as a web file manager, integrated with
> >>> web2py) out there?.
>
> >>> Best regards,
>
> >>>    Carlos


[web2py] Re: can I add a hover text ( like image:alt) to the default menu ?

2010-11-27 Thread mdipierro
a="title"
b=True or False
c=URL(...)
d=[] # submenu
response.menu=[(a,b,c,d)]


instead of a URL, c can be a helper

c=A('title',_href=URL(...),_onmouseover='')

On Nov 27, 5:22 am, Stef Mientki  wrote:
> hello,
>
> Can I add a hover text ( like image:alt) to the default menu ?
>
> thanks,
> Stef Mientki


[web2py] Don't miss the December 15th deadline!

2010-11-27 Thread NetAdmin

 December 15th is the last day you can submit your apps
 for the Web2py Application Exhibition Version 2.0

 See the pinned message at the top for more details.

 Good Luck!

 Mr.NetAdmin


[web2py] can I add a hover text ( like image:alt) to the default menu ?

2010-11-27 Thread Stef Mientki
hello,

Can I add a hover text ( like image:alt) to the default menu ?

thanks,
Stef Mientki


Re: [web2py] Re: elFinder web file manager

2010-11-27 Thread Phyo Arkar
i am using at production .

There is huge file upload problem coz it dont use web2py's upload
function.If there any you need feel free to modify and send me patch.

On 11/27/10, Phyo Arkar  wrote:
> here is my work
> http://code.google.com/p/elfinder-web2py/
>
> On 11/27/10, mdipierro  wrote:
>> It is not integrated but there was a plugin for it. If somebody could
>> post a list to it (and host it on google code somewhere) I would post
>> a link from appliances. It could be used for admin2.
>>
>> On Nov 26, 9:15 pm, Carlos  wrote:
>>> Hi,
>>>
>>> I'm wondering what ever happened with elFinder web file manager?:
>>>
>>> http://elrte.org/elfinder/
>>>
>>> http://groups.google.com/group/web2py/browse_thread/thread/3af7b48d32...
>>>
>>> Is it already integrated with web2py?, for all types of users (admin,
>>> appadmin, endusers)?.
>>>
>>> Is anybody actually using it in production environments?, or was it
>>> abandoned (why)?.
>>>
>>> Is there something better (as a web file manager, integrated with
>>> web2py) out there?.
>>>
>>> Best regards,
>>>
>>>    Carlos
>


Re: [web2py] Re: elFinder web file manager

2010-11-27 Thread Phyo Arkar
here is my work
http://code.google.com/p/elfinder-web2py/

On 11/27/10, mdipierro  wrote:
> It is not integrated but there was a plugin for it. If somebody could
> post a list to it (and host it on google code somewhere) I would post
> a link from appliances. It could be used for admin2.
>
> On Nov 26, 9:15 pm, Carlos  wrote:
>> Hi,
>>
>> I'm wondering what ever happened with elFinder web file manager?:
>>
>> http://elrte.org/elfinder/
>>
>> http://groups.google.com/group/web2py/browse_thread/thread/3af7b48d32...
>>
>> Is it already integrated with web2py?, for all types of users (admin,
>> appadmin, endusers)?.
>>
>> Is anybody actually using it in production environments?, or was it
>> abandoned (why)?.
>>
>> Is there something better (as a web file manager, integrated with
>> web2py) out there?.
>>
>> Best regards,
>>
>>    Carlos