[web2py] form validation using onvalidation and form.validate for boolean data type

2015-11-29 Thread Anthony
What is the traceback?

-- 
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] form validation using onvalidation and form.validate for boolean data type

2015-11-29 Thread 黄祥
is there any differences when form validation using onvalidation and 
form.validate for boolean data type?
*example 1 work when using onvalidation*
# onvalidation_check_in
*def __onvalidation_check_in(form):*
* if form.vars.is_booking == 'on':*
if form.vars.booking_no:
rows = db(db.booking.id == form.vars.booking_no).select()
for row in rows:
form.vars.field = row.field
form.vars.customer = row.customer
else:
form.errors.booking_no = 'enter a value'
else:
if not form.vars.field:
form.errors.field = 'enter a value'
elif not form.vars.customer:
form.errors.customer = 'enter a value'
# check_in
def check_in():
table = db.check_in
onvalidation = __onvalidation_check_in
return futsal_transaction.form_0(table, onvalidation)

*example 2 not work when using form.validate an error traceback occured*
# check_in
def check_in():
form = SQLFORM(db.check_in)
* if form.validate(formname = 'form_header'):*
* if form.vars.is_booking == 'on':*
booking = db(db.booking_header.id == form.vars.booking_no).select().first()
db.check_in.insert(check_in_date = form.vars.check_in_date, 
  is_booking = form.vars.is_booking, 
  booking_no = form.vars.booking_no, 
customer = booking.customer)
else :
db.check_in.insert(check_in_date = form.vars.check_in_date, 
  is_booking = form.vars.is_booking, 
  booking_no = form.vars.booking_no, 
customer = form.vars.customer)
return dict(form = form)

any idea why example 2 is not work?

thanks and best regards,
stifan

-- 
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: Hide "/index" in URLs

2015-11-29 Thread Anthony
Using the parameter-based rewrite system, set default_function='index' in 
the router.

Anthony

On Sunday, November 29, 2015 at 6:00:06 PM UTC-5, pbreit wrote:
>
> I am using individual files for my controllers. For example:
>
> web2py:applications:myapp:controllers:recipients.py
>
> In recipients.py I have:
>
> def index():
> ...
>
> How to make it so that "index" does not appear in the URL?
>
> I would like: http://mysite.com/myapp/recipients
> instead of: http://mysite.com/myapp/recipients/index
>

-- 
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] Hide "/index" in URLs

2015-11-29 Thread pbreit
I am using individual files for my controllers. For example:

web2py:applications:myapp:controllers:recipients.py

In recipients.py I have:

def index():
...

How to make it so that "index" does not appear in the URL?

I would like: http://mysite.com/myapp/recipients
instead of: http://mysite.com/myapp/recipients/index

-- 
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: Retrieve record field labels in sqlform.grid custom view

2015-11-29 Thread Anthony
Can you provide more details regarding what you are trying to do? Is there 
a reason you can't just do db.memos.code.label? Anyway, if a create, 
update, or view form has been requested, the associated SQLFORM objects can 
be found in grid.create_form, grid.update_form, and grid.view_form, 
respectively. At that point, it is just a regular SQLFORM, so you can 
access all the usual attributes. such as grid.view_form.custom.label.code.

Anthony

On Sunday, November 29, 2015 at 12:52:30 PM UTC-5, Gael Princivalle wrote:
>
> Hello everybody.
>
> Is there a way in a sqlform.grid to retrieve record field labels in a 
> custom view?
> Something like that:
> grid.view_form.record.code.label
>
> To retrieve:
> db.define_table('memos',
> Field('code', type='string', requires=IS_NOT_EMPTY(), label='*Codice*'
> ),
>
> Thanks, regards.
>

-- 
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] Re: New Web2py Materialize CSS Welcome app scaffold

2015-11-29 Thread Ron Chatterjee
One comment if I can add. Unlike regular welcome web2py app this doesn't 
appear to be responsive. Good work otherwise.



On Saturday, November 28, 2015 at 11:02:13 PM UTC-5, Mark Graves wrote:

> Hey,
>
> Thanks!
>
> Sorry, I haven't had time to get back to this.
>
> No I think there are some problems with the web2py based checkboxes for 
> some reason IIRC.
>
> The inputs seem to work reasonably well.
>
> I'll try to look at this asp.
>
> -Mark
>
> On Sat, Nov 28, 2015 at 10:22 AM, at > 
> wrote:
>
>> Good work Mark!
>>
>> Did you check if the SQLFORM and other web2py forms are still working 
>> after disabling bootstrapcss?
>>
>> Thanks
>>
>>
>> On Friday, 13 November 2015 22:55:56 UTC+5, Mark Graves wrote:
>>>
>>> Hey everyone,
>>>
>>> I just put up a new web2py welcome scaffold app based on materializecss.
>>>
>>> The repository is available at:
>>>
>>>  https://bitbucket.org/MarkGraves/welcome_materialize/
>>>
>>> You can preview it at:
>>>
>>> https://gravesmedical.pythonanywhere.com/welcome/
>>>
>>> There are definitely some issues, but I thought it might be useful for 
>>> some folks.
>>>
>>> -Mark
>>>
>> -- 
>> 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 a topic in the 
>> Google Groups "web2py-users" group.
>> To unsubscribe from this topic, visit 
>> https://groups.google.com/d/topic/web2py/GGi_09devEs/unsubscribe.
>> To unsubscribe from this group and all its topics, send an email to 
>> web2py+un...@googlegroups.com .
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>

-- 
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: Problem with processing unicode character by render function in gluon.template

2015-11-29 Thread Krzysztof Socha
It appears that I have been missing somthing. It is sufficient to properly 
encode the string before passing it to render:

render(template_content.encode('utf-8'))


-- 
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] Problem with processing unicode character by render function in gluon.template

2015-11-29 Thread Krzysztof Socha
I tried to use the templating system of web2py for parsing dynamically 
generated views. Theoretically, it should work - render from gluon.template 
accepts streams and strings as well. However, it seems that due to the fact 
it uses cStringIO instead of StringIO, it is unable to process unicode 
characters:

http://stackoverflow.com/questions/4677512/can-i-use-cstringio-the-same-as-stringio

So if my dynamically generated view contains any unicode characters, the 
rendering breaks with the error:

 'ascii' codec can't encode character 

It seems that it would be sufficient to change cStringIO to StringIO in 
gluon.template

Or am I missing something?

-- 
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] Retrieve record field labels in sqlform.grid custom view

2015-11-29 Thread Gael Princivalle
Hello everybody.

Is there a way in a sqlform.grid to retrieve record field labels in a 
custom view?
Something like that:
grid.view_form.record.code.label

To retrieve:
db.define_table('memos',
Field('code', type='string', requires=IS_NOT_EMPTY(), label='*Codice*'),

Thanks, regards.

-- 
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: Problems with fpdf

2015-11-29 Thread Martin Weissenboeck
Thank you. I have tried version 1.7.2 - same result.

But it is solved: the .pkl-file is wrong.

I have taken a new set of dejavo*.ttf files from
http://freefr.dl.sourceforge.net/project/dejavu/dejavu/2.35/dejavu-fonts-ttf-2.35.zip
.
Then I have unziped and copied these files into contrib/fpdf/font

fpdf creates new .pkl after the first usage.

Don't forget to make www-data the owner of the font directory:
chown -R www-data:www-data font

Maybe a short description of these steps in the web2py book could help
others to use fpdf.

Regards, Martin




2015-11-29 4:55 GMT+01:00 Edwood :

> I am not having that problem when testing your code with pyfpdf 1.7.2,
> using the same font.  I noticed web2py 2.12.3 is still using pyfpdf 1.7.1.
> I recommend temporarily replacing pyfpdf folder with new version an try
> again.
>
>
> On Saturday, November 28, 2015 at 1:46:12 PM UTC-4, mweissen wrote:
>>
>> Hi, I have tried again to use fpdf.
>>
>> *1st try:*
>>
>> from gluon.contrib.fpdf import FPDF
>>
>> def test():
>> pdf = FPDF('P', 'mm', 'A4')
>> pdf.add_page()
>> pdf.set_font('Arial', 'B', 16)
>> pdf.cell(40,10,'Hello World')
>> response.headers['Content-Type'] = 'application/pdf'
>> return XML(pdf.output('', 'S'))
>>
>>
>> Ok, that's simple and it works fine.
>>
>> *2nd try:*
>>
>> Now I want to use the unicode version.
>> There is a example: https://code.google.com/p/pyfpdf/wiki/Unicode:
>>
>> *Before you can use UTF-8, you have to install at least one Unicode font
>> in the font directory (or system font folder).*
>>
>>
>> But there is no font directory in fpdf!
>>
>> It would be nice to have a complete example how to use fpdf in web2py!
>>
>> After some trials I had to copy the *font directory* containing a lot of
>> "DejaVu*"-files to the gluon/contrib/fpdf directory.
>>
>> The structure is: gluon/contrib/fpdf/font
>>
>>
>> ​from gluon.contrib.fpdf import FPDF
>>
>> def test():
>> pdf = FPDF('P', 'mm', 'A4')
>> pdf.add_page()
>> pdf.add_font('DejaVu', '', 'DejaVuSansCondensed.ttf', uni=True)
>> pdf.set_font('DejaVu', '', 14)
>> pdf.cell(40,10,'Hello World  äöü€')
>>
>> response.headers['Content-Type'] = 'application/pdf'
>> return XML(pdf.output('', 'S'))
>>
>>
>> ​And now I get an error message:
>>
>> ​ could not convert string to float
>>
>> Version
>> web2py™Version 2.12.3-stable+timestamp.2015.08.19.00.18.03PythonPython
>> 2.7.6: /usr/local/bin/python (prefix: /usr)
>> Traceback
>>
>> 1.
>> 2.
>> 3.
>> 4.
>> 5.
>> 6.
>> 7.
>> 8.
>> 9.
>> 10.
>> 11.
>> 12.
>>
>> Traceback (most recent call last):
>>   File "/home/www-data/web2py/gluon/restricted.py", line 227, in restricted
>> exec ccode in environment
>>   File "/home/www-data/web2py/applications/m_abschluss/controllers/test.py" 
>> , 
>> line 54, in 
>>   File "/home/www-data/web2py/gluon/globals.py", line 412, in 
>> self._caller = lambda f: f()
>>   File "/home/www-data/web2py/applications/m_abschluss/controllers/test.py" 
>> , 
>> line 26, in test
>> pdf.add_font('DejaVu', '', 'DejaVuSansCondensed.ttf', uni=True)
>>   File "/home/www-data/web2py/gluon/contrib/fpdf/fpdf.py", line 432, in 
>> add_font
>> font_dict = pickle.load(fh)
>> ValueError: could not convert string to float
>>
>>
>> ​
>> ​What is the right way to use fpdf with the whole unicode character set
>>  in web2py?​
>>
>> ​Regards, Martin​
>>
>>


-- 
Mit freundlichen Grüßen / With kind regards
Martin Weissenböck
Gregor-Mendel-Str. 37, 1190 Wien
Austria / European Union

-- 
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.