[web2py] Re: list:string field length

2017-11-19 Thread Anthony
On Saturday, November 18, 2017 at 6:57:54 PM UTC-5, Donald McClymont wrote:
>
> Issue may be with SQLFORM rather than Pydal - if I have a list string 
> field in my case its called answers and put it in a SQLFORM then in 
> form.validate if you do
>
> print type(form.vars.answers)
>
> I get str when there is 1 item in my list and list when multiple answers and 
> so my validation includes a line like this:
>
>
> if isinstance(form.vars.answers, list) and len(form.vars.answers) > 1 and 
> len(form.vars.answers[1]) > 0:
>
>
> I just thought I'd mention it as something to be aware of if you start using 
> length with list string fields as I always expected it to be a list. 
>
>
> This is still the case with 2.16.1
>
>
Got it. That has to do with the widget used to represent list:string fields 
in forms. It simply creates one or more inputs with the same name. When 
there is only one item, the value in request.vars and therefore form.vars 
is just a string, but when there are multiple form elements with the same 
name, request.vars and form.vars ends up as a list. SQLFORM.accepts does 
ultimately convert a single string in form.vars to a single element list, 
but not until after the onvalidation function has been run. Feel free to 
submit a Github issue about this (in the web2py repo, as it is related to 
SQLFORM, not PyDAL).

Anthony

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


[web2py] Re: list:string field length

2017-11-18 Thread Donald McClymont
Issue may be with SQLFORM rather than Pydal - if I have a list string field 
in my case its called answers and put it in a SQLFORM then in form.validate 
if you do

print type(form.vars.answers)

I get str when there is 1 item in my list and list when multiple answers and so 
my validation includes a line like this:


if isinstance(form.vars.answers, list) and len(form.vars.answers) > 1 and 
len(form.vars.answers[1]) > 0:


I just thought I'd mention it as something to be aware of if you start using 
length with list string fields as I always expected it to be a list. 


This is still the case with 2.16.1


Donald



On Friday, November 17, 2017 at 11:47:49 PM UTC, Anthony wrote:

> On Friday, November 17, 2017 at 3:53:02 PM UTC-5, Donald McClymont wrote:
>
>> I don’t think you can set this but not sure why you would want to. 
>>  However beware if testing the length of the field as I think if you only 
>> have 1 item in the list then this is a string and you get the number of 
>> chars in the string.  While if you have more than 1 you get the length of 
>> the list.
>
>
> Can you show some code demonstrating what you mean -- I cannot replicate? 
> If you use the DAL to select data, it automatically converts the native 
> data to a Python list, even if the list includes only a single item. So, if 
> you do something like len(db.mytable(1).my_list_string_field), you should 
> always get the length of the list, not the length of any single element in 
> the list.
>
> Anthony
>

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


[web2py] Re: list:string field length

2017-11-17 Thread Anthony
On Friday, November 17, 2017 at 3:53:02 PM UTC-5, Donald McClymont wrote:
>
> I don’t think you can set this but not sure why you would want to. 
>  However beware if testing the length of the field as I think if you only 
> have 1 item in the list then this is a string and you get the number of 
> chars in the string.  While if you have more than 1 you get the length of 
> the list.


Can you show some code demonstrating what you mean -- I cannot replicate? 
If you use the DAL to select data, it automatically converts the native 
data to a Python list, even if the list includes only a single item. So, if 
you do something like len(db.mytable(1).my_list_string_field), you should 
always get the length of the list, not the length of any single element in 
the list.

Anthony

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


[web2py] Re: list:string field length

2017-11-17 Thread Anthony
On Friday, November 17, 2017 at 10:32:21 AM UTC-5, Yoel Benitez Fonseca 
wrote:
>
> h! 
>
> I always wanted to ask: According the online book, it is recommended 
> to explicit set the length of  "string", "password" or "upload", but 
> what about list:string ? 
>

I don't think the "length" attribute is relevant for list:string fields 
because the field is defined as a list in databases that natively support 
lists (i.e., nosql databases) and as a text field in SQL databases (the 
list is converted to a string with the elements separated by the pipe 
character).

Anthony

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


[web2py] Re: list:string field length

2017-11-17 Thread Pierre
if this is what you want, you can control | limit the length of a 
list:string field using a custom validator. this is documented in the book.

-- 
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: list:string and form.errors

2016-02-15 Thread Pierre
I'll give a try to this:

http://web2py.com/books/default/chapter/29/11/jquery-and-ajax?search=form.errors

all I need is to point out 'faulty' inputs. If I can pass index to JQUERY 
it seems workable..


we'll see.

-- 
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: list:string and form.errors

2016-02-14 Thread Pierre
I might be able to fix this with some JQUERY code, if I can pass the error 
index from onvalidation to jquery i am saved...we'll see.

-- 
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: list:string and form.errors

2016-02-13 Thread Niphlod
no, there isn't. the list:string widget is still attached to a single 
field, and the error message is attached to that field only.

if you want to do a custom validation on each input, you should just use a 
custom form 

On Saturday, February 13, 2016 at 2:59:24 PM UTC+1, Pierre wrote:
>
> Hi everyone,
>
> I have a sqlform to display a list:string field form and an onvalidation 
> function to check each data entry of the list. The error message always 
> shows at the bottom of the form whereas I would like to identify the 
> precise data entry responsible for that error (show the error in the 
> related row).
>
> Is there a way to do 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: list:string how to limit the number of strings

2015-12-06 Thread Pierre

custom validator fails : why ?

model:

class IS_LIST_TAGS:
def __init__(self, separator=',', error_message='too many tags max=3 
tags!'):
self.separator = separator
self.e = error_message

def __call__(self,value):
try:
li = value.split(self.separator)
assert(len(li) <= 3)
return (li, None)

db.define_table('listr',
Field('tags','list:string',requires=[IS_NOT_EMPTY(), 
IS_LIST_TAGS()]))

controller:

def test():
form = SQLFORM(db.listr)
if form.process().accepted:
response.flash = 'form accepted'
elif form.errors:
response.flash = 'form has errors'
else:
response.flash = 'please fill out the form'
return dict(form=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] Re: list:string on GAE breaks web2py's db admin tool

2015-05-06 Thread Massimo Di Pierro
oops. Thanks for the fix.

On Monday, 4 May 2015 10:56:36 UTC-5, michael.c.mccl...@gmail.com wrote:

 I've started using a list:string field on the auth_user model.

 I'm running web2py on GAE with the datastore.


 I noticed web2py's admin tool started crashing on this page 
 appadmin/select/db?query=db.auth_user.id0


 looking at the console I found:


 /gluon/dal.py, line 10035, in genexpr

 return ', '.join(str(y) for y in x or [])

 UnicodeEncodeError: 'ascii' codec can't encode character u'\xe1' in position 
 1: ordinal not in range(128)

 It seems web2py is not properly handling the datastore string list property. 

 I fixed the problem by adding .encoding(utf8) to the dal.py function below:

 def list_represent(x, r=None):
 #return ', '.join(str(y) for y in x or [])
 return ', '.join(str(y.encode(utf8)) for y in x or [])


 Has anybody else experienced the same error?


 tks



-- 
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: list:string type field is empty value on edit page

2015-05-04 Thread Ben Lawrence
Thanks for your work around. I see this too. It seems more convenient to 
use:
Field('gender','string',requires=IS_IN_SET(('Male', 'Female')))
as this will keep the default when in edit.


On Sunday, April 7, 2013 at 10:00:28 PM UTC-7, 黄祥 wrote:

 i've already start testing using the simple table (start from scratch) but 
 got the same result. here is my conclusion, please correct me if i'm wrong :
 - if you combine list:string field with IS_IN_SET validator, in form edit 
 you will receive blank value in drop down, not the existing value that 
 stored in database. 
 - if you want to use IS_IN_SET validator and in form edit will show the 
 existing value that store in database, please use string type field in your 
 define table.

 *e.g. in form edit receive blank value in drop down field, not the 
 existing value that stored in database*
 *db.py*
 db.define_table('gender',
 Field('gender', 'list:string'),
 format='%(gender)s')

 db.gender.gender.requires=IS_IN_SET(['Male', 'Female'])

 *default.py*
 def gender():
 grid=SQLFORM.grid(db.gender, user_signature=False)
 return locals()

 *default/gender.html*
 {{extend 'layout.html'}}

 {{=grid}}

 *e.g. in form edit will show the existing value that store in database*
 *db.py*
 db.define_table('gender',
 Field('gender'),
 format='%(gender)s')

 db.gender.gender.requires=IS_IN_SET(['Male', 'Female'])

 *default.py*
 def gender():
 grid=SQLFORM.grid(db.gender, user_signature=False)
 return locals()

 *default/gender.html*
 {{extend 'layout.html'}}

 {{=grid}}


-- 
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: list:string type issues

2014-10-05 Thread Anthony
Can you show your code? If you want to store a Python structure, you're 
probably better off using a json field type, which will automatically 
serialize back and forth between Python and JSON (the list:string type is 
meant for storing a list of strings, not a list of Python lists).

Anthony

On Sunday, October 5, 2014 5:45:44 AM UTC-4, Greg Vaughan wrote:

 Hi Guys,

 I am using a list:string to store a list of lists. Each seperate list has 
 4 values, qty (int), name (string), description (text) and price(double). 
 Stores nicely and looks fine in the db table eg.

 [1, 'OS 7030', 'OS 7030', 755.0], [3, 'SMT 24 Btn', 'SMT IP Phone', 
 360.0], [1, 'SMT IP', 'SMT IP Phone Licence', 70.0], [1, '2830 SIP Router', 
 '2830', 499.0], [1, 'ADSL Central Filter ', 'ADSL Central Filter ', 61.5]

 However if I try to iterate and get some totals it is getting confused. 
 For example the same list above becomes...

 [[1, 'OS 7030', 'OS 7030', 755.0], [3, 'SMT 24 Btn', 'SMT IP Phone', 
 360.0], [1, 'SMT IP', 'SMT IP Phone Licence', 70.0], [1, '2830 SIP 
 Router', '2830', 499.0], [1, 'ADSL Central Filter ', 'ADSL Central Filter 
 ', 61.5]]

 Iterating list[0] returns [ [ [ [ [  list[1] returns 1 3 1 1 1 list[2] , , 
 , , , list[3] returns a list of the spaces, list[4] the apostrophes ' ' ' ' 
 ' list[5] O S S 2 A etc etc...

 What do I have to change so that it is being interpreted correctly?






-- 
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: list:string type issues

2014-10-05 Thread Greg Vaughan
Ahh Anthony what would we do without you... tyvm... (again)

a few quick changes to code and works a charm...

Cheers
Greg

On Monday, 6 October 2014 00:48:09 UTC+10, Anthony wrote:

 Can you show your code? If you want to store a Python structure, you're 
 probably better off using a json field type, which will automatically 
 serialize back and forth between Python and JSON (the list:string type is 
 meant for storing a list of strings, not a list of Python lists).

 Anthony

 On Sunday, October 5, 2014 5:45:44 AM UTC-4, Greg Vaughan wrote:

 Hi Guys,

 I am using a list:string to store a list of lists. Each seperate list has 
 4 values, qty (int), name (string), description (text) and price(double). 
 Stores nicely and looks fine in the db table eg.

 [1, 'OS 7030', 'OS 7030', 755.0], [3, 'SMT 24 Btn', 'SMT IP Phone', 
 360.0], [1, 'SMT IP', 'SMT IP Phone Licence', 70.0], [1, '2830 SIP Router', 
 '2830', 499.0], [1, 'ADSL Central Filter ', 'ADSL Central Filter ', 61.5]

 However if I try to iterate and get some totals it is getting confused. 
 For example the same list above becomes...

 [[1, 'OS 7030', 'OS 7030', 755.0], [3, 'SMT 24 Btn', 'SMT IP Phone', 
 360.0], [1, 'SMT IP', 'SMT IP Phone Licence', 70.0], [1, '2830 SIP 
 Router', '2830', 499.0], [1, 'ADSL Central Filter ', 'ADSL Central Filter 
 ', 61.5]]

 Iterating list[0] returns [ [ [ [ [  list[1] returns 1 3 1 1 1 list[2] , 
 , , , , list[3] returns a list of the spaces, list[4] the apostrophes ' ' ' 
 ' ' list[5] O S S 2 A etc etc...

 What do I have to change so that it is being interpreted correctly?






-- 
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: list:string

2014-04-03 Thread Anthony
Can we see some code (and maybe a screenshot of what you see)? The default 
list:string widget requires an up-to-date web2py.js file.

On Thursday, April 3, 2014 12:23:08 AM UTC-4, horridohobbyist wrote:

 I've added a 'list:string' field to my table, but when adding a new record 
 from admin (using the new record form), I can't figure out how to enter the 
 data. I don't understand what format it expects.

 I tried ['item1','item2']. I tried |'item1'|'item2'|. They both don't 
 work.


-- 
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: list:string

2014-04-03 Thread horridohobbyist
db.define_table('products',
Field('thumbnail', 
'upload',uploadfield='image_data',represent=lambda v, r: 
IMG(_src=URL('download',args=v))),
Field('image_data', 'blob',readable=False),
Field('name',unique=True,represent=lambda v, r: 
A(v,_href=URL('view',args=[db.products,r.id])) + XML('br'+r.description)),
Field('category',represent=lambda v, r: 
DIV(v,_style='width:75px;word-wrap:break-word;')),
Field('description','text',represent=lambda v, r: ''),
Field('choices','text',readable=False),
Field('shift','list:string',readable=False),

I initialize the field with .update(shift=['colour','size'])

When I retrieve the field, I indeed can access the list items. However, in 
admin, I see this:

https://lh4.googleusercontent.com/-EfRWKJ_pUWQ/Uz1spRS9D0I/A40/H6TpxX6w7oM/s1600/Screen+Shot+2014-04-03+at+10.08.10+AM.png
I know the data is in the field. Why can't I see it??


On Thursday, 3 April 2014 09:37:41 UTC-4, Anthony wrote:

 Can we see some code (and maybe a screenshot of what you see)? The default 
 list:string widget requires an up-to-date web2py.js file.

 On Thursday, April 3, 2014 12:23:08 AM UTC-4, horridohobbyist wrote:

 I've added a 'list:string' field to my table, but when adding a new 
 record from admin (using the new record form), I can't figure out how to 
 enter the data. I don't understand what format it expects.

 I tried ['item1','item2']. I tried |'item1'|'item2'|. They both 
 don't work.



-- 
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: list:string

2014-04-03 Thread Anthony
And you're sure you have the version of web2py.js associated with the 
version of web2py you are running, and that it is loaded on the page?

On Thursday, April 3, 2014 10:17:58 AM UTC-4, horridohobbyist wrote:

 db.define_table('products',
 Field('thumbnail', 
 'upload',uploadfield='image_data',represent=lambda v, r: 
 IMG(_src=URL('download',args=v))),
 Field('image_data', 'blob',readable=False),
 Field('name',unique=True,represent=lambda v, r: 
 A(v,_href=URL('view',args=[db.products,r.id])) + 
 XML('br'+r.description)),
 Field('category',represent=lambda v, r: 
 DIV(v,_style='width:75px;word-wrap:break-word;')),
 Field('description','text',represent=lambda v, r: ''),
 Field('choices','text',readable=False),
 Field('shift','list:string',readable=False),

 I initialize the field with .update(shift=['colour','size'])

 When I retrieve the field, I indeed can access the list items. However, in 
 admin, I see this:


 https://lh4.googleusercontent.com/-EfRWKJ_pUWQ/Uz1spRS9D0I/A40/H6TpxX6w7oM/s1600/Screen+Shot+2014-04-03+at+10.08.10+AM.png
 I know the data is in the field. Why can't I see it??


 On Thursday, 3 April 2014 09:37:41 UTC-4, Anthony wrote:

 Can we see some code (and maybe a screenshot of what you see)? The 
 default list:string widget requires an up-to-date web2py.js file.

 On Thursday, April 3, 2014 12:23:08 AM UTC-4, horridohobbyist wrote:

 I've added a 'list:string' field to my table, but when adding a new 
 record from admin (using the new record form), I can't figure out how to 
 enter the data. I don't understand what format it expects.

 I tried ['item1','item2']. I tried |'item1'|'item2'|. They both 
 don't work.



-- 
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: list:string

2014-04-03 Thread horridohobbyist
I upgraded to web2py 2.9.4 recently. Unless the upgrade was corrupted, I 
should be using the correct files. How can I tell if the web2py.js I have 
is correct or not? There's no identifying information.


On Thursday, 3 April 2014 11:09:07 UTC-4, Anthony wrote:

 And you're sure you have the version of web2py.js associated with the 
 version of web2py you are running, and that it is loaded on the page?

 On Thursday, April 3, 2014 10:17:58 AM UTC-4, horridohobbyist wrote:

 db.define_table('products',
 Field('thumbnail', 
 'upload',uploadfield='image_data',represent=lambda v, r: 
 IMG(_src=URL('download',args=v))),
 Field('image_data', 'blob',readable=False),
 Field('name',unique=True,represent=lambda v, r: 
 A(v,_href=URL('view',args=[db.products,r.id])) + 
 XML('br'+r.description)),
 Field('category',represent=lambda v, r: 
 DIV(v,_style='width:75px;word-wrap:break-word;')),
 Field('description','text',represent=lambda v, r: ''),
 Field('choices','text',readable=False),
 Field('shift','list:string',readable=False),

 I initialize the field with .update(shift=['colour','size'])

 When I retrieve the field, I indeed can access the list items. However, 
 in admin, I see this:


 https://lh4.googleusercontent.com/-EfRWKJ_pUWQ/Uz1spRS9D0I/A40/H6TpxX6w7oM/s1600/Screen+Shot+2014-04-03+at+10.08.10+AM.png
 I know the data is in the field. Why can't I see it??


 On Thursday, 3 April 2014 09:37:41 UTC-4, Anthony wrote:

 Can we see some code (and maybe a screenshot of what you see)? The 
 default list:string widget requires an up-to-date web2py.js file.

 On Thursday, April 3, 2014 12:23:08 AM UTC-4, horridohobbyist wrote:

 I've added a 'list:string' field to my table, but when adding a new 
 record from admin (using the new record form), I can't figure out how to 
 enter the data. I don't understand what format it expects.

 I tried ['item1','item2']. I tried |'item1'|'item2'|. They both 
 don't work.



-- 
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: list:string

2014-04-03 Thread Anthony
Unless you explicitly copied the new web2py.js file from /welcome/static/js 
to the /static/js folder of your existing app, then you don't have the 
updated version of web2py.js.

Anthony

On Thursday, April 3, 2014 11:47:15 AM UTC-4, horridohobbyist wrote:

 I upgraded to web2py 2.9.4 recently. Unless the upgrade was corrupted, I 
 should be using the correct files. How can I tell if the web2py.js I have 
 is correct or not? There's no identifying information.


 On Thursday, 3 April 2014 11:09:07 UTC-4, Anthony wrote:

 And you're sure you have the version of web2py.js associated with the 
 version of web2py you are running, and that it is loaded on the page?

 On Thursday, April 3, 2014 10:17:58 AM UTC-4, horridohobbyist wrote:

 db.define_table('products',
 Field('thumbnail', 
 'upload',uploadfield='image_data',represent=lambda v, r: 
 IMG(_src=URL('download',args=v))),
 Field('image_data', 'blob',readable=False),
 Field('name',unique=True,represent=lambda v, r: 
 A(v,_href=URL('view',args=[db.products,r.id])) + 
 XML('br'+r.description)),
 Field('category',represent=lambda v, r: 
 DIV(v,_style='width:75px;word-wrap:break-word;')),
 Field('description','text',represent=lambda v, r: ''),
 Field('choices','text',readable=False),
 Field('shift','list:string',readable=False),

 I initialize the field with .update(shift=['colour','size'])

 When I retrieve the field, I indeed can access the list items. However, 
 in admin, I see this:


 https://lh4.googleusercontent.com/-EfRWKJ_pUWQ/Uz1spRS9D0I/A40/H6TpxX6w7oM/s1600/Screen+Shot+2014-04-03+at+10.08.10+AM.png
 I know the data is in the field. Why can't I see it??


 On Thursday, 3 April 2014 09:37:41 UTC-4, Anthony wrote:

 Can we see some code (and maybe a screenshot of what you see)? The 
 default list:string widget requires an up-to-date web2py.js file.

 On Thursday, April 3, 2014 12:23:08 AM UTC-4, horridohobbyist wrote:

 I've added a 'list:string' field to my table, but when adding a new 
 record from admin (using the new record form), I can't figure out how to 
 enter the data. I don't understand what format it expects.

 I tried ['item1','item2']. I tried |'item1'|'item2'|. They both 
 don't work.



-- 
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: list:string

2014-04-03 Thread Anthony
While your at it, you may want to copy the appadmin.py controller and 
appadmin.html views from the new welcome app into your app.

Anthony

On Thursday, April 3, 2014 11:54:28 AM UTC-4, Anthony wrote:

 Unless you explicitly copied the new web2py.js file from 
 /welcome/static/js to the /static/js folder of your existing app, then you 
 don't have the updated version of web2py.js.

 Anthony

 On Thursday, April 3, 2014 11:47:15 AM UTC-4, horridohobbyist wrote:

 I upgraded to web2py 2.9.4 recently. Unless the upgrade was corrupted, I 
 should be using the correct files. How can I tell if the web2py.js I have 
 is correct or not? There's no identifying information.


 On Thursday, 3 April 2014 11:09:07 UTC-4, Anthony wrote:

 And you're sure you have the version of web2py.js associated with the 
 version of web2py you are running, and that it is loaded on the page?

 On Thursday, April 3, 2014 10:17:58 AM UTC-4, horridohobbyist wrote:

 db.define_table('products',
 Field('thumbnail', 
 'upload',uploadfield='image_data',represent=lambda v, r: 
 IMG(_src=URL('download',args=v))),
 Field('image_data', 'blob',readable=False),
 Field('name',unique=True,represent=lambda v, r: 
 A(v,_href=URL('view',args=[db.products,r.id])) + 
 XML('br'+r.description)),
 Field('category',represent=lambda v, r: 
 DIV(v,_style='width:75px;word-wrap:break-word;')),
 Field('description','text',represent=lambda v, r: ''),
 Field('choices','text',readable=False),
 Field('shift','list:string',readable=False),

 I initialize the field with .update(shift=['colour','size'])

 When I retrieve the field, I indeed can access the list items. However, 
 in admin, I see this:


 https://lh4.googleusercontent.com/-EfRWKJ_pUWQ/Uz1spRS9D0I/A40/H6TpxX6w7oM/s1600/Screen+Shot+2014-04-03+at+10.08.10+AM.png
 I know the data is in the field. Why can't I see it??


 On Thursday, 3 April 2014 09:37:41 UTC-4, Anthony wrote:

 Can we see some code (and maybe a screenshot of what you see)? The 
 default list:string widget requires an up-to-date web2py.js file.

 On Thursday, April 3, 2014 12:23:08 AM UTC-4, horridohobbyist wrote:

 I've added a 'list:string' field to my table, but when adding a new 
 record from admin (using the new record form), I can't figure out how to 
 enter the data. I don't understand what format it expects.

 I tried ['item1','item2']. I tried |'item1'|'item2'|. They both 
 don't work.



-- 
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: list:string

2014-04-03 Thread horridohobbyist
Done. However, it didn't fix the issue, although I now see a tiny clickable 
'+' and '-' right beside the input field for 'Shift:'. I have no idea what 
that means. Clicking on them does nothing.

It's also a little disturbing that I have to manually update my apps 
whenever I upgrade web2py. *This is a disincentive for me to upgrade. My 
motto is:  If it ain't broke, don't fix it.*


On Thursday, 3 April 2014 11:55:23 UTC-4, Anthony wrote:

 While your at it, you may want to copy the appadmin.py controller and 
 appadmin.html views from the new welcome app into your app.

 Anthony

 On Thursday, April 3, 2014 11:54:28 AM UTC-4, Anthony wrote:

 Unless you explicitly copied the new web2py.js file from 
 /welcome/static/js to the /static/js folder of your existing app, then you 
 don't have the updated version of web2py.js.

 Anthony

 On Thursday, April 3, 2014 11:47:15 AM UTC-4, horridohobbyist wrote:

 I upgraded to web2py 2.9.4 recently. Unless the upgrade was corrupted, I 
 should be using the correct files. How can I tell if the web2py.js I have 
 is correct or not? There's no identifying information.


 On Thursday, 3 April 2014 11:09:07 UTC-4, Anthony wrote:

 And you're sure you have the version of web2py.js associated with the 
 version of web2py you are running, and that it is loaded on the page?

 On Thursday, April 3, 2014 10:17:58 AM UTC-4, horridohobbyist wrote:

 db.define_table('products',
 Field('thumbnail', 
 'upload',uploadfield='image_data',represent=lambda v, r: 
 IMG(_src=URL('download',args=v))),
 Field('image_data', 'blob',readable=False),
 Field('name',unique=True,represent=lambda v, r: 
 A(v,_href=URL('view',args=[db.products,r.id])) + 
 XML('br'+r.description)),
 Field('category',represent=lambda v, r: 
 DIV(v,_style='width:75px;word-wrap:break-word;')),
 Field('description','text',represent=lambda v, r: ''),
 Field('choices','text',readable=False),
 Field('shift','list:string',readable=False),

 I initialize the field with .update(shift=['colour','size'])

 When I retrieve the field, I indeed can access the list items. 
 However, in admin, I see this:


 https://lh4.googleusercontent.com/-EfRWKJ_pUWQ/Uz1spRS9D0I/A40/H6TpxX6w7oM/s1600/Screen+Shot+2014-04-03+at+10.08.10+AM.png
 I know the data is in the field. Why can't I see it??


 On Thursday, 3 April 2014 09:37:41 UTC-4, Anthony wrote:

 Can we see some code (and maybe a screenshot of what you see)? The 
 default list:string widget requires an up-to-date web2py.js file.

 On Thursday, April 3, 2014 12:23:08 AM UTC-4, horridohobbyist wrote:

 I've added a 'list:string' field to my table, but when adding a new 
 record from admin (using the new record form), I can't figure out how 
 to 
 enter the data. I don't understand what format it expects.

 I tried ['item1','item2']. I tried |'item1'|'item2'|. They both 
 don't work.



-- 
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: list:string

2014-04-03 Thread Anthony
On Thursday, April 3, 2014 12:25:21 PM UTC-4, horridohobbyist wrote:

 Done. However, it didn't fix the issue, although I now see a tiny 
 clickable '+' and '-' right beside the input field for 'Shift:'. I have no 
 idea what that means. Clicking on them does nothing.


Check the JS console to see if any errors are produced. Clicking the + 
should add a new text box, and clicking the - should remove a box. If 
existing lists are not being populated, I suppose it's possible that the 
existing data are not stored correctly in the field. It might help to pack 
and attach a minimal app that reproduces the problem.
 

 It's also a little disturbing that I have to manually update my apps 
 whenever I upgrade web2py. *This is a disincentive for me to upgrade. My 
 motto is:  If it ain't broke, don't fix it.*


Well, in addition to bringing new features, upgrades typically include bug 
and security fixes, but if none of those matter to you, then of course you 
don't have to upgrade. Really, though, is it that much extra work to 
manually copy a couple of extra files? I think it's not done automatically 
because technically there does not have to be a fixed name or location for 
the app files (e.g., you could move or rename web2py.js or combine it with 
other JS files and minify). Upon upgrade, the only file you really have to 
worry about is web2py.js (i.e., because that works in conjunction with 
markup and CSS classes generated by the framework, things might break 
without the proper version). Old versions of appadmin.py and appadmin.html 
(and the generic views) should continue to work, though you may be missing 
new functionality or bug fixes if you don't upgrade those.

Anthony

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


[web2py] Re: list:string

2014-04-03 Thread Massimo Di Pierro
Usually you do not have to upgrade apps when you upgrade web2py. I can 
think of very few cases when we asked users to do it. In fact I think the 
only case in the last two years is when we asked to replace web2py.js in 
2.8. Moreover we never asked you to change the code. In the case in 
question, we only asked to replace one system file that you are not 
expected to edit anyway.

If I am missing something please let me know. 

Massimo


On Thursday, 3 April 2014 11:25:21 UTC-5, horridohobbyist wrote:

 Done. However, it didn't fix the issue, although I now see a tiny 
 clickable '+' and '-' right beside the input field for 'Shift:'. I have no 
 idea what that means. Clicking on them does nothing.

 It's also a little disturbing that I have to manually update my apps 
 whenever I upgrade web2py. *This is a disincentive for me to upgrade. My 
 motto is:  If it ain't broke, don't fix it.*


 On Thursday, 3 April 2014 11:55:23 UTC-4, Anthony wrote:

 While your at it, you may want to copy the appadmin.py controller and 
 appadmin.html views from the new welcome app into your app.

 Anthony

 On Thursday, April 3, 2014 11:54:28 AM UTC-4, Anthony wrote:

 Unless you explicitly copied the new web2py.js file from 
 /welcome/static/js to the /static/js folder of your existing app, then you 
 don't have the updated version of web2py.js.

 Anthony

 On Thursday, April 3, 2014 11:47:15 AM UTC-4, horridohobbyist wrote:

 I upgraded to web2py 2.9.4 recently. Unless the upgrade was corrupted, 
 I should be using the correct files. How can I tell if the web2py.js I 
 have 
 is correct or not? There's no identifying information.


 On Thursday, 3 April 2014 11:09:07 UTC-4, Anthony wrote:

 And you're sure you have the version of web2py.js associated with the 
 version of web2py you are running, and that it is loaded on the page?

 On Thursday, April 3, 2014 10:17:58 AM UTC-4, horridohobbyist wrote:

 db.define_table('products',
 Field('thumbnail', 
 'upload',uploadfield='image_data',represent=lambda v, r: 
 IMG(_src=URL('download',args=v))),
 Field('image_data', 'blob',readable=False),
 Field('name',unique=True,represent=lambda v, r: 
 A(v,_href=URL('view',args=[db.products,r.id])) + 
 XML('br'+r.description)),
 Field('category',represent=lambda v, r: 
 DIV(v,_style='width:75px;word-wrap:break-word;')),
 Field('description','text',represent=lambda v, r: ''),
 Field('choices','text',readable=False),
 Field('shift','list:string',readable=False),

 I initialize the field with .update(shift=['colour','size'])

 When I retrieve the field, I indeed can access the list items. 
 However, in admin, I see this:


 https://lh4.googleusercontent.com/-EfRWKJ_pUWQ/Uz1spRS9D0I/A40/H6TpxX6w7oM/s1600/Screen+Shot+2014-04-03+at+10.08.10+AM.png
 I know the data is in the field. Why can't I see it??


 On Thursday, 3 April 2014 09:37:41 UTC-4, Anthony wrote:

 Can we see some code (and maybe a screenshot of what you see)? The 
 default list:string widget requires an up-to-date web2py.js file.

 On Thursday, April 3, 2014 12:23:08 AM UTC-4, horridohobbyist wrote:

 I've added a 'list:string' field to my table, but when adding a new 
 record from admin (using the new record form), I can't figure out how 
 to 
 enter the data. I don't understand what format it expects.

 I tried ['item1','item2']. I tried |'item1'|'item2'|. They 
 both don't work.



-- 
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: list:string

2014-04-03 Thread horridohobbyist
What and where is the JS console??


On Thursday, 3 April 2014 14:11:02 UTC-4, Anthony wrote:

 On Thursday, April 3, 2014 12:25:21 PM UTC-4, horridohobbyist wrote:

 Done. However, it didn't fix the issue, although I now see a tiny 
 clickable '+' and '-' right beside the input field for 'Shift:'. I have no 
 idea what that means. Clicking on them does nothing.


 Check the JS console to see if any errors are produced. Clicking the + 
 should add a new text box, and clicking the - should remove a box. If 
 existing lists are not being populated, I suppose it's possible that the 
 existing data are not stored correctly in the field. It might help to pack 
 and attach a minimal app that reproduces the problem.
  

 It's also a little disturbing that I have to manually update my apps 
 whenever I upgrade web2py. *This is a disincentive for me to upgrade. My 
 motto is:  If it ain't broke, don't fix it.*


 Well, in addition to bringing new features, upgrades typically include bug 
 and security fixes, but if none of those matter to you, then of course you 
 don't have to upgrade. Really, though, is it that much extra work to 
 manually copy a couple of extra files? I think it's not done automatically 
 because technically there does not have to be a fixed name or location for 
 the app files (e.g., you could move or rename web2py.js or combine it with 
 other JS files and minify). Upon upgrade, the only file you really have to 
 worry about is web2py.js (i.e., because that works in conjunction with 
 markup and CSS classes generated by the framework, things might break 
 without the proper version). Old versions of appadmin.py and appadmin.html 
 (and the generic views) should continue to work, though you may be missing 
 new functionality or bug fixes if you don't upgrade those.

 Anthony


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


[web2py] Re: list:string

2014-04-03 Thread horridohobbyist
For some reason, it's suddenly working with the newer web2py.js. Weird.


On Thursday, 3 April 2014 14:11:02 UTC-4, Anthony wrote:

 On Thursday, April 3, 2014 12:25:21 PM UTC-4, horridohobbyist wrote:

 Done. However, it didn't fix the issue, although I now see a tiny 
 clickable '+' and '-' right beside the input field for 'Shift:'. I have no 
 idea what that means. Clicking on them does nothing.


 Check the JS console to see if any errors are produced. Clicking the + 
 should add a new text box, and clicking the - should remove a box. If 
 existing lists are not being populated, I suppose it's possible that the 
 existing data are not stored correctly in the field. It might help to pack 
 and attach a minimal app that reproduces the problem.
  

 It's also a little disturbing that I have to manually update my apps 
 whenever I upgrade web2py. *This is a disincentive for me to upgrade. My 
 motto is:  If it ain't broke, don't fix it.*


 Well, in addition to bringing new features, upgrades typically include bug 
 and security fixes, but if none of those matter to you, then of course you 
 don't have to upgrade. Really, though, is it that much extra work to 
 manually copy a couple of extra files? I think it's not done automatically 
 because technically there does not have to be a fixed name or location for 
 the app files (e.g., you could move or rename web2py.js or combine it with 
 other JS files and minify). Upon upgrade, the only file you really have to 
 worry about is web2py.js (i.e., because that works in conjunction with 
 markup and CSS classes generated by the framework, things might break 
 without the proper version). Old versions of appadmin.py and appadmin.html 
 (and the generic views) should continue to work, though you may be missing 
 new functionality or bug fixes if you don't upgrade those.

 Anthony


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


[web2py] Re: list:string

2014-04-03 Thread Dave S
On Thursday, April 3, 2014 11:57:27 AM UTC-7, horridohobbyist wrote:

 What and where is the JS console??


Browser-dependent, isn't it?  In FF 18.something, it's Tools-Web 
Developer-Web Console, and then pick the proper tab in the subwindow that 
starts up.  Chrome has different menu layout.

/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: list:string

2014-04-03 Thread Anthony
Perhaps your browser had the older JS file cached.

On Thursday, April 3, 2014 3:43:08 PM UTC-4, horridohobbyist wrote:

 For some reason, it's suddenly working with the newer web2py.js. Weird.


 On Thursday, 3 April 2014 14:11:02 UTC-4, Anthony wrote:

 On Thursday, April 3, 2014 12:25:21 PM UTC-4, horridohobbyist wrote:

 Done. However, it didn't fix the issue, although I now see a tiny 
 clickable '+' and '-' right beside the input field for 'Shift:'. I have no 
 idea what that means. Clicking on them does nothing.


 Check the JS console to see if any errors are produced. Clicking the + 
 should add a new text box, and clicking the - should remove a box. If 
 existing lists are not being populated, I suppose it's possible that the 
 existing data are not stored correctly in the field. It might help to pack 
 and attach a minimal app that reproduces the problem.
  

 It's also a little disturbing that I have to manually update my apps 
 whenever I upgrade web2py. *This is a disincentive for me to upgrade. 
 My motto is:  If it ain't broke, don't fix it.*


 Well, in addition to bringing new features, upgrades typically include 
 bug and security fixes, but if none of those matter to you, then of course 
 you don't have to upgrade. Really, though, is it that much extra work to 
 manually copy a couple of extra files? I think it's not done automatically 
 because technically there does not have to be a fixed name or location for 
 the app files (e.g., you could move or rename web2py.js or combine it with 
 other JS files and minify). Upon upgrade, the only file you really have to 
 worry about is web2py.js (i.e., because that works in conjunction with 
 markup and CSS classes generated by the framework, things might break 
 without the proper version). Old versions of appadmin.py and appadmin.html 
 (and the generic views) should continue to work, though you may be missing 
 new functionality or bug fixes if you don't upgrade those.

 Anthony



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


[web2py] Re: list:string type field output format

2014-03-22 Thread Pedro Pisandelli
Hi Antony! This made too many things clear to me.
I got the point about represent function, but i guess the 
DIV(db...represent(...)) must be at a view file... and what about appadmin?

Trying to get the fields value through appadmin, I got the error *sequence 
item 0: expected string, long found*
My question is: Is there any thing I must do in models to not get this 
error in appadmin?

Cheers


Em quarta-feira, 17 de abril de 2013 00h33min13s UTC-3, Anthony escreveu:

 In the database, the value is stored as a string with the individual 
 values separated by pipe characters (i.e., |a|b|). However, when you 
 select from the DB using the DAL, the value gets converted to a list. 
 list:string fields get a default represent attribute that displays the 
 values as a comma-separated list in grids, etc., but you have to do it 
 yourself or explicitly call the represent function in other contexts:

 DIV(', '.join(row.test))

 or

 DIV(db.test.test.represent(row.test))

 Anthony

 On Tuesday, April 16, 2013 10:37:20 PM UTC-4, 黄祥 wrote:

 hi folks,

 is it possible to change list:string type field output format?

 e.g.
 *in grid output : a, b*
 *in shell output :  |a|b|*
  print db(db.test.test.contains('b')).select()
 test.id,test.test
 1,|a|b|
 *in view using query output : ab*
 {{for i, row in enumerate(rows):}}
 {{=DIV(row.test)}}
 {{pass}}
 *in view using query output : ['a', 'b']*
 {{for i, row in enumerate(rows):}}
 {{=DIV(str(row.test))}}
 {{pass}}

 i want to have the output format for list:string type field in view : *a, 
 b* or *a; b* instead of ab. did anyone know how to produce the output 
 like that in web2py?

 thank you very much in advance



-- 
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: List:string display missing the + and - since about 2.7

2013-12-17 Thread Mark Kirkwood
I think this is due to me forgetting to update static/js/web2py.js from the 
2.7 or 2.8 welcome app, but will confirm.

-- 
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/groups/opt_out.


[web2py] Re: List:string display missing the + and - since about 2.7

2013-12-17 Thread Mark Kirkwood
Confirmed, the excellent quality of the Changelog included with the src is 
much appreciated. I must remember to read it *before* posting questions...

-- 
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/groups/opt_out.


[web2py] Re: list:string repeats same error message in SQLFORM grid

2013-09-03 Thread step
This issue is now fixed in trunk 
2013-09-01 
https://github.com/web2py/web2py/commit/085b4a0d15b173d84d92e2ed2b6db30923d2f643
Thanks Massimo

On Wednesday, August 7, 2013 12:57:14 PM UTC+2, step wrote:

 Thank yOU for looking into this. Will you post a follow-up to this thread 
 or should I monitor the google code issue list re this issue?

 On Monday, August 5, 2013 12:38:50 AM UTC+2, Massimo Di Pierro wrote:

 Your first solution should also have worked. I will look into it.

 On Sunday, 4 August 2013 16:40:57 UTC-5, step wrote:

 Answering my own question, with jQuery I found a way to display just a 
 single error message div for a list:string type field. I added this code to 
 the view:
 {{if grid.update_form or grid.create_form:}}
 {{#hide all list:string error divs but the first one, and move it 
 before the data}}
 script type=text/javascript
 $(document).ready(function() {
 var f=['email','phone']; //list:strings
 for (var i=0; if.length; i++) {
 $('#person_'+f[i]+' .error_wrapper').each(function(i) {
 if (i==0) $(this).siblings().first().before($(this));
 else this.style.display='none';
 });
 }
 });
 /script
 {{pass}}
 {{=grid}}



 On Saturday, August 3, 2013 12:52:16 AM UTC+2, step wrote:

 is it possible to display just one error message of a list:string input 
 right after the last input control, using SQLFORM.grid?

 With SQLFORM,grid create/update form, when a list:string field with 
 validators has errors it should be possible to hide the error display on 
 all list inputs but the last one. At least that's how I interpret the 
 current ListWidget code in sqlform.py
 nvalue = value or ['']
 items = [LI(INPUT(_id=_id, _class=_class, _name=_name,
   value=v, hideerror=k  len(nvalue) - 1,
   requires=requires),
 **attributes) for (k, v) in enumerate(nvalue)]
 so hideerror=True for all input items but the last one. Effectively, 
 this should display a single error message after the last string of the 
 list. How nice, but it doesn't seem to work, and the form repeats the same 
 error message under each string of the list - 100 times if the list:string 
 comprises 100 elements.
 I'm not sure where the hideerror attribute gets reset in the chain. I 
 check its value in function _translate, and it's always false, even when I 
 add this code after the above code in the ListWidget - for the sake of 
 investigating this issue.
 for i in items:
 for e in i.elements:
 e.attributes['hideerror'] = True
 hideerror is still == False for all self.components in _translate() 
 while I'd expect it to be True for components that correspond to my 
 list:string inputs.
 def _traverse(self, status, hideerror=False):
 # zip zip...

 # for input, textarea, select, option
 # deal with 'value' and 'validation'

 name = self['_name']
 print name, self['hideerror'] # this always prints False




-- 

--- 
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/groups/opt_out.


[web2py] Re: list:string repeats same error message in SQLFORM grid

2013-08-07 Thread step
Thank yOU for looking into this. Will you post a follow-up to this thread 
or should I monitor the google code issue list re this issue?

On Monday, August 5, 2013 12:38:50 AM UTC+2, Massimo Di Pierro wrote:

 Your first solution should also have worked. I will look into it.

 On Sunday, 4 August 2013 16:40:57 UTC-5, step wrote:

 Answering my own question, with jQuery I found a way to display just a 
 single error message div for a list:string type field. I added this code to 
 the view:
 {{if grid.update_form or grid.create_form:}}
 {{#hide all list:string error divs but the first one, and move it 
 before the data}}
 script type=text/javascript
 $(document).ready(function() {
 var f=['email','phone']; //list:strings
 for (var i=0; if.length; i++) {
 $('#person_'+f[i]+' .error_wrapper').each(function(i) {
 if (i==0) $(this).siblings().first().before($(this));
 else this.style.display='none';
 });
 }
 });
 /script
 {{pass}}
 {{=grid}}



 On Saturday, August 3, 2013 12:52:16 AM UTC+2, step wrote:

 is it possible to display just one error message of a list:string input 
 right after the last input control, using SQLFORM.grid?

 With SQLFORM,grid create/update form, when a list:string field with 
 validators has errors it should be possible to hide the error display on 
 all list inputs but the last one. At least that's how I interpret the 
 current ListWidget code in sqlform.py
 nvalue = value or ['']
 items = [LI(INPUT(_id=_id, _class=_class, _name=_name,
   value=v, hideerror=k  len(nvalue) - 1,
   requires=requires),
 **attributes) for (k, v) in enumerate(nvalue)]
 so hideerror=True for all input items but the last one. Effectively, 
 this should display a single error message after the last string of the 
 list. How nice, but it doesn't seem to work, and the form repeats the same 
 error message under each string of the list - 100 times if the list:string 
 comprises 100 elements.
 I'm not sure where the hideerror attribute gets reset in the chain. I 
 check its value in function _translate, and it's always false, even when I 
 add this code after the above code in the ListWidget - for the sake of 
 investigating this issue.
 for i in items:
 for e in i.elements:
 e.attributes['hideerror'] = True
 hideerror is still == False for all self.components in _translate() 
 while I'd expect it to be True for components that correspond to my 
 list:string inputs.
 def _traverse(self, status, hideerror=False):
 # zip zip...

 # for input, textarea, select, option
 # deal with 'value' and 'validation'

 name = self['_name']
 print name, self['hideerror'] # this always prints False




-- 

--- 
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/groups/opt_out.




[web2py] Re: list:string repeats same error message in SQLFORM grid

2013-08-04 Thread step
Answering my own question, with jQuery I found a way to display just a 
single error message div for a list:string type field. I added this code to 
the view:
{{if grid.update_form or grid.create_form:}}
{{#hide all list:string error divs but the first one, and move it 
before the data}}
script type=text/javascript
$(document).ready(function() {
var f=['email','phone']; //list:strings
for (var i=0; if.length; i++) {
$('#person_'+f[i]+' .error_wrapper').each(function(i) {
if (i==0) $(this).siblings().first().before($(this));
else this.style.display='none';
});
}
});
/script
{{pass}}
{{=grid}}



On Saturday, August 3, 2013 12:52:16 AM UTC+2, step wrote:

 is it possible to display just one error message of a list:string input 
 right after the last input control, using SQLFORM.grid?

 With SQLFORM,grid create/update form, when a list:string field with 
 validators has errors it should be possible to hide the error display on 
 all list inputs but the last one. At least that's how I interpret the 
 current ListWidget code in sqlform.py
 nvalue = value or ['']
 items = [LI(INPUT(_id=_id, _class=_class, _name=_name,
   value=v, hideerror=k  len(nvalue) - 1,
   requires=requires),
 **attributes) for (k, v) in enumerate(nvalue)]
 so hideerror=True for all input items but the last one. Effectively, this 
 should display a single error message after the last string of the list. 
 How nice, but it doesn't seem to work, and the form repeats the same error 
 message under each string of the list - 100 times if the list:string 
 comprises 100 elements.
 I'm not sure where the hideerror attribute gets reset in the chain. I 
 check its value in function _translate, and it's always false, even when I 
 add this code after the above code in the ListWidget - for the sake of 
 investigating this issue.
 for i in items:
 for e in i.elements:
 e.attributes['hideerror'] = True
 hideerror is still == False for all self.components in _translate() while 
 I'd expect it to be True for components that correspond to my list:string 
 inputs.
 def _traverse(self, status, hideerror=False):
 # zip zip...

 # for input, textarea, select, option
 # deal with 'value' and 'validation'

 name = self['_name']
 print name, self['hideerror'] # this always prints False




-- 

--- 
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/groups/opt_out.




[web2py] Re: list:string repeats same error message in SQLFORM grid

2013-08-04 Thread Massimo Di Pierro
Your first solution should also have worked. I will look into it.

On Sunday, 4 August 2013 16:40:57 UTC-5, step wrote:

 Answering my own question, with jQuery I found a way to display just a 
 single error message div for a list:string type field. I added this code to 
 the view:
 {{if grid.update_form or grid.create_form:}}
 {{#hide all list:string error divs but the first one, and move it 
 before the data}}
 script type=text/javascript
 $(document).ready(function() {
 var f=['email','phone']; //list:strings
 for (var i=0; if.length; i++) {
 $('#person_'+f[i]+' .error_wrapper').each(function(i) {
 if (i==0) $(this).siblings().first().before($(this));
 else this.style.display='none';
 });
 }
 });
 /script
 {{pass}}
 {{=grid}}



 On Saturday, August 3, 2013 12:52:16 AM UTC+2, step wrote:

 is it possible to display just one error message of a list:string input 
 right after the last input control, using SQLFORM.grid?

 With SQLFORM,grid create/update form, when a list:string field with 
 validators has errors it should be possible to hide the error display on 
 all list inputs but the last one. At least that's how I interpret the 
 current ListWidget code in sqlform.py
 nvalue = value or ['']
 items = [LI(INPUT(_id=_id, _class=_class, _name=_name,
   value=v, hideerror=k  len(nvalue) - 1,
   requires=requires),
 **attributes) for (k, v) in enumerate(nvalue)]
 so hideerror=True for all input items but the last one. Effectively, this 
 should display a single error message after the last string of the list. 
 How nice, but it doesn't seem to work, and the form repeats the same error 
 message under each string of the list - 100 times if the list:string 
 comprises 100 elements.
 I'm not sure where the hideerror attribute gets reset in the chain. I 
 check its value in function _translate, and it's always false, even when I 
 add this code after the above code in the ListWidget - for the sake of 
 investigating this issue.
 for i in items:
 for e in i.elements:
 e.attributes['hideerror'] = True
 hideerror is still == False for all self.components in _translate() while 
 I'd expect it to be True for components that correspond to my list:string 
 inputs.
 def _traverse(self, status, hideerror=False):
 # zip zip...

 # for input, textarea, select, option
 # deal with 'value' and 'validation'

 name = self['_name']
 print name, self['hideerror'] # this always prints False




-- 

--- 
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/groups/opt_out.




[web2py] Re: list:string field in smartgrid? ver: 2.6.0-development+timestamp.2013.08.01.08.22.32

2013-08-03 Thread Niphlod
are you using an application based on a scaffolding pre 2.6.0 and upgraded 
web2py to 2.6.0?

If yes, please overwrite your app's web2py.js with the new 
welcome/static/js/web2py.js 

On Saturday, August 3, 2013 8:41:09 PM UTC+2, Adi wrote:


 I have a list:string field without any represent definition, and when 
 open record for editing in smartgrid, the field is represented as string 
 (one line). I remember in the past seeing a button with the plus sign on 
 the right side, and ability to add multiple values into a field. Should I 
 specify some widget in order to get the button and functionality? 

 simplified table definition:

 db.define_table('product',
 Field('videos', 'list:string'),
 )


 Thanks.




-- 

--- 
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/groups/opt_out.




[web2py] Re: list:string field in smartgrid? ver: 2.6.0-development+timestamp.2013.08.01.08.22.32

2013-08-03 Thread Adi
The problem is that I created a new application minutes before I'll post, 
just to be sure it's not some other code interfering... and even though 
welcome/static/js has newest files, what got copied into a new (uniquely 
named) application was not the same. All files dates were from January 
2013, and sizes were less. 

Not sure if there is a problem with New simple application functionality 
to bring the latest files into scaffolding, or it's only a setup on my 
computer. 

Regardless to all this, the problem is solved + and - are there. 

Thanks again Simone!!!






On Saturday, August 3, 2013 2:47:11 PM UTC-4, Niphlod wrote:

 are you using an application based on a scaffolding pre 2.6.0 and upgraded 
 web2py to 2.6.0?

 If yes, please overwrite your app's web2py.js with the new 
 welcome/static/js/web2py.js 

 On Saturday, August 3, 2013 8:41:09 PM UTC+2, Adi wrote:


 I have a list:string field without any represent definition, and when 
 open record for editing in smartgrid, the field is represented as string 
 (one line). I remember in the past seeing a button with the plus sign on 
 the right side, and ability to add multiple values into a field. Should I 
 specify some widget in order to get the button and functionality? 

 simplified table definition:

 db.define_table('product',
 Field('videos', 'list:string'),
 )


 Thanks.




-- 

--- 
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/groups/opt_out.




[web2py] Re: list:string field in smartgrid? ver: 2.6.0-development+timestamp.2013.08.01.08.22.32

2013-08-03 Thread Niphlod
this happens if when you upgrade you don't have a NEWINSTALL file 
available. In fact, the scaffolding app (welcome) gets packed to a 
welcome.w2p file and that archive is used as the base for any other simple 
application. If the NEWINSTALL file is found, upon executing web2py the 
existing welcome application gets packed to welcome.w2p, so all new 
applications carry around the latest code.


On Saturday, August 3, 2013 9:04:53 PM UTC+2, Adi wrote:

 The problem is that I created a new application minutes before I'll post, 
 just to be sure it's not some other code interfering... and even though 
 welcome/static/js has newest files, what got copied into a new (uniquely 
 named) application was not the same. All files dates were from January 
 2013, and sizes were less. 

 Not sure if there is a problem with New simple application functionality 
 to bring the latest files into scaffolding, or it's only a setup on my 
 computer. 

 Regardless to all this, the problem is solved + and - are there. 

 Thanks again Simone!!!






 On Saturday, August 3, 2013 2:47:11 PM UTC-4, Niphlod wrote:

 are you using an application based on a scaffolding pre 2.6.0 and 
 upgraded web2py to 2.6.0?

 If yes, please overwrite your app's web2py.js with the new 
 welcome/static/js/web2py.js 

 On Saturday, August 3, 2013 8:41:09 PM UTC+2, Adi wrote:


 I have a list:string field without any represent definition, and when 
 open record for editing in smartgrid, the field is represented as string 
 (one line). I remember in the past seeing a button with the plus sign on 
 the right side, and ability to add multiple values into a field. Should I 
 specify some widget in order to get the button and functionality? 

 simplified table definition:

 db.define_table('product',
 Field('videos', 'list:string'),
 )


 Thanks.




-- 

--- 
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/groups/opt_out.




[web2py] Re: list:string field in smartgrid? ver: 2.6.0-development+timestamp.2013.08.01.08.22.32

2013-08-03 Thread Adi
if you need me to do some additional testing in regards to creating new 
application, please let me know. I use github to constantly synch with the 
latest trunk, so not sure if that could somehow interfere... 


On Saturday, August 3, 2013 2:47:11 PM UTC-4, Niphlod wrote:

 are you using an application based on a scaffolding pre 2.6.0 and upgraded 
 web2py to 2.6.0?

 If yes, please overwrite your app's web2py.js with the new 
 welcome/static/js/web2py.js 

 On Saturday, August 3, 2013 8:41:09 PM UTC+2, Adi wrote:


 I have a list:string field without any represent definition, and when 
 open record for editing in smartgrid, the field is represented as string 
 (one line). I remember in the past seeing a button with the plus sign on 
 the right side, and ability to add multiple values into a field. Should I 
 specify some widget in order to get the button and functionality? 

 simplified table definition:

 db.define_table('product',
 Field('videos', 'list:string'),
 )


 Thanks.




-- 

--- 
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/groups/opt_out.




[web2py] Re: list:string field in smartgrid? ver: 2.6.0-development+timestamp.2013.08.01.08.22.32

2013-08-03 Thread Niphlod
actually is a rather easy piece of code... in gluon/widget.py 
create_welcome_w2p() is called.
this is defined in gluon/fileutils.py

if not os.path.exists('welcome.w2p') or os.path.exists('NEWINSTALL'):
try:
w2p_pack('welcome.w2p', 'applications/welcome')
os.unlink('NEWINSTALL')
logging.info(New installation: created welcome.w2p file)
except:
logging.error(New installation error: unable to create 
welcome.w2p file)

So, to make sure that your apps are always derived by the welcome app, 
you have either to:
- delete the welcome.w2p file
- create the NEWINSTALL file

and then start web2py to recreate the scaffolding archive that gets used.
Unfortunately when you sync a remote with a local dir if you removed a file 
in the local dir it doesn't get recreated unless you checkout it manually.

-- 

--- 
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/groups/opt_out.




[web2py] Re: list:string field in smartgrid? ver: 2.6.0-development+timestamp.2013.08.01.08.22.32

2013-08-03 Thread Niphlod
by sync I meant with git or hg. 
It may be not handy for rolling developers (meaning that they use the 
google code or the github repo to keep their web2py updated) but for 
developers using tagged releases or in production the procedure indeed 
works fine because if you download the archive the NEWINSTALL file is 
present, so when you overwrite your prod web2py folder with the archive, 
the new welcome is created without problems.

-- 

--- 
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/groups/opt_out.




[web2py] Re: list:string type field output format

2013-04-18 Thread Niphlod
check again: there's no way mine and Anthony's last snippets generates a 
single A holding two addresses

On Thursday, April 18, 2013 4:04:26 AM UTC+2, 黄祥 wrote:

 thank you so much for your hints niphlod and anthony, i've tried both of 
 your hints, but the result is not what i'm expected (no error occured)
 {{=SPAN(T('Email : '), XML(', '.join([A(email, _title=T('Send Email'), 
 _target='_blank',
_href='mailto:%s' % email).xml() for email in row.email])), 
 _id='email_%s' % i)}}

 {{=SPAN(T('Email : '), CAT([A(email, _title=T('Send Email'), 
 _target='_blank',
_href='mailto:%s' % email) for email in row.email]), _id='email_%s' 
 % i)}}

 the result in inspect elements :
 a href=mailto:a...@a.com javascript:, b...@b.com javascript: 
 target=_blank title=Send Emaila...@a.com javascript:, 
 b...@b.comjavascript:
 /a

 my expectation is
 a href=mailto:a...@a.com javascript: target=_blank title=Send 
 Emaila...@a.com javascript:/a
 , 
 a href=mailto:b...@b.com javascript: target=_blank title=Send 
 Emailb...@b.com javascript:/a

 any idea how to accomplish it?
 thank you so much in advance


-- 

--- 
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/groups/opt_out.




[web2py] Re: list:string type field output format

2013-04-18 Thread 黄祥
yes, you are right, my mistake, the problem is on the data itself, because 
i input it via populate.
thank you so much for your hints and suggestions

-- 

--- 
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/groups/opt_out.




[web2py] Re: list:string type field output format

2013-04-17 Thread 黄祥
thank you so much for your hint, anthony both of it is work well.

{{extend 'layout.html'}}

{{for i, row in enumerate(rows):}}
{{=DIV(', '.join(row.test))}}
{{=DIV(db.test.test.represent(row.test))}}
{{pass}}

On Wednesday, April 17, 2013 10:33:13 AM UTC+7, Anthony wrote:

 In the database, the value is stored as a string with the individual 
 values separated by pipe characters (i.e., |a|b|). However, when you 
 select from the DB using the DAL, the value gets converted to a list. 
 list:string fields get a default represent attribute that displays the 
 values as a comma-separated list in grids, etc., but you have to do it 
 yourself or explicitly call the represent function in other contexts:

 DIV(', '.join(row.test))

 or

 DIV(db.test.test.represent(row.test))

 Anthony

 On Tuesday, April 16, 2013 10:37:20 PM UTC-4, 黄祥 wrote:

 hi folks,

 is it possible to change list:string type field output format?

 e.g.
 *in grid output : a, b*
 *in shell output :  |a|b|*
  print db(db.test.test.contains('b')).select()
 test.id,test.test
 1,|a|b|
 *in view using query output : ab*
 {{for i, row in enumerate(rows):}}
 {{=DIV(row.test)}}
 {{pass}}
 *in view using query output : ['a', 'b']*
 {{for i, row in enumerate(rows):}}
 {{=DIV(str(row.test))}}
 {{pass}}

 i want to have the output format for list:string type field in view : *a, 
 b* or *a; b* instead of ab. did anyone know how to produce the output 
 like that in web2py?

 thank you very much in advance



-- 

--- 
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/groups/opt_out.




[web2py] Re: list:string type field output format

2013-04-17 Thread 黄祥
it seems can not make it work for the link, i've tried both, but same result
{{=SPAN(T('Email : '), A(', '.join(row.email), _title=T('Send Email'), 
_target='_blank', _href='mailto:%s' % row.email), _id='email_%s' % i)}}
{{=SPAN(T('Email : '), A(db.branch.email.represent(row.email), 
_title=T('Send Email'), _target='_blank', _href='mailto:%s' % row.email), 
_id='email_%s' % i)}}

yet the output is correct but when i clicked, it will produce :
['a...@a.com', 'b...@b.com']
in the email from field value

is it possible to make the list value separated in link output format? so 
that when i hover to a...@a.com will send email to a...@a.com, vice versa, not 
send to both email
thank you so much

-- 

--- 
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/groups/opt_out.




[web2py] Re: list:string type field output format

2013-04-17 Thread Niphlod
then you want to have 2 separate A, one for each email!

On Wednesday, April 17, 2013 9:41:02 AM UTC+2, 黄祥 wrote:

 it seems can not make it work for the link, i've tried both, but same 
 result
 {{=SPAN(T('Email : '), A(', '.join(row.email), _title=T('Send Email'), 
 _target='_blank', _href='mailto:%s' % row.email), _id='email_%s' % i)}}
 {{=SPAN(T('Email : '), A(db.branch.email.represent(row.email), 
 _title=T('Send Email'), _target='_blank', _href='mailto:%s' % row.email), 
 _id='email_%s' % i)}}

 yet the output is correct but when i clicked, it will produce :
 ['a...@a.com javascript:', 'b...@b.com javascript:']
 in the email from field value

 is it possible to make the list value separated in link output format? so 
 that when i hover to a...@a.com javascript: will send email to 
 a...@a.com javascript:, vice versa, not send to both email
 thank you so much


-- 

--- 
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/groups/opt_out.




[web2py] Re: list:string type field output format

2013-04-17 Thread Anthony
You have to make a comma-separated list of A()'s instead of inserting all 
the email addresses in a single mailto:

', '.join([A(email, _title=T('Send Email'), _target='_blank',
 _href='mailto:%s' % email) for email in row.email])

Anthony

On Wednesday, April 17, 2013 3:41:02 AM UTC-4, 黄祥 wrote:

 it seems can not make it work for the link, i've tried both, but same 
 result
 {{=SPAN(T('Email : '), A(', '.join(row.email), _title=T('Send Email'), 
 _target='_blank', _href='mailto:%s' % row.email), _id='email_%s' % i)}}
 {{=SPAN(T('Email : '), A(db.branch.email.represent(row.email), 
 _title=T('Send Email'), _target='_blank', _href='mailto:%s' % row.email), 
 _id='email_%s' % i)}}

 yet the output is correct but when i clicked, it will produce :
 ['a...@a.com javascript:', 'b...@b.com javascript:']
 in the email from field value

 is it possible to make the list value separated in link output format? so 
 that when i hover to a...@a.com javascript: will send email to 
 a...@a.com javascript:, vice versa, not send to both email
 thank you so much


-- 

--- 
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/groups/opt_out.




[web2py] Re: list:string type field output format

2013-04-17 Thread 黄祥
thank you so much for your hint anthony, it seems must be string type, when 
i try to use your hints it return an error 
*not work*
{{=SPAN(T('Email : '), ', '.join([A(email, _title=T('Send Email'), 
_target='_blank',
 _href='mailto:%s' % email) for email in row.email]), 
_id='email_%s' % i)}}

Traceback

1.
2.
3.
4.
5.
6.

Traceback (most recent call last):
  File /host/Download/web2py/gluon/restricted.py, line 212, in restricted
exec ccode in environment
  File 
/host/Download/web2py/applications/stifix/views/default/contact_us.html, line 
92, in module
TypeError: sequence item 0: expected string, A found


*work but the output result not expected (no link A href)*
{{=SPAN(T('Email : '), ', '.join([str(email) for email in row.email]), 
_id='email_%s' % i)}}

any idea how to accomplished it?
thank you very much in advance

-- 

--- 
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/groups/opt_out.




[web2py] Re: list:string type field output format

2013-04-17 Thread Niphlod
yep, html helpers aren't properly strings, so they can't be joined with a 
simple ','.join()
However, you can do it with the CAT (from conCAT)

try 

SPAN(T('Email'), CAT([A(email) for a in emails]))

On Wednesday, April 17, 2013 11:12:26 PM UTC+2, 黄祥 wrote:

 thank you so much for your hint anthony, it seems must be string type, 
 when i try to use your hints it return an error 
 *not work*
 {{=SPAN(T('Email : '), ', '.join([A(email, _title=T('Send Email'), 
 _target='_blank',
  _href='mailto:%s' % email) for email in row.email]), 
 _id='email_%s' % i)}}

 Traceback

 1.
 2.
 3.
 4.
 5.
 6.

 Traceback (most recent call last):
   File /host/Download/web2py/gluon/restricted.py, line 212, in restricted
 exec ccode in environment
   File 
 /host/Download/web2py/applications/stifix/views/default/contact_us.html, 
 line 92, in module
 TypeError: sequence item 0: expected string, A found


 *work but the output result not expected (no link A href)*
 {{=SPAN(T('Email : '), ', '.join([str(email) for email in row.email]), 
 _id='email_%s' % i)}}

 any idea how to accomplished it?
 thank you very much in advance


-- 

--- 
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/groups/opt_out.




[web2py] Re: list:string type field output format

2013-04-17 Thread Anthony
Sorry, wasn't thinking -- you could do:

{{=SPAN(T('Email : '), XML(', '.join([A(email, _title=T('Send Email'),_target
='_blank',
   _href='mailto:%s' % email).xml() for email in row.email])), _id=
'email_%s' % i)}}

Anthony

On Wednesday, April 17, 2013 5:12:26 PM UTC-4, 黄祥 wrote:

 thank you so much for your hint anthony, it seems must be string type, 
 when i try to use your hints it return an error 
 *not work*
 {{=SPAN(T('Email : '), ', '.join([A(email, _title=T('Send Email'), 
 _target='_blank',
  _href='mailto:%s' % email) for email in row.email]), 
 _id='email_%s' % i)}}

 Traceback

 1.
 2.
 3.
 4.
 5.
 6.

 Traceback (most recent call last):
   File /host/Download/web2py/gluon/restricted.py, line 212, in restricted
 exec ccode in environment
   File 
 /host/Download/web2py/applications/stifix/views/default/contact_us.html, 
 line 92, in module
 TypeError: sequence item 0: expected string, A found


 *work but the output result not expected (no link A href)*
 {{=SPAN(T('Email : '), ', '.join([str(email) for email in row.email]), 
 _id='email_%s' % i)}}

 any idea how to accomplished it?
 thank you very much in advance


-- 

--- 
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/groups/opt_out.




[web2py] Re: list:string type field output format

2013-04-17 Thread 黄祥
thank you so much for your hints niphlod and anthony, i've tried both of 
your hints, but the result is not what i'm expected (no error occured)
{{=SPAN(T('Email : '), XML(', '.join([A(email, _title=T('Send Email'), 
_target='_blank',
   _href='mailto:%s' % email).xml() for email in row.email])), 
_id='email_%s' % i)}}

{{=SPAN(T('Email : '), CAT([A(email, _title=T('Send Email'), 
_target='_blank',
   _href='mailto:%s' % email) for email in row.email]), _id='email_%s' 
% i)}}

the result in inspect elements :
a href=mailto:a...@a.com, b...@b.com target=_blank title=Send 
Emaila...@a.com, b...@b.com/a

my expectation is
a href=mailto:a...@a.com; target=_blank title=Send Emaila...@a.com/a
, 
a href=mailto:b...@b.com; target=_blank title=Send Emailb...@b.com/a

any idea how to accomplish it?
thank you so much in advance

-- 

--- 
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/groups/opt_out.




[web2py] Re: list:string type field output format

2013-04-16 Thread Anthony
In the database, the value is stored as a string with the individual values 
separated by pipe characters (i.e., |a|b|). However, when you select from 
the DB using the DAL, the value gets converted to a list. list:string 
fields get a default represent attribute that displays the values as a 
comma-separated list in grids, etc., but you have to do it yourself or 
explicitly call the represent function in other contexts:

DIV(', '.join(row.test))

or

DIV(db.test.test.represent(row.test))

Anthony

On Tuesday, April 16, 2013 10:37:20 PM UTC-4, 黄祥 wrote:

 hi folks,

 is it possible to change list:string type field output format?

 e.g.
 *in grid output : a, b*
 *in shell output :  |a|b|*
  print db(db.test.test.contains('b')).select()
 test.id,test.test
 1,|a|b|
 *in view using query output : ab*
 {{for i, row in enumerate(rows):}}
 {{=DIV(row.test)}}
 {{pass}}
 *in view using query output : ['a', 'b']*
 {{for i, row in enumerate(rows):}}
 {{=DIV(str(row.test))}}
 {{pass}}

 i want to have the output format for list:string type field in view : *a, 
 b* or *a; b* instead of ab. did anyone know how to produce the output 
 like that in web2py?

 thank you very much in advance


-- 

--- 
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/groups/opt_out.




[web2py] Re: list:string type field is empty value on edit page

2013-04-09 Thread 黄祥
yeah, my mistake. 
thanks for correct me

-- 

--- 
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/groups/opt_out.




[web2py] Re: list:string type field is empty value on edit page

2013-04-08 Thread Massimo Di Pierro
db.define_table('gender',
Field('gender', 'list:string'),
format='%(gender)s')

db.gender.gender.requires=IS_IN_SET(['Male', 'Female'])

should be

db.define_table('gender',
Field('gender', 'list:string'),
format='%(gender)s')
db.gender.gender.requires=IS_IN_SET(['Male', 'Female'],mutliple=True)

if you have a list of strings, you must allows multiple options. It does 
not make much sense in the Male/Female case (or perhaps it does, not sure).

On Monday, 8 April 2013 00:00:28 UTC-5, 黄祥 wrote:

 i've already start testing using the simple table (start from scratch) but 
 got the same result. here is my conclusion, please correct me if i'm wrong :
 - if you combine list:string field with IS_IN_SET validator, in form edit 
 you will receive blank value in drop down, not the existing value that 
 stored in database. 
 - if you want to use IS_IN_SET validator and in form edit will show the 
 existing value that store in database, please use string type field in your 
 define table.

 *e.g. in form edit receive blank value in drop down field, not the 
 existing value that stored in database*
 *db.py*
 db.define_table('gender',
 Field('gender', 'list:string'),
 format='%(gender)s')

 db.gender.gender.requires=IS_IN_SET(['Male', 'Female'])

 *default.py*
 def gender():
 grid=SQLFORM.grid(db.gender, user_signature=False)
 return locals()

 *default/gender.html*
 {{extend 'layout.html'}}

 {{=grid}}

 *e.g. in form edit will show the existing value that store in database*
 *db.py*
 db.define_table('gender',
 Field('gender'),
 format='%(gender)s')

 db.gender.gender.requires=IS_IN_SET(['Male', 'Female'])

 *default.py*
 def gender():
 grid=SQLFORM.grid(db.gender, user_signature=False)
 return locals()

 *default/gender.html*
 {{extend 'layout.html'}}

 {{=grid}}


-- 

--- 
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/groups/opt_out.




[web2py] Re: list:string type field is empty value on edit page

2013-04-07 Thread 黄祥
i've already start testing using the simple table (start from scratch) but 
got the same result. here is my conclusion, please correct me if i'm wrong :
- if you combine list:string field with IS_IN_SET validator, in form edit 
you will receive blank value in drop down, not the existing value that 
stored in database. 
- if you want to use IS_IN_SET validator and in form edit will show the 
existing value that store in database, please use string type field in your 
define table.

*e.g. in form edit receive blank value in drop down field, not the existing 
value that stored in database*
*db.py*
db.define_table('gender',
Field('gender', 'list:string'),
format='%(gender)s')

db.gender.gender.requires=IS_IN_SET(['Male', 'Female'])

*default.py*
def gender():
grid=SQLFORM.grid(db.gender, user_signature=False)
return locals()

*default/gender.html*
{{extend 'layout.html'}}

{{=grid}}

*e.g. in form edit will show the existing value that store in database*
*db.py*
db.define_table('gender',
Field('gender'),
format='%(gender)s')

db.gender.gender.requires=IS_IN_SET(['Male', 'Female'])

*default.py*
def gender():
grid=SQLFORM.grid(db.gender, user_signature=False)
return locals()

*default/gender.html*
{{extend 'layout.html'}}

{{=grid}}

-- 

--- 
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/groups/opt_out.




[web2py] Re: list:string type field is empty value on edit page

2013-04-05 Thread Massimo Di Pierro
No it is not. Something in the code must be resetting it.

On Thursday, 4 April 2013 22:13:25 UTC-5, 黄祥 wrote:

 hi,

 is it normal for list:string type field is empty when on editing page?

 e.g.
 db.define_table('contact',
 *Field('salutation'),*
 Field('first_name'),
 Field('last_name'),
 *Field('gender', 'list:string'),*
 Field('birthday', 'date'),
 Field('job_title'),
 Field('address', 'text'),
 Field('zip'),
 Field('city'),
 Field('country'),
 Field('phone'),
 Field('fax'),
 Field('email'),
 *Field('account', 'reference account'),*
 format='%(first_name)s %(last_name)s')

 *db.contact.salutation.requires=IS_IN_SET(['Mr.', 'Mrs.', 'Ms.'])*
 db.contact.first_name.requires=IS_NOT_EMPTY()
 db.contact.last_name.requires=IS_NOT_EMPTY()
 *db.contact.gender.requires=IS_IN_SET(['Male', 'Female'])*
 db.contact.job_title.requires=IS_NOT_EMPTY()
 db.contact.address.requires=IS_NOT_EMPTY()
 db.contact.zip.requires=IS_MATCH('^\d{5,5}$',
  error_message='not a zip code')
 db.contact.city.requires=IS_NOT_EMPTY()
 db.contact.country.requires=IS_NOT_EMPTY()
 db.contact.phone.requires=IS_NOT_EMPTY()
 db.contact.email.requires=[IS_EMAIL(), 
IS_NOT_IN_DB(db, 'contact.email')]
 *db.contact.account.requires=IS_IN_DB(db, db.account.id, 
 '%(account_name)s')*

 i make 3 different field type (bold) that contain drop down in the form 
 view. why the value is always empty for the list:string type when i'm on 
 the editing page? is it possible for not empty for list:string type in 
 editing page?
 any idea or explaination about this?

 thank you so much before


-- 

--- 
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/groups/opt_out.




[web2py] Re: list:string type field is empty value on edit page

2013-04-05 Thread 黄祥
is it related to the other field constructor, like required, label, etc? 
and for controller i'm using grid.

*default.py*
@auth.requires_login()
def contact():
grid=SQLFORM.grid(db.contact, user_signature=False)
return locals()

*db_wizard.py*
# create table : contact
db.define_table('contact',
Field('salutation'),
Field('first_name'),
Field('last_name'),
Field('gender', 'list:string'),
Field('birthday', 'date'),
Field('job_title'),
Field('address', 'text'),
Field('zip'),
Field('city'),
Field('country'),
Field('phone'),
Field('fax'),
Field('email'),
Field('account', 'reference account'),
format='%(first_name)s %(last_name)s')

# create index : contact
db.executesql('CREATE INDEX IF NOT EXISTS idx_contact ON contact (id, 
first_name, last_name);')

# enable_record_versioning : contact
db.contact._enable_record_versioning()

*db_wizard_label.py*
# contact
db.contact.salutation.label=T('Salutation')
db.contact.first_name.label=T('First Name')
db.contact.last_name.label=T('Last Name')
db.contact.gender.label=T('Gender')
db.contact.birthday.label=T('Birthday')
db.contact.job_title.label=T('Job Title')
db.contact.address.label=T('Address')
db.contact.zip.label=T('Zip')
db.contact.city.label=T('City')
db.contact.country.label=T('Country')
db.contact.phone.label=T('Phone')
db.contact.fax.label=T('Fax')
db.contact.email.label=T('Email')
db.contact.account.label=T('Account')

*db_wizard_required.py*
# contact
db.contact.salutation.required=True
db.contact.first_name.required=True
db.contact.last_name.required=True
db.contact.gender.required=True
db.contact.job_title.required=True
db.contact.address.required=True
db.contact.zip.required=True
db.contact.city.required=True
db.contact.country.required=True
db.contact.phone.required=True
db.contact.email.required=True
db.contact.account.required=True
*
db_wizard_requires.py*
# contact
db.contact.salutation.requires=IS_IN_SET(['Mr.', 'Mrs.', 'Ms.'])
db.contact.first_name.requires=IS_NOT_EMPTY()
db.contact.last_name.requires=IS_NOT_EMPTY()
db.contact.gender.requires=IS_IN_SET(['Male', 'Female'])
db.contact.job_title.requires=IS_NOT_EMPTY()
db.contact.address.requires=IS_NOT_EMPTY()
db.contact.zip.requires=IS_MATCH('^\d{5,5}$',
 error_message='not a zip code')
db.contact.city.requires=IS_NOT_EMPTY()
db.contact.country.requires=IS_NOT_EMPTY()
db.contact.phone.requires=IS_NOT_EMPTY()
db.contact.email.requires=[IS_EMAIL(), 
   IS_NOT_IN_DB(db, 'contact.email')]
db.contact.account.requires=IS_IN_DB(db, db.account.id, '%(account_name)s')

On Friday, April 5, 2013 5:25:55 PM UTC-4, Massimo Di Pierro wrote:

 No it is not. Something in the code must be resetting it.

 On Thursday, 4 April 2013 22:13:25 UTC-5, 黄祥 wrote:

 hi,

 is it normal for list:string type field is empty when on editing page?

 e.g.
 db.define_table('contact',
 *Field('salutation'),*
 Field('first_name'),
 Field('last_name'),
 *Field('gender', 'list:string'),*
 Field('birthday', 'date'),
 Field('job_title'),
 Field('address', 'text'),
 Field('zip'),
 Field('city'),
 Field('country'),
 Field('phone'),
 Field('fax'),
 Field('email'),
 *Field('account', 'reference account'),*
 format='%(first_name)s %(last_name)s')

 *db.contact.salutation.requires=IS_IN_SET(['Mr.', 'Mrs.', 'Ms.'])*
 db.contact.first_name.requires=IS_NOT_EMPTY()
 db.contact.last_name.requires=IS_NOT_EMPTY()
 *db.contact.gender.requires=IS_IN_SET(['Male', 'Female'])*
 db.contact.job_title.requires=IS_NOT_EMPTY()
 db.contact.address.requires=IS_NOT_EMPTY()
 db.contact.zip.requires=IS_MATCH('^\d{5,5}$',
  error_message='not a zip code')
 db.contact.city.requires=IS_NOT_EMPTY()
 db.contact.country.requires=IS_NOT_EMPTY()
 db.contact.phone.requires=IS_NOT_EMPTY()
 db.contact.email.requires=[IS_EMAIL(), 
IS_NOT_IN_DB(db, 'contact.email')]
 *db.contact.account.requires=IS_IN_DB(db, db.account.id, 
 '%(account_name)s')*

 i make 3 different field type (bold) that contain drop down in the form 
 view. why the value is always empty for the list:string type when i'm on 
 the editing page? is it possible for not empty for list:string type in 
 editing page?
 any idea or explaination about this?

 thank you so much before



-- 

--- 
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/groups/opt_out.




[web2py] Re: list:string crud form entry -- what's the latest?

2012-07-09 Thread Anthony
Well, by default, the list:string field type does get a special Javascript 
widget, though the functionality could probably be improved. After you 
enter an item in the initial text box, hit enter, and a new box should 
appear below it, and so on. There is no way to remove a box once created.

Regardless of the widget, you can apply an email validator to each item in 
a list:string input using IS_LIST_OF(IS_EMAIL()). The only caveat is that 
validation errors will not automatically be displayed on the form, so you 
have to explicitly check for a validation error on that field and implement 
a custom error display.

Anthony

On Monday, July 9, 2012 10:15:34 AM UTC-4, weheh wrote:

 This has been an oft-disucssed topic. Just search for list:string crud 
 But having just experienced the pain myself, and not easily locating the 
 status of this issue, I felt compelled to ask for myself: 

 Shouldn't list:string have a default interactive (jQuery OK) widget that 
 is an expandable/collapsible list of user-input text data that works with 
 crud? Validators like IS_EMAIL() would then have to iterate on list:string. 
 This would be handy for storing entities with multiple emails, for example.

 Seems like a gap in web2py's form-input armor and a pretty useful 
 capability, to boot. So what's the latest?



[web2py] Re: list:string crud form entry -- what's the latest?

2012-07-09 Thread weheh
Yah, I tried the Enter key, and a lot of other combinations of control 
and/or shift + enter as well as an abracadabra (on Chrome (didn't try any 
other browser)), but none of them got the list:string to represent except 
as a single string field. No additional string fields magically appeared, 
as hoped for.

I think a stronger widget is needed for this very useful construct. I use 
list:string in lots of places and having a handy way of editing them is 
essential. Obviously, not being able to delete a string after entry makes 
any list:string editor DOA. (Needs an (x) button at end of string field 
that, if clicked, prompts user to confirm delete  then deletes field from 
form and db entry when submitted.

I will submit a formal enhancement request, if it hasn't already been done.

Thanks for the tip on IS_LIST_OF. Must print out  read doc again one of 
these days.


On Monday, July 9, 2012 11:11:53 PM UTC+8, Anthony wrote:

 Well, by default, the list:string field type does get a special Javascript 
 widget, though the functionality could probably be improved. After you 
 enter an item in the initial text box, hit enter, and a new box should 
 appear below it, and so on. There is no way to remove a box once created.

 Regardless of the widget, you can apply an email validator to each item in 
 a list:string input using IS_LIST_OF(IS_EMAIL()). The only caveat is that 
 validation errors will not automatically be displayed on the form, so you 
 have to explicitly check for a validation error on that field and implement 
 a custom error display.

 Anthony

 On Monday, July 9, 2012 10:15:34 AM UTC-4, weheh wrote:

 This has been an oft-disucssed topic. Just search for list:string crud 
 But having just experienced the pain myself, and not easily locating the 
 status of this issue, I felt compelled to ask for myself: 

 Shouldn't list:string have a default interactive (jQuery OK) widget that 
 is an expandable/collapsible list of user-input text data that works with 
 crud? Validators like IS_EMAIL() would then have to iterate on list:string. 
 This would be handy for storing entities with multiple emails, for example.

 Seems like a gap in web2py's form-input armor and a pretty useful 
 capability, to boot. So what's the latest?



[web2py] Re: list:string crud form entry -- what's the latest?

2012-07-09 Thread Anthony


 Yah, I tried the Enter key, and a lot of other combinations of control 
 and/or shift + enter as well as an abracadabra (on Chrome (didn't try any 
 other browser)), but none of them got the list:string to represent except 
 as a single string field. No additional string fields magically appeared, 
 as hoped for.


Hmm, it works for me. What does your code look like?
 

 I think a stronger widget is needed for this very useful construct. I use 
 list:string in lots of places and having a handy way of editing them is 
 essential.


+1
 

 Obviously, not being able to delete a string after entry makes any 
 list:string editor DOA.


Agreed, though I think if you simply delete the content of the text box, no 
value is submitted for it.
 

 I will submit a formal enhancement request, if it hasn't already been done.


It probably makes sense to find a nice existing JS widget and adopt it.

Anthony


[web2py] Re: list:string and Update form

2011-06-13 Thread Oscar
No problem I already solved the issue.

Regards,

Oscar.


On 12 jun, 01:33, Oscar oscar.m...@gmail.com wrote:
 Hi,

 I have a model using a list:string field called type.

 Validation for type field:
 IS_IN_SET({'finished':T('Finished'),'service':T('Service')},
 zero=T(-- Choose Type Of The Product --))),

 So, when I create an update form using SQLFORM it shows the form fine
 but, the dropdown thats belong to type doesn't have the right value or
 selection, it just shows -- Choose Type Of The Product --

 form = SQLFORM(db[main_data.settings.table_name_products],
                    record = product_id,
                    fields = product_fields,
                    submit_button = submit_button,
                    formstyle = 'divs')

 I need that type field get the right value from the string stored in
 the DB to get it showed in the dropdown. How I can do this?

 Regards,

 Oscar.


[web2py] Re: list:string and Update form

2011-06-13 Thread Oscar
I used the following:

record = db(db[main_data.settings.table_name_products].id ==
product_id).select()
form.element(_id = op_products_type)[0] = record[0].type

Regards,

Oscar.


On 12 jun, 01:33, Oscar oscar.m...@gmail.com wrote:
 Hi,

 I have a model using a list:string field called type.

 Validation for type field:
 IS_IN_SET({'finished':T('Finished'),'service':T('Service')},
 zero=T(-- Choose Type Of The Product --))),

 So, when I create an update form using SQLFORM it shows the form fine
 but, the dropdown thats belong to type doesn't have the right value or
 selection, it just shows -- Choose Type Of The Product --

 form = SQLFORM(db[main_data.settings.table_name_products],
                    record = product_id,
                    fields = product_fields,
                    submit_button = submit_button,
                    formstyle = 'divs')

 I need that type field get the right value from the string stored in
 the DB to get it showed in the dropdown. How I can do this?

 Regards,

 Oscar.


Re: [web2py] Re: list:string thoughts

2010-11-23 Thread Bruno Rocha
HI, I am taking advantage of this thread to solve a doubt about
list:string,
How can I get the values from list:string field rendered as a Python 'list'
?

Is there a ready way in DAL, or I need to use .split() and .join() ?

look:

 row = db(db.doacao.user_id==23).select()[0]
 row
Row {'user_id': 23, 'exibir': True, 'twitter': None, 'update_record':
function lambda at 0x930ae64, 'projeto': None, 'animais': '|12|20|',
'valores': '|21.5|45.3|', 'obs': None, 'sorteio': '5796', 'total': 20.0,
'data': datetime.datetime(2010, 11, 23, 10, 7, 48), 'id': 58,
'delete_record': function lambda at 0x930ae2c}
 row.animais
'|12|20|'
 row.valores
'|21.5|45.3|'

At this point the 'list:string' fields returns 'str' , I can split this by
'|' and create a new list, but may be DAL has a function for doing that?






2010/10/25 mdipierro mdipie...@cs.depaul.edu

 h. that is possible. Will look into it.

 On Oct 25, 3:59 pm, yamandu yamandu.co...@gmail.com wrote:
  It seems that this widget does not work when there is more than one
  list:string field in a page.
 
  On Oct 25, 2:01 am, mdipierro mdipie...@cs.depaul.edu wrote:
 
   The list:string is not an alternative to using a tag table and
   tag_link many-to-many (an example of which is provided by
   plugin_tagging).
 
   Yet you should not have the problem you experience. With recent
   versions of web2py, Field('keywords', 'list:string') should be
   rendered by a new widget that takes one keyword per line and adds new
   lines when yo press enter. You should not be using '|' to separate
   keywords. If you do all keywords will be interpreted as one long
   keyword containing the '|'s.
 
   Massimo
 
   On Oct 24, 10:35 pm, rick ricon...@gmail.com wrote:
 
I'm getting frustrated with the list:string field type.
 
I store products, each product has keywords that describe the
product.
db.define_table('products',
   Field('keywords', 'list:string'))
I don't know what the keywords will be, so I can't use IS_IN_SET()
 
It seems to stores the keywords fine, as long as (I'm using Crud)
I separate the keywords like this: green|blue|red
 
But when I make this call
rows = db(db.products.keywords.contains(keyword)).select()
I don't get all the products back that I should! In fact, it seems
that I need to do an update on the product (again using Crud,
and any sort of update) before the product's keywords will be
picked up.
 
Is this a problem with using Crud?
In all honesty, I'd be more comfortable not using list:string, and
having a separate table keywords that linked (many-to-one)
to the products table, but I really don't know how I would even
begin to do that in web2py..
 
Thanks for reading!
- rick
 
 




-- 

Bruno Rocha
http://about.me/rochacbruno/bio


[web2py] Re: list:string thoughts

2010-11-23 Thread mdipierro
No it does not. This is what I get:

 db.define_table('name',Field('value','list:string'))
 db.name.insert(value=['hello','world'])
1
 db.name(1).value
['hello', 'world']
 for row in db(db.name).select(): print row
Row {'update_record': function lambda at 0x1698f70, 'value':
['hello', 'world'], 'id': 1, 'delete_record': function lambda at
0x16a0030}

I think you inserted '|21.5|45.3|' instead of ['21.5','45.3'] and you
get back what you insert.


On Nov 23, 10:08 am, Bruno Rocha rochacbr...@gmail.com wrote:
 HI, I am taking advantage of this thread to solve a doubt about
 list:string,
 How can I get the values from list:string field rendered as a Python 'list'
 ?

 Is there a ready way in DAL, or I need to use .split() and .join() ?

 look:

  row = db(db.doacao.user_id==23).select()[0]
  row

 Row {'user_id': 23, 'exibir': True, 'twitter': None, 'update_record':
 function lambda at 0x930ae64, 'projeto': None, 'animais': '|12|20|',
 'valores': '|21.5|45.3|', 'obs': None, 'sorteio': '5796', 'total': 20.0,
 'data': datetime.datetime(2010, 11, 23, 10, 7, 48), 'id': 58,
 'delete_record': function lambda at 0x930ae2c} row.animais
 '|12|20|'
  row.valores

 '|21.5|45.3|'

 At this point the 'list:string' fields returns 'str' , I can split this by
 '|' and create a new list, but may be DAL has a function for doing that?

 2010/10/25 mdipierro mdipie...@cs.depaul.edu



  h. that is possible. Will look into it.

  On Oct 25, 3:59 pm, yamandu yamandu.co...@gmail.com wrote:
   It seems that this widget does not work when there is more than one
   list:string field in a page.

   On Oct 25, 2:01 am, mdipierro mdipie...@cs.depaul.edu wrote:

The list:string is not an alternative to using a tag table and
tag_link many-to-many (an example of which is provided by
plugin_tagging).

Yet you should not have the problem you experience. With recent
versions of web2py, Field('keywords', 'list:string') should be
rendered by a new widget that takes one keyword per line and adds new
lines when yo press enter. You should not be using '|' to separate
keywords. If you do all keywords will be interpreted as one long
keyword containing the '|'s.

Massimo

On Oct 24, 10:35 pm, rick ricon...@gmail.com wrote:

 I'm getting frustrated with the list:string field type.

 I store products, each product has keywords that describe the
 product.
 db.define_table('products',
    Field('keywords', 'list:string'))
 I don't know what the keywords will be, so I can't use IS_IN_SET()

 It seems to stores the keywords fine, as long as (I'm using Crud)
 I separate the keywords like this: green|blue|red

 But when I make this call
 rows = db(db.products.keywords.contains(keyword)).select()
 I don't get all the products back that I should! In fact, it seems
 that I need to do an update on the product (again using Crud,
 and any sort of update) before the product's keywords will be
 picked up.

 Is this a problem with using Crud?
 In all honesty, I'd be more comfortable not using list:string, and
 having a separate table keywords that linked (many-to-one)
 to the products table, but I really don't know how I would even
 begin to do that in web2py..

 Thanks for reading!
 - rick

 --

 Bruno Rochahttp://about.me/rochacbruno/bio


Re: [web2py] Re: list:string thoughts

2010-11-23 Thread Bruno Rocha
This is what I have:

order = []
for product_id, qty, val in session.cart:
order.append(( product_id, qty, val ))

store.define_table('doacao',
  Field('user_id',db.auth_user,requires=IS_IN_DB(db,
db.auth_user.id)),
  Field('animais','list:string'),
  Field('valores','list:string'),
  Field('data','datetime',default=request.now),
  )

assuming order = [(12,1,21.4),(15,1,45.3)]

doacao = dict(
 user_id=auth.user_id,
 animais=[ord[0] for ord in order],
 valores=[ord[2] for ord in order],
 data=datetime.today()+timedelta(hours=4)
 )

session.id_doacao = db.doacao.insert(**doacao)

I got animais with '|12|15|' and valores = '|21.4|45.3|'






2010/11/23 mdipierro mdipie...@cs.depaul.edu

 No it does not. This is what I get:

  db.define_table('name',Field('value','list:string'))
  db.name.insert(value=['hello','world'])
 1
  db.name(1).value
 ['hello', 'world']
  for row in db(db.name).select(): print row
 Row {'update_record': function lambda at 0x1698f70, 'value':
 ['hello', 'world'], 'id': 1, 'delete_record': function lambda at
 0x16a0030}

 I think you inserted '|21.5|45.3|' instead of ['21.5','45.3'] and you
 get back what you insert.


 On Nov 23, 10:08 am, Bruno Rocha rochacbr...@gmail.com wrote:
  HI, I am taking advantage of this thread to solve a doubt about
  list:string,
  How can I get the values from list:string field rendered as a Python
 'list'
  ?
 
  Is there a ready way in DAL, or I need to use .split() and .join() ?
 
  look:
 
   row = db(db.doacao.user_id==23).select()[0]
   row
 
  Row {'user_id': 23, 'exibir': True, 'twitter': None, 'update_record':
  function lambda at 0x930ae64, 'projeto': None, 'animais': '|12|20|',
  'valores': '|21.5|45.3|', 'obs': None, 'sorteio': '5796', 'total': 20.0,
  'data': datetime.datetime(2010, 11, 23, 10, 7, 48), 'id': 58,
  'delete_record': function lambda at 0x930ae2c} row.animais
  '|12|20|'
   row.valores
 
  '|21.5|45.3|'
 
  At this point the 'list:string' fields returns 'str' , I can split this
 by
  '|' and create a new list, but may be DAL has a function for doing that?
 
  2010/10/25 mdipierro mdipie...@cs.depaul.edu
 
 
 
   h. that is possible. Will look into it.
 
   On Oct 25, 3:59 pm, yamandu yamandu.co...@gmail.com wrote:
It seems that this widget does not work when there is more than one
list:string field in a page.
 
On Oct 25, 2:01 am, mdipierro mdipie...@cs.depaul.edu wrote:
 
 The list:string is not an alternative to using a tag table and
 tag_link many-to-many (an example of which is provided by
 plugin_tagging).
 
 Yet you should not have the problem you experience. With recent
 versions of web2py, Field('keywords', 'list:string') should be
 rendered by a new widget that takes one keyword per line and adds
 new
 lines when yo press enter. You should not be using '|' to separate
 keywords. If you do all keywords will be interpreted as one long
 keyword containing the '|'s.
 
 Massimo
 
 On Oct 24, 10:35 pm, rick ricon...@gmail.com wrote:
 
  I'm getting frustrated with the list:string field type.
 
  I store products, each product has keywords that describe the
  product.
  db.define_table('products',
 Field('keywords', 'list:string'))
  I don't know what the keywords will be, so I can't use
 IS_IN_SET()
 
  It seems to stores the keywords fine, as long as (I'm using Crud)
  I separate the keywords like this: green|blue|red
 
  But when I make this call
  rows = db(db.products.keywords.contains(keyword)).select()
  I don't get all the products back that I should! In fact, it
 seems
  that I need to do an update on the product (again using Crud,
  and any sort of update) before the product's keywords will be
  picked up.
 
  Is this a problem with using Crud?
  In all honesty, I'd be more comfortable not using list:string,
 and
  having a separate table keywords that linked (many-to-one)
  to the products table, but I really don't know how I would even
  begin to do that in web2py..
 
  Thanks for reading!
  - rick
 
  --
 
  Bruno Rochahttp://about.me/rochacbruno/bio




-- 

Bruno Rocha
http://about.me/rochacbruno/bio


[web2py] Re: list:string thoughts

2010-11-23 Thread mdipierro
This is what I get from shell:

 db.define_table('doacao',
...Field('animais','list:string'),
...Field('valores','list:string'))
 order = [(12,1,21.4),(15,1,45.3)]
 doacao = dict(
...  animais=[ord[0] for ord in order],
...  valores=[ord[2] for ord in order], )
 i=db.doacao.insert(**doacao)
 for row in db(db.doacao).select(): print row
...
Row {'update_record': function lambda at 0x1698e70, 'animais':
['12', '15'], 'id': 1, 'delete_record': function lambda at
0x1698eb0, 'valores': ['21.4', '45.3']}

what do you do to get '|12|15|' and '|21.4|45.3|'? I cannot reproduce
them.

On Nov 23, 10:30 am, Bruno Rocha rochacbr...@gmail.com wrote:
 This is what I have:

 order = []
 for product_id, qty, val in session.cart:
     order.append(( product_id, qty, val ))

 store.define_table('doacao',
                   Field('user_id',db.auth_user,requires=IS_IN_DB(db,
 db.auth_user.id)),
                   Field('animais','list:string'),
                   Field('valores','list:string'),
                   Field('data','datetime',default=request.now),
                   )

 assuming order = [(12,1,21.4),(15,1,45.3)]

 doacao = dict(
              user_id=auth.user_id,
              animais=[ord[0] for ord in order],
              valores=[ord[2] for ord in order],
              data=datetime.today()+timedelta(hours=4)
              )

 session.id_doacao = db.doacao.insert(**doacao)

 I got animais with '|12|15|' and valores = '|21.4|45.3|'

 2010/11/23 mdipierro mdipie...@cs.depaul.edu



  No it does not. This is what I get:

   db.define_table('name',Field('value','list:string'))
   db.name.insert(value=['hello','world'])
  1
   db.name(1).value
  ['hello', 'world']
   for row in db(db.name).select(): print row
  Row {'update_record': function lambda at 0x1698f70, 'value':
  ['hello', 'world'], 'id': 1, 'delete_record': function lambda at
  0x16a0030}

  I think you inserted '|21.5|45.3|' instead of ['21.5','45.3'] and you
  get back what you insert.

  On Nov 23, 10:08 am, Bruno Rocha rochacbr...@gmail.com wrote:
   HI, I am taking advantage of this thread to solve a doubt about
   list:string,
   How can I get the values from list:string field rendered as a Python
  'list'
   ?

   Is there a ready way in DAL, or I need to use .split() and .join() ?

   look:

row = db(db.doacao.user_id==23).select()[0]
row

   Row {'user_id': 23, 'exibir': True, 'twitter': None, 'update_record':
   function lambda at 0x930ae64, 'projeto': None, 'animais': '|12|20|',
   'valores': '|21.5|45.3|', 'obs': None, 'sorteio': '5796', 'total': 20.0,
   'data': datetime.datetime(2010, 11, 23, 10, 7, 48), 'id': 58,
   'delete_record': function lambda at 0x930ae2c} row.animais
   '|12|20|'
row.valores

   '|21.5|45.3|'

   At this point the 'list:string' fields returns 'str' , I can split this
  by
   '|' and create a new list, but may be DAL has a function for doing that?

   2010/10/25 mdipierro mdipie...@cs.depaul.edu

h. that is possible. Will look into it.

On Oct 25, 3:59 pm, yamandu yamandu.co...@gmail.com wrote:
 It seems that this widget does not work when there is more than one
 list:string field in a page.

 On Oct 25, 2:01 am, mdipierro mdipie...@cs.depaul.edu wrote:

  The list:string is not an alternative to using a tag table and
  tag_link many-to-many (an example of which is provided by
  plugin_tagging).

  Yet you should not have the problem you experience. With recent
  versions of web2py, Field('keywords', 'list:string') should be
  rendered by a new widget that takes one keyword per line and adds
  new
  lines when yo press enter. You should not be using '|' to separate
  keywords. If you do all keywords will be interpreted as one long
  keyword containing the '|'s.

  Massimo

  On Oct 24, 10:35 pm, rick ricon...@gmail.com wrote:

   I'm getting frustrated with the list:string field type.

   I store products, each product has keywords that describe the
   product.
   db.define_table('products',
      Field('keywords', 'list:string'))
   I don't know what the keywords will be, so I can't use
  IS_IN_SET()

   It seems to stores the keywords fine, as long as (I'm using Crud)
   I separate the keywords like this: green|blue|red

   But when I make this call
   rows = db(db.products.keywords.contains(keyword)).select()
   I don't get all the products back that I should! In fact, it
  seems
   that I need to do an update on the product (again using Crud,
   and any sort of update) before the product's keywords will be
   picked up.

   Is this a problem with using Crud?
   In all honesty, I'd be more comfortable not using list:string,
  and
   having a separate table keywords that linked (many-to-one)
   to the products table, but I really don't know how I would even
   begin to do that in web2py..

   Thanks for reading!
   - rick


Re: [web2py] Re: list:string thoughts

2010-11-23 Thread Bruno Rocha
I deleted my database, redefined the tables and now it works.

I found the problem.

First defined

Field('valores')

After some values inserted, and some deletions, I changed to

Field('valores','list:string')

But this still renders pure strings '|x|x|'

changing fields from 'string' to 'list:string' does not works.

2010/11/23 mdipierro mdipie...@cs.depaul.edu

 This is what I get from shell:

  db.define_table('doacao',
 ...Field('animais','list:string'),
 ...Field('valores','list:string'))
  order = [(12,1,21.4),(15,1,45.3)]
  doacao = dict(
 ...  animais=[ord[0] for ord in order],
 ...  valores=[ord[2] for ord in order], )
  i=db.doacao.insert(**doacao)
  for row in db(db.doacao).select(): print row
 ...
 Row {'update_record': function lambda at 0x1698e70, 'animais':
 ['12', '15'], 'id': 1, 'delete_record': function lambda at
 0x1698eb0, 'valores': ['21.4', '45.3']}

 what do you do to get '|12|15|' and '|21.4|45.3|'? I cannot reproduce
 them.

 On Nov 23, 10:30 am, Bruno Rocha rochacbr...@gmail.com wrote:
  This is what I have:
 
  order = []
  for product_id, qty, val in session.cart:
  order.append(( product_id, qty, val ))
 
  store.define_table('doacao',
Field('user_id',db.auth_user,requires=IS_IN_DB(db,
  db.auth_user.id)),
Field('animais','list:string'),
Field('valores','list:string'),
Field('data','datetime',default=request.now),
)
 
  assuming order = [(12,1,21.4),(15,1,45.3)]
 
  doacao = dict(
   user_id=auth.user_id,
   animais=[ord[0] for ord in order],
   valores=[ord[2] for ord in order],
   data=datetime.today()+timedelta(hours=4)
   )
 
  session.id_doacao = db.doacao.insert(**doacao)
 
  I got animais with '|12|15|' and valores = '|21.4|45.3|'
 
  2010/11/23 mdipierro mdipie...@cs.depaul.edu
 
 
 
   No it does not. This is what I get:
 
db.define_table('name',Field('value','list:string'))
db.name.insert(value=['hello','world'])
   1
db.name(1).value
   ['hello', 'world']
for row in db(db.name).select(): print row
   Row {'update_record': function lambda at 0x1698f70, 'value':
   ['hello', 'world'], 'id': 1, 'delete_record': function lambda at
   0x16a0030}
 
   I think you inserted '|21.5|45.3|' instead of ['21.5','45.3'] and you
   get back what you insert.
 
   On Nov 23, 10:08 am, Bruno Rocha rochacbr...@gmail.com wrote:
HI, I am taking advantage of this thread to solve a doubt about
list:string,
How can I get the values from list:string field rendered as a Python
   'list'
?
 
Is there a ready way in DAL, or I need to use .split() and .join() ?
 
look:
 
 row = db(db.doacao.user_id==23).select()[0]
 row
 
Row {'user_id': 23, 'exibir': True, 'twitter': None,
 'update_record':
function lambda at 0x930ae64, 'projeto': None, 'animais':
 '|12|20|',
'valores': '|21.5|45.3|', 'obs': None, 'sorteio': '5796', 'total':
 20.0,
'data': datetime.datetime(2010, 11, 23, 10, 7, 48), 'id': 58,
'delete_record': function lambda at 0x930ae2c} row.animais
'|12|20|'
 row.valores
 
'|21.5|45.3|'
 
At this point the 'list:string' fields returns 'str' , I can split
 this
   by
'|' and create a new list, but may be DAL has a function for doing
 that?
 
2010/10/25 mdipierro mdipie...@cs.depaul.edu
 
 h. that is possible. Will look into it.
 
 On Oct 25, 3:59 pm, yamandu yamandu.co...@gmail.com wrote:
  It seems that this widget does not work when there is more than
 one
  list:string field in a page.
 
  On Oct 25, 2:01 am, mdipierro mdipie...@cs.depaul.edu wrote:
 
   The list:string is not an alternative to using a tag table and
   tag_link many-to-many (an example of which is provided by
   plugin_tagging).
 
   Yet you should not have the problem you experience. With recent
   versions of web2py, Field('keywords', 'list:string') should be
   rendered by a new widget that takes one keyword per line and
 adds
   new
   lines when yo press enter. You should not be using '|' to
 separate
   keywords. If you do all keywords will be interpreted as one
 long
   keyword containing the '|'s.
 
   Massimo
 
   On Oct 24, 10:35 pm, rick ricon...@gmail.com wrote:
 
I'm getting frustrated with the list:string field type.
 
I store products, each product has keywords that describe
 the
product.
db.define_table('products',
   Field('keywords', 'list:string'))
I don't know what the keywords will be, so I can't use
   IS_IN_SET()
 
It seems to stores the keywords fine, as long as (I'm using
 Crud)
I separate the keywords like this: green|blue|red
 
But when I make this call
rows = db(db.products.keywords.contains(keyword)).select()
I don't get all the products back that I should! 

[web2py] Re: list:string thoughts

2010-10-25 Thread yamandu
It seems that this widget does not work when there is more than one
list:string field in a page.

On Oct 25, 2:01 am, mdipierro mdipie...@cs.depaul.edu wrote:
 The list:string is not an alternative to using a tag table and
 tag_link many-to-many (an example of which is provided by
 plugin_tagging).

 Yet you should not have the problem you experience. With recent
 versions of web2py, Field('keywords', 'list:string') should be
 rendered by a new widget that takes one keyword per line and adds new
 lines when yo press enter. You should not be using '|' to separate
 keywords. If you do all keywords will be interpreted as one long
 keyword containing the '|'s.

 Massimo

 On Oct 24, 10:35 pm, rick ricon...@gmail.com wrote:

  I'm getting frustrated with the list:string field type.

  I store products, each product has keywords that describe the
  product.
  db.define_table('products',
     Field('keywords', 'list:string'))
  I don't know what the keywords will be, so I can't use IS_IN_SET()

  It seems to stores the keywords fine, as long as (I'm using Crud)
  I separate the keywords like this: green|blue|red

  But when I make this call
  rows = db(db.products.keywords.contains(keyword)).select()
  I don't get all the products back that I should! In fact, it seems
  that I need to do an update on the product (again using Crud,
  and any sort of update) before the product's keywords will be
  picked up.

  Is this a problem with using Crud?
  In all honesty, I'd be more comfortable not using list:string, and
  having a separate table keywords that linked (many-to-one)
  to the products table, but I really don't know how I would even
  begin to do that in web2py..

  Thanks for reading!
  - rick




[web2py] Re: list:string thoughts

2010-10-25 Thread mdipierro
h. that is possible. Will look into it.

On Oct 25, 3:59 pm, yamandu yamandu.co...@gmail.com wrote:
 It seems that this widget does not work when there is more than one
 list:string field in a page.

 On Oct 25, 2:01 am, mdipierro mdipie...@cs.depaul.edu wrote:

  The list:string is not an alternative to using a tag table and
  tag_link many-to-many (an example of which is provided by
  plugin_tagging).

  Yet you should not have the problem you experience. With recent
  versions of web2py, Field('keywords', 'list:string') should be
  rendered by a new widget that takes one keyword per line and adds new
  lines when yo press enter. You should not be using '|' to separate
  keywords. If you do all keywords will be interpreted as one long
  keyword containing the '|'s.

  Massimo

  On Oct 24, 10:35 pm, rick ricon...@gmail.com wrote:

   I'm getting frustrated with the list:string field type.

   I store products, each product has keywords that describe the
   product.
   db.define_table('products',
      Field('keywords', 'list:string'))
   I don't know what the keywords will be, so I can't use IS_IN_SET()

   It seems to stores the keywords fine, as long as (I'm using Crud)
   I separate the keywords like this: green|blue|red

   But when I make this call
   rows = db(db.products.keywords.contains(keyword)).select()
   I don't get all the products back that I should! In fact, it seems
   that I need to do an update on the product (again using Crud,
   and any sort of update) before the product's keywords will be
   picked up.

   Is this a problem with using Crud?
   In all honesty, I'd be more comfortable not using list:string, and
   having a separate table keywords that linked (many-to-one)
   to the products table, but I really don't know how I would even
   begin to do that in web2py..

   Thanks for reading!
   - rick




[web2py] Re: list:string thoughts

2010-10-24 Thread mdipierro
The list:string is not an alternative to using a tag table and
tag_link many-to-many (an example of which is provided by
plugin_tagging).

Yet you should not have the problem you experience. With recent
versions of web2py, Field('keywords', 'list:string') should be
rendered by a new widget that takes one keyword per line and adds new
lines when yo press enter. You should not be using '|' to separate
keywords. If you do all keywords will be interpreted as one long
keyword containing the '|'s.

Massimo


On Oct 24, 10:35 pm, rick ricon...@gmail.com wrote:
 I'm getting frustrated with the list:string field type.

 I store products, each product has keywords that describe the
 product.
 db.define_table('products',
    Field('keywords', 'list:string'))
 I don't know what the keywords will be, so I can't use IS_IN_SET()

 It seems to stores the keywords fine, as long as (I'm using Crud)
 I separate the keywords like this: green|blue|red

 But when I make this call
 rows = db(db.products.keywords.contains(keyword)).select()
 I don't get all the products back that I should! In fact, it seems
 that I need to do an update on the product (again using Crud,
 and any sort of update) before the product's keywords will be
 picked up.

 Is this a problem with using Crud?
 In all honesty, I'd be more comfortable not using list:string, and
 having a separate table keywords that linked (many-to-one)
 to the products table, but I really don't know how I would even
 begin to do that in web2py..

 Thanks for reading!
 - rick


[web2py] Re: list:string with empty list is not reversible

2010-10-15 Thread mdipierro
fixed in trunk

On Oct 15, 5:42 pm, Bob_in_Comox rwstj...@gmail.com wrote:
 Using web2py 1.87.2 with sqlite

 I need to store and retrieve a list of strings from a multple select.
 I have a case where the list can be the empty list []. It will encode
 to the datebase as '||', but will decode to ['|'], not [].

 The current gluon.sql.py is:

 def bar_encode(items):
     return '|%s|' % '|'.join(bar_escape(item) for item in items if
 str(item).strip())

 def bar_decode_string(value):
     return [x.replace('||','|') for x in string_unpack.split(value) if
 x.strip()]

 I believe the following would fix this:

 def bar_decode_string(value):
     return [x.replace('||','|') for x in
 string_unpack.split(value[1:-1]) if x.strip()]


[web2py] Re: list:string not working [solved]

2010-08-30 Thread yamandu
I wrote a slice for my solution on this purpose.
http://web2pyslices.com/main/slices/take_slice/94

It uses jQuery for a better interaction altough it needs a bit of
styling.

On Aug 27, 2:06 pm, yamandu yamandu.co...@gmail.com wrote:
 Massimo, that gave me a ticket with this:
 Traceback (most recent call last):
   File C:\repo\anima\gluon\restricted.py, line 186, in restricted
     exec ccode in environment
   File C:/repo/anima/applications/welcome/controllers/default.py,
 line 754, in module
   File C:\repo\anima\gluon\globals.py, line 96, in lambda
     self._caller = lambda f: f()
   File C:/repo/anima/applications/welcome/controllers/default.py,
 line 553, in editar_diag_beta
     form =
 crud.update(db.diagnostico_beta,request.args(0),deletable=False)
   File C:\repo\anima\gluon\tools.py, line 2756, in update
     hideerror=self.settings.hideerror):
   File C:\repo\anima\gluon\sqlhtml.py, line 906, in accepts
     hideerror=hideerror,
   File C:\repo\anima\gluon\html.py, line 1512, in accepts
     status = self._traverse(status,hideerror)
   File C:\repo\anima\gluon\html.py, line 522, in _traverse
     newstatus = c._traverse(status,hideerror) and newstatus
   File C:\repo\anima\gluon\html.py, line 522, in _traverse
     newstatus = c._traverse(status,hideerror) and newstatus
   File C:\repo\anima\gluon\html.py, line 522, in _traverse
     newstatus = c._traverse(status,hideerror) and newstatus
   File C:\repo\anima\gluon\html.py, line 522, in _traverse
     newstatus = c._traverse(status,hideerror) and newstatus
   File C:\repo\anima\gluon\html.py, line 529, in _traverse
     newstatus = self._validate()
   File C:\repo\anima\gluon\html.py, line 1300, in _validate
     (value, errors) = validator(value)
 ValueError: too many values to unpack

 But I had already succeed with this:
 class TAGS_LIST:
     def __init__(self, separator=',', error_message='This is not a
 valid list!'):
         self.separator = separator
         self.e = error_message

     def __call__(self,value):
         try:
             list = value.split(self.separator)
             return (list, None)
         except:
             return (value, self.e)

     def formatter(self, value):
         tags = ''
         for tag in value:
             tags += '%(tag)s%(sep)s ' %
 {'tag':tag,'sep':self.separator}
         return tags

 I have two question:
 Could this be general relating different DBs?
 Is there a way to define a default widget for a custom validator?

 On Aug 26, 7:28 pm, mdipierro mdipie...@cs.depaul.edu wrote:

  try define

  class IS_LIST_OF_STRINGS:
      def __call__(self,value):
           return [str(x) for x in value.split(',')]
      def formatter(self,value):
           return ', '.join(value)

  and use

      Field(...,'list:string',requires=IS_LIST_OF_STRINGS())

  On Aug 26, 4:27 pm,yamanduyamandu.co...@gmail.com wrote:

   Yes, I wish I could let the user input strings that don´t belong to
   predetermined set.
   A type of list that can add new itens does not make much sense for me.
   This is just a multi select, not properly a list in its most
   meaningful sense.

   On Aug 26, 5:36 pm, mdipierro mdipie...@cs.depaul.edu wrote:

This is not wrong.

The problem is that your field has type='list:string' but you did not
set requires=IS_IN_SET(('aaa','bbb','ccc')) or requires=IS_IN_DB(...)
Without the validator web2py does not know which options are valid and
which ones are not and does not know how to make a dropbox.

You have a valid point though. There should be a default validator
that allows to write strings separated by a comma or something like
plugin tagging. Such validator has not yet been created.

On Aug 26, 3:27 pm,yamanduyamandu.co...@gmail.com wrote: I possibly 
found a problem with list:string field.
 I´ve searched for a widget and I could found one for it.
 So I starte to make my own based on 
 thishttp://blog.crazybeavers.se/wp-content/demos/jquery.tag.editor/
 I could be like that tag editor in plugin_wiki too but I found it
 harder to base on it.

 The problem is when you update a field of type list:string using the
 item1|item2|... syntax it parses correctly and saves like array
 ['item1','item2']
 But if you update the record it shows like ['item1','item2'] and if
 you simply save it without editing it saves as ['['item1','item2']']

 I think the correct would it to reverse parse it to the | syntax, via
 widget maybe.
 If it was like this it would be simpler to adpat the above mentioned
 jQuery plugin.
 But the way it is it´s need to do two types of parses.

 Is this really wrong or not?




[web2py] Re: list:string not working

2010-08-27 Thread yamandu
Massimo, that gave me a ticket with this:
Traceback (most recent call last):
  File C:\repo\anima\gluon\restricted.py, line 186, in restricted
exec ccode in environment
  File C:/repo/anima/applications/welcome/controllers/default.py,
line 754, in module
  File C:\repo\anima\gluon\globals.py, line 96, in lambda
self._caller = lambda f: f()
  File C:/repo/anima/applications/welcome/controllers/default.py,
line 553, in editar_diag_beta
form =
crud.update(db.diagnostico_beta,request.args(0),deletable=False)
  File C:\repo\anima\gluon\tools.py, line 2756, in update
hideerror=self.settings.hideerror):
  File C:\repo\anima\gluon\sqlhtml.py, line 906, in accepts
hideerror=hideerror,
  File C:\repo\anima\gluon\html.py, line 1512, in accepts
status = self._traverse(status,hideerror)
  File C:\repo\anima\gluon\html.py, line 522, in _traverse
newstatus = c._traverse(status,hideerror) and newstatus
  File C:\repo\anima\gluon\html.py, line 522, in _traverse
newstatus = c._traverse(status,hideerror) and newstatus
  File C:\repo\anima\gluon\html.py, line 522, in _traverse
newstatus = c._traverse(status,hideerror) and newstatus
  File C:\repo\anima\gluon\html.py, line 522, in _traverse
newstatus = c._traverse(status,hideerror) and newstatus
  File C:\repo\anima\gluon\html.py, line 529, in _traverse
newstatus = self._validate()
  File C:\repo\anima\gluon\html.py, line 1300, in _validate
(value, errors) = validator(value)
ValueError: too many values to unpack

But I had already succeed with this:
class TAGS_LIST:
def __init__(self, separator=',', error_message='This is not a
valid list!'):
self.separator = separator
self.e = error_message

def __call__(self,value):
try:
list = value.split(self.separator)
return (list, None)
except:
return (value, self.e)

def formatter(self, value):
tags = ''
for tag in value:
tags += '%(tag)s%(sep)s ' %
{'tag':tag,'sep':self.separator}
return tags

I have two question:
Could this be general relating different DBs?
Is there a way to define a default widget for a custom validator?


On Aug 26, 7:28 pm, mdipierro mdipie...@cs.depaul.edu wrote:
 try define

 class IS_LIST_OF_STRINGS:
     def __call__(self,value):
          return [str(x) for x in value.split(',')]
     def formatter(self,value):
          return ', '.join(value)

 and use

     Field(...,'list:string',requires=IS_LIST_OF_STRINGS())

 On Aug 26, 4:27 pm, yamandu yamandu.co...@gmail.com wrote:

  Yes, I wish I could let the user input strings that don´t belong to
  predetermined set.
  A type of list that can add new itens does not make much sense for me.
  This is just a multi select, not properly a list in its most
  meaningful sense.

  On Aug 26, 5:36 pm, mdipierro mdipie...@cs.depaul.edu wrote:

   This is not wrong.

   The problem is that your field has type='list:string' but you did not
   set requires=IS_IN_SET(('aaa','bbb','ccc')) or requires=IS_IN_DB(...)
   Without the validator web2py does not know which options are valid and
   which ones are not and does not know how to make a dropbox.

   You have a valid point though. There should be a default validator
   that allows to write strings separated by a comma or something like
   plugin tagging. Such validator has not yet been created.

   On Aug 26, 3:27 pm, yamandu yamandu.co...@gmail.com wrote: I possibly 
   found a problem with list:string field.
I´ve searched for a widget and I could found one for it.
So I starte to make my own based on 
thishttp://blog.crazybeavers.se/wp-content/demos/jquery.tag.editor/
I could be like that tag editor in plugin_wiki too but I found it
harder to base on it.

The problem is when you update a field of type list:string using the
item1|item2|... syntax it parses correctly and saves like array
['item1','item2']
But if you update the record it shows like ['item1','item2'] and if
you simply save it without editing it saves as ['['item1','item2']']

I think the correct would it to reverse parse it to the | syntax, via
widget maybe.
If it was like this it would be simpler to adpat the above mentioned
jQuery plugin.
But the way it is it´s need to do two types of parses.

Is this really wrong or not?




[web2py] Re: list:string not working

2010-08-26 Thread mdipierro
This is not wrong.

The problem is that your field has type='list:string' but you did not
set requires=IS_IN_SET(('aaa','bbb','ccc')) or requires=IS_IN_DB(...)
Without the validator web2py does not know which options are valid and
which ones are not and does not know how to make a dropbox.

You have a valid point though. There should be a default validator
that allows to write strings separated by a comma or something like
plugin tagging. Such validator has not yet been created.


On Aug 26, 3:27 pm, yamandu yamandu.co...@gmail.com wrote:
 I possibly found a problem with list:string field.
 I´ve searched for a widget and I could found one for it.
 So I starte to make my own based on 
 thishttp://blog.crazybeavers.se/wp-content/demos/jquery.tag.editor/
 I could be like that tag editor in plugin_wiki too but I found it
 harder to base on it.

 The problem is when you update a field of type list:string using the
 item1|item2|... syntax it parses correctly and saves like array
 ['item1','item2']
 But if you update the record it shows like ['item1','item2'] and if
 you simply save it without editing it saves as ['['item1','item2']']

 I think the correct would it to reverse parse it to the | syntax, via
 widget maybe.
 If it was like this it would be simpler to adpat the above mentioned
 jQuery plugin.
 But the way it is it´s need to do two types of parses.

 Is this really wrong or not?


[web2py] Re: list:string not working

2010-08-26 Thread yamandu
Yes, I wish I could let the user input strings that don´t belong to
predetermined set.
A type of list that can add new itens does not make much sense for me.
This is just a multi select, not properly a list in its most
meaningful sense.

On Aug 26, 5:36 pm, mdipierro mdipie...@cs.depaul.edu wrote:
 This is not wrong.

 The problem is that your field has type='list:string' but you did not
 set requires=IS_IN_SET(('aaa','bbb','ccc')) or requires=IS_IN_DB(...)
 Without the validator web2py does not know which options are valid and
 which ones are not and does not know how to make a dropbox.

 You have a valid point though. There should be a default validator
 that allows to write strings separated by a comma or something like
 plugin tagging. Such validator has not yet been created.

 On Aug 26, 3:27 pm, yamandu yamandu.co...@gmail.com wrote: I possibly 
 found a problem with list:string field.
  I´ve searched for a widget and I could found one for it.
  So I starte to make my own based on 
  thishttp://blog.crazybeavers.se/wp-content/demos/jquery.tag.editor/
  I could be like that tag editor in plugin_wiki too but I found it
  harder to base on it.

  The problem is when you update a field of type list:string using the
  item1|item2|... syntax it parses correctly and saves like array
  ['item1','item2']
  But if you update the record it shows like ['item1','item2'] and if
  you simply save it without editing it saves as ['['item1','item2']']

  I think the correct would it to reverse parse it to the | syntax, via
  widget maybe.
  If it was like this it would be simpler to adpat the above mentioned
  jQuery plugin.
  But the way it is it´s need to do two types of parses.

  Is this really wrong or not?




[web2py] Re: list:string not working

2010-08-26 Thread mdipierro
try define

class IS_LIST_OF_STRINGS:
def __call__(self,value):
 return [str(x) for x in value.split(',')]
def formatter(self,value):
 return ', '.join(value)

and use

Field(...,'list:string',requires=IS_LIST_OF_STRINGS())

On Aug 26, 4:27 pm, yamandu yamandu.co...@gmail.com wrote:
 Yes, I wish I could let the user input strings that don´t belong to
 predetermined set.
 A type of list that can add new itens does not make much sense for me.
 This is just a multi select, not properly a list in its most
 meaningful sense.

 On Aug 26, 5:36 pm, mdipierro mdipie...@cs.depaul.edu wrote:

  This is not wrong.

  The problem is that your field has type='list:string' but you did not
  set requires=IS_IN_SET(('aaa','bbb','ccc')) or requires=IS_IN_DB(...)
  Without the validator web2py does not know which options are valid and
  which ones are not and does not know how to make a dropbox.

  You have a valid point though. There should be a default validator
  that allows to write strings separated by a comma or something like
  plugin tagging. Such validator has not yet been created.

  On Aug 26, 3:27 pm, yamandu yamandu.co...@gmail.com wrote: I possibly 
  found a problem with list:string field.
   I´ve searched for a widget and I could found one for it.
   So I starte to make my own based on 
   thishttp://blog.crazybeavers.se/wp-content/demos/jquery.tag.editor/
   I could be like that tag editor in plugin_wiki too but I found it
   harder to base on it.

   The problem is when you update a field of type list:string using the
   item1|item2|... syntax it parses correctly and saves like array
   ['item1','item2']
   But if you update the record it shows like ['item1','item2'] and if
   you simply save it without editing it saves as ['['item1','item2']']

   I think the correct would it to reverse parse it to the | syntax, via
   widget maybe.
   If it was like this it would be simpler to adpat the above mentioned
   jQuery plugin.
   But the way it is it´s need to do two types of parses.

   Is this really wrong or not?