Meta-question: Should I rather post things like this to the issue tracker?
1.
In
http://web2py.com/books/default/chapter/32/07/forms-and-validators#Validators,
the paragraph "IS_IN_SET" says:
The elements of the set must always be strings unless this validator is
preceded by IS_INT_IN_RANGE (which converts the value to int) or
IS_FLOAT_IN_RANGE (which converts the value to float). For example:
requires = [IS_INT_IN_RANGE(0, 8), IS_IN_SET([2, 3, 5, 7],
error_message='must be prime and less than 10')]
This doesn't work for me in this case:
requires = [
IS_INT_IN_RANGE(0, 4),
IS_IN_SET([
(0, T("<Option 1>")),
(1, T("<Option 2>")),
(2, T("<Option 3>")),
(3, T("<Option 4>")),
]
),
],
I get a ticket:
<type 'exceptions.SyntaxError'> widget cannot determine options of
piece.piece_type
and it seems web2py tries to derive the options from the first validator:
if hasattr(requires[0], 'options')
Changing the order in my code indeed works:
requires = [
IS_IN_SET([
(0, T("<Option 1>")),
(1, T("<Option 2>")),
(2, T("<Option 3>")),
(3, T("<Option 4>")),
]
),
IS_INT_IN_RANGE(0, 4),
],
So should the book perhaps say:
The elements of the set must always be strings unless this validator is
*followed* by IS_INT_IN_RANGE (which converts the value to int) or
IS_FLOAT_IN_RANGE (which converts the value to float).
?
2. In http://www.web2py.com/book/default/chapter/10#JSONRPC-and-Pyjamas
this part of the code example
<script language="javascript"
src="{{=URL('static','output/pygwt.js')}}">
</script>
for more recent versions of pyjs should be changed to
<script language="javascript"
src="{{=URL('static','output/bootstrap.js')}}">
</script>
However, JSONRPC in pyjamas 0.8.x is broken (due to this problem:
http://osdir.com/ml/python-pyjamas-devel/2012-04/msg00246.html), and it
doesn't look like it'd be fixed any time soon (or ever).
I'd suggest to put a note on top of this chapter, to discourage people from
trying it until pyjs development is continued, and there's a newer version
than 0.8.1a.
--
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 [email protected].
For more options, visit https://groups.google.com/groups/opt_out.