Re: [web2py] views: {{include var}}

2015-06-24 Thread Manuele Pesenti
Yes you need to pass a string in this way:
{{include "page.html"}}

Il 24/06/15 08:43, Dmitry Ermolaev ha scritto:
> |
> {{if 'page' in globals():}}
> {{include page}}
> {{else:}}
> {{=list}}
> {{pass}}
>
> |
> erro - 
>  File "C:\web2py-m\gluon\template.py", line 684, in parse
> self.include(top, value)
>   File "C:\web2py-m\gluon\template.py", line 462, in include
> text = self._get_file_text(filename)
>   File "C:\web2py-m\gluon\template.py", line 439, in _get_file_text
> filename = eval(filename, context)
>   File "", line 1, in 
> NameError: name 'page' is not defined
>
> -- 
> 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.

-- 
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: does every controller function require a view?

2015-06-24 Thread Manuele Pesenti
Il 23/06/15 20:30, Niphlod ha scritto:
> if you plan to use functions in controllers that MAY NOT be seen by
> users, just define them with a parameter (a dummy one works fine)
>
> def this_function_is_accessible():
> pass
>
> def this_is_not_accessible(dummy=None):
> pass
Another way I like is to define them in files inside a directory under
models with the same name of your controller. In that way the folder
content is read and the functions are defined in the framework
environment only when your controller is called.

Cheers

M.

-- 
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: how to use onupdate with grid

2015-06-24 Thread Niphlod
or just onupdate=updateAuthorizationStatus

On Tuesday, June 23, 2015 at 9:41:39 PM UTC+2, Alex Glaros wrote:
>
> is this right?
>
>   grid = SQLFORM.grid(db.AuthorizedInstance.id==request.get_vars.
> specificAuthorizationID, editable=True, deletable=False, create=False, 
> searchable=False, details=False, csv=False, maxtextlength=5000, onupdate=
> lambda form:updateAuthorizationStatus(form))
>
>
>

-- 
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] IS_TIME format

2015-06-24 Thread Annet
I wrote a widget to format time:

def timeplain(field, value):
if value == None:
value = ''
elif 'strftime' in dir(value):
value = value.strftime('%H:%M')
id = '%s_%s' % (field._tablename, field.name)
return INPUT(_type='text', _id=id, _class='form-control time_plain', 
_name=field.name, value=str(value), requires=field.requires)

and on the fileds of type time I have the following attributes:

istime = dict(type='time', requires=IS_TIME(error_message='Formaat komt 
niet overeen met HH:MM'), widget=timeplain)


This works fine unless the form contains an error on the field of type 
time, for example I have the following validation function:

def __onvalidation_openinghours(form):
if form.vars.startTime > form.vars.endTime:
form.errors.endTime = 'De eind tijd is vroeger dan de start tijd'

In this case the endTime is displayed in the format HH:MM:SS
The issue can be fixed by adding:

form.vars.endTime = form.vars.endTime.strftime('%H:%M')

after form.errors.endTime, however, I wonder whether there is a way to 
adjust the timeplain function to solve the issue.


Kind regards,

Annet



-- 
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: IS_TIME format

2015-06-24 Thread Niphlod
if you need a cutsom widget with a custom format, and you already rewrote 
the widget, why don't you rewrite also the validator ?!

On Wednesday, June 24, 2015 at 10:00:46 AM UTC+2, Annet wrote:
>
> I wrote a widget to format time:
>
> def timeplain(field, value):
> if value == None:
> value = ''
> elif 'strftime' in dir(value):
> value = value.strftime('%H:%M')
> id = '%s_%s' % (field._tablename, field.name)
> return INPUT(_type='text', _id=id, _class='form-control time_plain', 
> _name=field.name, value=str(value), requires=field.requires)
>
> and on the fileds of type time I have the following attributes:
>
> istime = dict(type='time', requires=IS_TIME(error_message='Formaat komt 
> niet overeen met HH:MM'), widget=timeplain)
>
>
> This works fine unless the form contains an error on the field of type 
> time, for example I have the following validation function:
>
> def __onvalidation_openinghours(form):
> if form.vars.startTime > form.vars.endTime:
> form.errors.endTime = 'De eind tijd is vroeger dan de start tijd'
>
> In this case the endTime is displayed in the format HH:MM:SS
> The issue can be fixed by adding:
>
> form.vars.endTime = form.vars.endTime.strftime('%H:%M')
>
> after form.errors.endTime, however, I wonder whether there is a way to 
> adjust the timeplain function to solve the issue.
>
>
> Kind regards,
>
> Annet
>
>
>
>

-- 
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] Ajax and table with queried values

2015-06-24 Thread Carla Raquel

I'm having a bit of trouble figuring out how to add info to a bootstrap 
table in a panel, through ajax.This's a phone call register system and I 
have the following code in the html:

resumoMensal.html




  
  Extensions
  

  

  
  
  {{for x in extension:}}

{{=x.Extension}}
{{pass}}
  
   
   




  Total 
Cost
{{if total_cost["_extra"]["SUM(Call.Cost)"]!=None:}}

€{{=total_cost["_extra"]["SUM(Call.Cost)"]}}
{{else:}}
 €0
{{pass}}




  
  
  {{for x in cost_types:}}

{{=x["Call"]["Type_service"]}}€{{=x["_extra"]["SUM(Call.Cost)"]}}
{{pass}}
  
   

   





  Total (min)
{{if min_total["_extra"]["SUM(Call.Duration)"]!=None:}}

{{=min_total["_extra"]["SUM(Call.Duration)"]}}
{{else:}}
 0
{{pass}}


 
  
   {{for x in cost_type:}}

{{=x["Call"]["Type_service"]}} (min){{=x["_extra"]["SUM(Call.Duration)"]}}
{{pass}}
  
   











When you click a certain link, the username, month and year is passed 
through as vars.Something along the lines of 
/resumoMensal?year=2015&month=April&name=John . After that, the 
What I want to do is exactly this: db is queried for the appropriate 
info(total cost,call duration,etc.,like represented in the code above) and 
through ajax I want to add the values retrieved, and display them in each 
of the td. How can I accomplish this?

-- 
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: Ajax and table with queried values

2015-06-24 Thread 黄祥
please see the book :
http://web2py.com/books/default/chapter/29/11/jquery-and-ajax#The-ajax-function
or web2py appliances (posonlinestore and estore) for example
http://www.web2py.com/appliances

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: How do I check of the version of pysimplesoap in web2py.

2015-06-24 Thread Encompass solutions
Found it.  it's in the init.py file in gluon/contrib/pysimplesoap/
It's version 1.11 which is a little behind, but there are some regression 
as of last year, we should check before bumping up the version.


On Wednesday, June 24, 2015 at 9:52:08 AM UTC+3, Encompass solutions wrote:
>
> I am trying to use soap and I am comming across errors from 2012 is the 
> version included in web2py always the latest with each new version of 
> web2py?  I do I check what version is included?
> I am getting a Tag not found: service (No elements found) error when 
> trying to get the wsdl file. (The file seems very good and well tested)
> BR,
> Jason
>

-- 
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: views: {{include var}}

2015-06-24 Thread Anthony
{{include}} and {{extend}} are template directives, not Python code. So, 
even if the Python "if" statement evaluates to False, the {{include page}} 
will still remain in the template and get executed (though once the actual 
template code is included there, *that *code will not be executed). So, 
instead, you have to do something like:

{{if 'include_page' in globals():}}
{{include 'page.html'}}
...

There is a simpler approach (though I'm not sure it is documented):

{{include page if 'page' in globals() else None}}

The advantage of this approach is that it does not actually include and 
parse the "page" template when the condition is False, so it should be 
faster in that case. The above also works with {{extend}}:

{{extend 'my_layout.html' if some_condition else None}}

Anthony

On Wednesday, June 24, 2015 at 2:43:21 AM UTC-4, Dmitry Ermolaev wrote:
>
> {{if 'page' in globals():}}
> {{include page}}
> {{else:}}
> {{=list}}
> {{pass}}
>
> erro - 
>
>  File "C:\web2py-m\gluon\template.py", line 684, in parse
> self.include(top, value)
>   File "C:\web2py-m\gluon\template.py", line 462, in include
> text = self._get_file_text(filename)
>   File "C:\web2py-m\gluon\template.py", line 439, in _get_file_text
> filename = eval(filename, context)
>   File "", line 1, in 
> NameError: name 'page' is not defined
>
>
> OR how include HTML file in controller?
>

-- 
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: views: {{include var}}

2015-06-24 Thread Dmitry Ermolaev
solve:  use response.render:

in controller:
from gluon.fileutils import read_file
spath = 'static/pages/' + cat.folder + '/'
spath1 = '/' + request.application + '/' + spath
h += XML(response.render(request.folder + spath + rec.file_, 
dict(sp=spath1)))
Введите код...






среда, 24 июня 2015 г., 9:43:21 UTC+3 пользователь Dmitry Ermolaev написал:
>
> {{if 'page' in globals():}}
> {{include page}}
> {{else:}}
> {{=list}}
> {{pass}}
>
> erro - 
>
>  File "C:\web2py-m\gluon\template.py", line 684, in parse
> self.include(top, value)
>   File "C:\web2py-m\gluon\template.py", line 462, in include
> text = self._get_file_text(filename)
>   File "C:\web2py-m\gluon\template.py", line 439, in _get_file_text
> filename = eval(filename, context)
>   File "", line 1, in 
> NameError: name 'page' is not defined
>
>
> OR how include HTML file in controller?
>

-- 
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: views: {{include var}}

2015-06-24 Thread Dmitry Ermolaev
if that variable [page] not in globals - error raised
if [page] is setted - all work

среда, 24 июня 2015 г., 15:42:56 UTC+3 пользователь Anthony написал:
>
> {{include}} and {{extend}} are template directives, not Python code. So, 
> even if the Python "if" statement evaluates to False, the {{include page}} 
> will still remain in the template and get executed (though once the actual 
> template code is included there, *that *code will not be executed). So, 
> instead, you have to do something like:
>
> {{if 'include_page' in globals():}}
> {{include 'page.html'}}
> ...
>
> There is a simpler approach (though I'm not sure it is documented):
>
> {{include page if 'page' in globals() else None}}
>
> The advantage of this approach is that it does not actually include and 
> parse the "page" template when the condition is False, so it should be 
> faster in that case. The above also works with {{extend}}:
>
> {{extend 'my_layout.html' if some_condition else None}}
>
> Anthony
>
> On Wednesday, June 24, 2015 at 2:43:21 AM UTC-4, Dmitry Ermolaev wrote:
>>
>> {{if 'page' in globals():}}
>> {{include page}}
>> {{else:}}
>> {{=list}}
>> {{pass}}
>>
>> erro - 
>>
>>  File "C:\web2py-m\gluon\template.py", line 684, in parse
>> self.include(top, value)
>>   File "C:\web2py-m\gluon\template.py", line 462, in include
>> text = self._get_file_text(filename)
>>   File "C:\web2py-m\gluon\template.py", line 439, in _get_file_text
>> filename = eval(filename, context)
>>   File "", line 1, in 
>> NameError: name 'page' is not defined
>>
>>
>> OR how include HTML file in controller?
>>
>

-- 
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: views: {{include var}}

2015-06-24 Thread Dmitry Ermolaev
thanx - it work!

in controller:
spath = 'views/default/pages/' + cat.folder + '/'
spath1 = '/' + request.application + '/default/stream/' + 
spath
return dict(page=request.folder + spath + rec.file_, 
sp=spath1, h=h, f=f)



and I add path to urls by use 
def stream():
f = request.folder + '/' + '/'.join(request.args)
return response.stream(f, request=request)


and in view:
{{extend 'layout.html'}}

{{if 'h' in globals():}}
{{=h}}
{{pass}}

{{include page if 'page' in globals() else None}}

{{if 'f' in globals():}}
{{=f}}
{{pass}}




in included files arrange urls:




среда, 24 июня 2015 г., 15:42:56 UTC+3 пользователь Anthony написал:
>
> {{include}} and {{extend}} are template directives, not Python code. So, 
> even if the Python "if" statement evaluates to False, the {{include page}} 
> will still remain in the template and get executed (though once the actual 
> template code is included there, *that *code will not be executed). So, 
> instead, you have to do something like:
>
> {{if 'include_page' in globals():}}
> {{include 'page.html'}}
> ...
>
> There is a simpler approach (though I'm not sure it is documented):
>
> {{include page if 'page' in globals() else None}}
>
> The advantage of this approach is that it does not actually include and 
> parse the "page" template when the condition is False, so it should be 
> faster in that case. The above also works with {{extend}}:
>
> {{extend 'my_layout.html' if some_condition else None}}
>
> Anthony
>
> On Wednesday, June 24, 2015 at 2:43:21 AM UTC-4, Dmitry Ermolaev wrote:
>>
>> {{if 'page' in globals():}}
>> {{include page}}
>> {{else:}}
>> {{=list}}
>> {{pass}}
>>
>> erro - 
>>
>>  File "C:\web2py-m\gluon\template.py", line 684, in parse
>> self.include(top, value)
>>   File "C:\web2py-m\gluon\template.py", line 462, in include
>> text = self._get_file_text(filename)
>>   File "C:\web2py-m\gluon\template.py", line 439, in _get_file_text
>> filename = eval(filename, context)
>>   File "", line 1, in 
>> NameError: name 'page' is not defined
>>
>>
>> OR how include HTML file in controller?
>>
>

-- 
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: Plain Text and HTML Email with auth.messages.verify_email

2015-06-24 Thread Mark Li
Hey Falko,

I went with plain text email at first, but now everything is HTML email.
Sorry I can't really help you out here!

On Sat, Jun 20, 2015 at 4:10 PM, Falko Delarue 
wrote:

> how did you do it? could you please explain ┐(・。・┐) ♪
>
>
> On Saturday, September 15, 2012 at 1:17:50 AM UTC+2, c h wrote:
>>
>> for what it's worth i have re-implemented some of the auth functions that
>> send mail so that i can send both plain text and HTML emails (i don't read
>> email in HTML so i still like plain text versions).  i'm not sure how many
>> people are left who are like meif there are enough it would be great to
>> be able to specify to auth the plain text and the HTML versions for all
>> emails - perhaps even pass in path to views (which is what i do in my
>> extensions).
>>
>> cfh
>>
>> On Friday, September 14, 2012 2:25:04 PM UTC-7, Massimo Di Pierro wrote:
>>>
>>> If the email text looks like '' it should be send as
>>> html.
>>>
>>> On Friday, 14 September 2012 12:12:21 UTC-5, Mark Li wrote:

 Is it possible to send both Plain Text and HTML Emails with
 auth.messages.verify_email? From the book, it seems
 auth.messages.verify_email only accepts a single string.


  --
> 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/x7NSemz7Jx8/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to
> web2py+unsubscr...@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.


Re: [web2py] Re: does every controller function require a view?

2015-06-24 Thread Fabiano Almeida
or init function name with double underscore:

def __test():
pass

the __ make function usable in your code, but not visible in browser.

Fabiano.

2015-06-23 15:30 GMT-03:00 Niphlod :

> if you plan to use functions in controllers that MAY NOT be seen by users,
> just define them with a parameter (a dummy one works fine)
>
> def this_function_is_accessible():
> pass
>
> def this_is_not_accessible(dummy=None):
> pass
>
>
> On Tuesday, June 23, 2015 at 7:27:42 PM UTC+2, Alex Glaros wrote:
>>
>> some functions are not viewed by user; they just return data to another
>> function.  Do those need a view?
>>
>> I ask because if it crashes, then user may see the raw view
>>
>> thanks
>>
>> Alex Glaros
>>
>  --
> 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.
>

-- 
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] empy string from csv for integer for integer field

2015-06-24 Thread goome
Hello
i have a table with integer field.
i populated thhe db from a csv (created from other then me).
it sometimes has empty value for the integers fields.
So when i try to get a list of the records of the table, i got:
type 'exceptions.ValueError'> invalid literal for long() with base 10: ''

from db.py  #table prodotti
Field("lunghezza","integer"),
Field("larghezza","integer"),

from default.py
prodotti = legacy_db().select(legacy_db.prodotti.ALL,orderby='prodotti.id 
DESC', limitby=limitby)

The error ticket:
File 
"/home/marcello/scripts/web2py/2/web2py/applications/PROVE/controllers/default.py",
 
line 171, in lista_prodotti
prodotti = 
legacy_db().select(legacy_db.prodotti.ALL,orderby='prodotti.id DESC', 
limitby=limitby)
  File 
"/home/marcello/scripts/web2py/2/web2py/gluon/packages/dal/pydal/objects.py", 
line 2026, in select
return adapter.select(self.query,fields,attributes)
  File 
"/home/marcello/scripts/web2py/2/web2py/gluon/packages/dal/pydal/adapters/sqlite.py",
 
line 125, in select
return super(SQLiteAdapter, self).select(query, fields, attributes)
  File 
"/home/marcello/scripts/web2py/2/web2py/gluon/packages/dal/pydal/adapters/base.py",
 
line 1239, in select
return self._select_aux(sql,fields,attributes)
  File 
"/home/marcello/scripts/web2py/2/web2py/gluon/packages/dal/pydal/adapters/base.py",
 
line 1220, in _select_aux
return processor(rows,fields,self._colnames,cacheable=cacheable)
  File 
"/home/marcello/scripts/web2py/2/web2py/gluon/packages/dal/pydal/adapters/base.py",
 
line 1596, in parse
value = self.parse_value(value,ft,blob_decode)
  File 
"/home/marcello/scripts/web2py/2/web2py/gluon/packages/dal/pydal/adapters/base.py",
 
line 1450, in parse_value
return self.parsemap[key](value,field_type)
  File 
"/home/marcello/scripts/web2py/2/web2py/gluon/packages/dal/pydal/adapters/base.py",
 
line 1534, in parse_integer
return long(value)
ValueError: invalid literal for long() with base 10: ''

how to face with empty values?

-- 
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: Ajax and table with queried values

2015-06-24 Thread Dave S


On Wednesday, June 24, 2015 at 4:16:01 AM UTC-7, 黄祥 wrote:
>
> please see the book :
>
> http://web2py.com/books/default/chapter/29/11/jquery-and-ajax#The-ajax-function
> or web2py appliances (posonlinestore and estore) for example
> http://www.web2py.com/appliances
>
>
Note that the technique involves having a target DIV that the ajax response 
is loaded into.  My experience is with controllers returning
 HTML from the server-side processing (a long string, with the occasional 
A() or IMG()), or with a dict whose one entry is an array of tuples that is 
turned into a TABLE() in the view (so also server-side processing).

I'm interested in converting the latter into something using Datatables or 
HandsOnTables, but haven't progressed very far with that yet.

/dps

-- 
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] set of rows as input to smart grid

2015-06-24 Thread Davy Jacops
Typically, smartgrid takes a query as argument.
But what if that query is the result of a join where some fields may not be 
displayed in the smart grid?

Example:

q = ((db.t1.f1 == db.t2.f21) & (db.t2.f22 == db.t3.f3))
grid=SQLFORM.smartgrid(db.t1, constraints = dict(t1=query))
return locals()


What if we want to display in the smart gird ONLY fields of t1?

DJ 





-- 
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: How do I check of the version of pysimplesoap in web2py.

2015-06-24 Thread Dave S


On Wednesday, June 24, 2015 at 4:39:57 AM UTC-7, Encompass solutions wrote:
>
> Found it.  it's in the init.py file in gluon/contrib/pysimplesoap/
> It's version 1.11 which is a little behind, but there are some regression 
> as of last year, we should check before bumping up the version.
>
>
FWIW, I also use pysimplesoap (it's what brought me to web2py), both with a 
third party target and with my own SOAP target.  It works well with these.

I tried using it with a different third party target that had some special 
WSDL handling required , and I wasn't successful with that.  I had some 
conversations here about it, and the dev (M Reingart) tried to help, but I 
didn't know my way around the code well enough to nail things down, and 
didn't have time then to come more up to speed.  (I have a TooManyTabs 
bookmark for "Fixing Broken WSDL")


/dps



> On Wednesday, June 24, 2015 at 9:52:08 AM UTC+3, Encompass solutions wrote:
>>
>> I am trying to use soap and I am comming across errors from 2012 is the 
>> version included in web2py always the latest with each new version of 
>> web2py?  I do I check what version is included?
>> I am getting a Tag not found: service (No elements found) error when 
>> trying to get the wsdl file. (The file seems very good and well tested)
>> BR,
>> Jason
>>
>

-- 
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: empy string from csv for integer for integer field

2015-06-24 Thread Niphlod
an integer can't be ''. set them to null of to 0 at import time :D

On Wednesday, June 24, 2015 at 7:28:21 PM UTC+2, goome wrote:
>
> Hello
> i have a table with integer field.
> i populated thhe db from a csv (created from other then me).
> it sometimes has empty value for the integers fields.
> So when i try to get a list of the records of the table, i got:
> type 'exceptions.ValueError'> invalid literal for long() with base 10: ''
>
> from db.py  #table prodotti
> Field("lunghezza","integer"),
> Field("larghezza","integer"),
>
> from default.py
> prodotti = legacy_db().select(legacy_db.prodotti.ALL,orderby='prodotti.id 
> DESC', limitby=limitby)
>
> The error ticket:
> File 
> "/home/marcello/scripts/web2py/2/web2py/applications/PROVE/controllers/default.py",
>  
> line 171, in lista_prodotti
> prodotti = legacy_db().select(legacy_db.prodotti.ALL,orderby='
> prodotti.id DESC', limitby=limitby)
>   File 
> "/home/marcello/scripts/web2py/2/web2py/gluon/packages/dal/pydal/objects.py", 
> line 2026, in select
> return adapter.select(self.query,fields,attributes)
>   File 
> "/home/marcello/scripts/web2py/2/web2py/gluon/packages/dal/pydal/adapters/sqlite.py",
>  
> line 125, in select
> return super(SQLiteAdapter, self).select(query, fields, attributes)
>   File 
> "/home/marcello/scripts/web2py/2/web2py/gluon/packages/dal/pydal/adapters/base.py",
>  
> line 1239, in select
> return self._select_aux(sql,fields,attributes)
>   File 
> "/home/marcello/scripts/web2py/2/web2py/gluon/packages/dal/pydal/adapters/base.py",
>  
> line 1220, in _select_aux
> return processor(rows,fields,self._colnames,cacheable=cacheable)
>   File 
> "/home/marcello/scripts/web2py/2/web2py/gluon/packages/dal/pydal/adapters/base.py",
>  
> line 1596, in parse
> value = self.parse_value(value,ft,blob_decode)
>   File 
> "/home/marcello/scripts/web2py/2/web2py/gluon/packages/dal/pydal/adapters/base.py",
>  
> line 1450, in parse_value
> return self.parsemap[key](value,field_type)
>   File 
> "/home/marcello/scripts/web2py/2/web2py/gluon/packages/dal/pydal/adapters/base.py",
>  
> line 1534, in parse_integer
> return long(value)
> ValueError: invalid literal for long() with base 10: ''
>
> how to face with empty values?
>
>

-- 
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: empy string from csv for integer for integer field

2015-06-24 Thread Dave S


On Wednesday, June 24, 2015 at 10:28:21 AM UTC-7, goome wrote:
>
> Hello
> i have a table with integer field.
> i populated thhe db from a csv (created from other then me).
> it sometimes has empty value for the integers fields.
> So when i try to get a list of the records of the table, i got:
> type 'exceptions.ValueError'> invalid literal for long() with base 10: ''
>
> [...] 
>
how to face with empty values?
>
>
I think the simplest choices are probably
*  preprocessing (for example, runnng the CSV file through sed or awk to 
replace ',,' with ' ,-999,' (or other value you can recognize as 
"illegal")
*  customizing the CSV import code to allow an empty field.

/dps

-- 
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: empy string from csv for integer for integer field

2015-06-24 Thread Dave S


On Wednesday, June 24, 2015 at 11:43:46 AM UTC-7, Dave S wrote:

But hey, Niphlod beat me to it.

 

> On Wednesday, June 24, 2015 at 10:28:21 AM UTC-7, goome wrote:
>>
>> Hello
>> i have a table with integer field.
>> i populated thhe db from a csv (created from other then me).
>> it sometimes has empty value for the integers fields.
>> So when i try to get a list of the records of the table, i got:
>> type 'exceptions.ValueError'> invalid literal for long() with base 10: ''
>>
>> [...] 
>>
> how to face with empty values?
>>
>>
> I think the simplest choices are probably
> *  preprocessing (for example, runnng the CSV file through sed or awk to 
> replace ',,' with ' ,-999,' (or other value you can recognize as 
> "illegal")
>

This is similar to Niphlod's advice.  But lacking his deeper knowledge, I'd 
be running a "cleanup job" (post-processing) on the imported data to 
convert the "illegal" values to NULL.  Probably through the scheduler.
 

> *  customizing the CSV import code to allow an empty field.
>

Or changing the field definition, perhaps to a string type, and then 
converting non-empty strings at a later time.

Or changing the validator to provide the NULL.
 
/dps

-- 
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: How do I check of the version of pysimplesoap in web2py.

2015-06-24 Thread Limedrop
SOAP can really be a world of pain.  I spent hours trying to connect to a 
SOAP service and the best I could get was a "400 Bad Request".  It turned 
out that they were using wsHttpBinding - which seems to only be supported 
by .NET clients.  The work-around is to manually inject the WS-Security 
headers into the SOAP envelope.  In the end I gave up and reverted to a 
service using basicHttp binding.

Long story, short: pysimplesoap works really well.  It is SOAP itself that 
is overly complex and mostly broken.

And for anyone out there experiencing the pain, here's some sample code 
that I use as a sanity check.  The 'trace' option leaves a nice trail on 
the console - but remember to turn it off in production.

from gluon.contrib.pysimplesoap.client import SoapClient, 
SoapFault
url = "http://wsf.cdyne.com/WeatherWS/Weather.asmx?WSDL";
client = SoapClient(wsdl=url, trace = True) 

parameters = {}
parameters['ZIP'] = 90210

try:
response = client.GetCityWeatherByZIP(**parameters) 
except SoapFault as e:
response = "ERROR {0}: {1}".format(e.faultcode, 
e.faultstring)


On Thursday, 25 June 2015 06:32:00 UTC+12, Dave S wrote:
>
>
>
> On Wednesday, June 24, 2015 at 4:39:57 AM UTC-7, Encompass solutions wrote:
>>
>> Found it.  it's in the init.py file in gluon/contrib/pysimplesoap/
>> It's version 1.11 which is a little behind, but there are some regression 
>> as of last year, we should check before bumping up the version.
>>
>>
> FWIW, I also use pysimplesoap (it's what brought me to web2py), both with 
> a third party target and with my own SOAP target.  It works well with these.
>
> I tried using it with a different third party target that had some special 
> WSDL handling required , and I wasn't successful with that.  I had some 
> conversations here about it, and the dev (M Reingart) tried to help, but I 
> didn't know my way around the code well enough to nail things down, and 
> didn't have time then to come more up to speed.  (I have a TooManyTabs 
> bookmark for "Fixing Broken WSDL")
>
>
> /dps
>
>
>
>> On Wednesday, June 24, 2015 at 9:52:08 AM UTC+3, Encompass solutions 
>> wrote:
>>>
>>> I am trying to use soap and I am comming across errors from 2012 is the 
>>> version included in web2py always the latest with each new version of 
>>> web2py?  I do I check what version is included?
>>> I am getting a Tag not found: service (No elements found) error when 
>>> trying to get the wsdl file. (The file seems very good and well tested)
>>> BR,
>>> Jason
>>>
>>

-- 
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: empy string from csv for integer for integer field

2015-06-24 Thread goome
> Or changing the validator to provide the NULL.

how could it be done? in the model?
Thanks

>
>
>

-- 
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: empy string from csv for integer for integer field

2015-06-24 Thread 黄祥
they suggest to change your csv that have '' empty or null value for the 
field that have integer type. another way around is to set default = 0 in 
your table definition in models for that table.

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: empy string from csv for integer for integer field

2015-06-24 Thread Dave S


On Wednesday, June 24, 2015 at 2:34:40 PM UTC-7, goome wrote:
>
> > Or changing the validator to provide the NULL.
>
> how could it be done? in the model?
>

I believe so, but I've only played around a little with validators.  The 
other suggestions may be simpler for you.
Or you can search for custom validators among the old posts, and check the 
web2py book
http://www.web2py.com/books/default/chapter/29/07/forms-and-validators#Custom-validators>

In my db.py, I have (at the end) this terribly unsophisticated custom 
validator.


from gluon.validators import Validator

class IS_HEXSTR(Validator):
def __init__(self, format='%c%c%c%c', error_message='must be a 4-digit 
hex string like A09F!'):
self.format = format
self.error_message = error_message
def __call__(self, value):
try:
if len(value) != 4:
raise ValueError
intvalue = int(value, 16)
print "should be valid " + str(intvalue)
return (value, None)
except ValueError:
print "invalid " + value
return (value, self.error_message)
except Exception as e:
print "invalid " + value
raise e
def formatter(self, value):
return value.upper()



-- 
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: sending email

2015-06-24 Thread Michael Beller
If you have two factor auth enabled in gmail you need to authorize app and 
generate unique password

-- 
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] set of rows as input to smart grid

2015-06-24 Thread Michael Beller
You can pass a list of fields using the 'fields' arg of smartgrid

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