[web2py] list:reference get data

2017-06-03 Thread Winter Kryz
Hello everybody,

I have this table with a list:reference to another table

Movie = db.define_table('movies',
 Field('title','string', label = 'Title'),
 Field('date_release','integer', label = 'Date Release'),
 Field('duraction','integer', label = 'Duraction'),
 Field('category','string','list:reference categories', label = 'Category'),
 Field('actor','list:reference actors', label = 'Actor'),
 Field('director','list:reference directors', label = 'Diretor'),
 )




I have to do a report using Reportlab and I would like to know how can I 
extract the data from a  list:reference
I tried to do this but it doesn't work
for row in db(db.movies).select():
list= row.actor 
story.append(list)

I would like to know how can I get the data from the list. Any suggestions 
will be appreciated.

Thanks.

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


Re: [web2py] Re: 'validate_and_insert' throws error each time on latest version where it was fine before on prev version

2017-06-03 Thread Jordan Ladora
Yes, I was able to reproduce with a fresh install of web2py-

Here's what I did-
-
extracted new copy of web2py from DL src

modified welcome app-
 in models/db.py commented out this block-
  if not request.env.web2py_runtime_gae: / else:
 ..and replaced with-
   db = DAL('sqlite://storage.sqlite', lazy_tables=True,
ignore_field_case=False, pool_size=10, check_reserved=['postgres',
'postgres_nonreserved'])

created models/db_data.py and added-

 db.define_table('datatable',
Field('title', length=128),
Field('name', requires=IS_IN_SET(['a','b','c'], multiple=False,
zero=None), readable=False, writable=False, length=128),
Field('dtype', requires=IS_IN_SET(['1','2','3'], multiple=False),
label="Type", readable=False, writable=False, length=128),
Field('finished', 'boolean', default=False, readable=False,
writable=False),
Field('the_timestamp', 'datetime', readable=False, writable=False),
Field('alive', 'boolean', default=True, readable=False, writable=False),
Field( 'comments', 'text' ),
auth.signature, migrate=True,
format = '%(title)s %(datatype)s %(species)s'
)

created welcome/databases folder




launched with-

python '.../web2py.py' -S welcome -M

>>> from datetime import datetime

## insert two fields-
>>> new_record = db.datatable.validate_and_insert(dtype='1',
the_timestamp=datetime.utcnow())
Traceback (most recent call last):
  File "", line 1, in 
  File ".../gluon/packages/dal/pydal/objects.py", line 749, in
validate_and_insert
response, new_fields = self._validate_fields(fields)
  File ".../gluon/packages/dal/pydal/objects.py", line 741, in
_validate_fields
value, error = self[fieldname].validate(raw_value)
  File ".../gluon/packages/dal/pydal/objects.py", line 1634, in validate
(value, error) = validator(value)
  File ".../gluon/validators.py", line 660, in __call__
if isinstance(value, (int, long)) or value.isdigit():
AttributeError: 'NoneType' object has no attribute 'isdigit'


## no fields-
>>> new_record = db.datatable.validate_and_insert()
Traceback (most recent call last):
  File "", line 1, in 
  File ".../gluon/packages/dal/pydal/objects.py", line 749, in
validate_and_insert
response, new_fields = self._validate_fields(fields)
  File ".../gluon/packages/dal/pydal/objects.py", line 741, in
_validate_fields
value, error = self[fieldname].validate(raw_value)
  File ".../gluon/packages/dal/pydal/objects.py", line 1634, in validate
(value, error) = validator(value)
  File ".../gluon/validators.py", line 660, in __call__
if isinstance(value, (int, long)) or value.isdigit():
AttributeError: 'NoneType' object has no attribute 'isdigit'


## 'name' field here should throw error for not being in set defined by
model-
>>> new_record = db.datatable.validate_and_insert(title='test title',
name='test name', dtype='1', finished=False,
the_timestamp=datetime.utcnow(), alive=True, comments='this is a test')
Traceback (most recent call last):
  File "", line 1, in 
  File ".../gluon/packages/dal/pydal/objects.py", line 749, in
validate_and_insert
response, new_fields = self._validate_fields(fields)
  File ".../gluon/packages/dal/pydal/objects.py", line 741, in
_validate_fields
value, error = self[fieldname].validate(raw_value)
  File ".../gluon/packages/dal/pydal/objects.py", line 1634, in validate
(value, error) = validator(value)
  File ".../gluon/validators.py", line 660, in __call__
if isinstance(value, (int, long)) or value.isdigit():
AttributeError: 'NoneType' object has no attribute 'isdigit'


## all fields-
>>> new_record = db.datatable.validate_and_insert(title='test title',
name='a', dtype='1', finished=False, the_timestamp=datetime.utcnow(),
alive=True, comments='this is a test')
Traceback (most recent call last):
  File "", line 1, in 
  File ".../gluon/packages/dal/pydal/objects.py", line 749, in
validate_and_insert
response, new_fields = self._validate_fields(fields)
  File ".../gluon/packages/dal/pydal/objects.py", line 741, in
_validate_fields
value, error = self[fieldname].validate(raw_value)
  File ".../gluon/packages/dal/pydal/objects.py", line 1634, in validate
(value, error) = validator(value)
  File ".../gluon/validators.py", line 660, in __call__
if isinstance(value, (int, long)) or value.isdigit():
AttributeError: 'NoneType' object has no attribute 'isdigit'


Thanks again for your help.



On Fri, Jun 2, 2017 at 11:04 AM, Anthony  wrote:

> Can we see the code and full traceback?
>
> --
> Resources:
> - http://web2py.com
> - http://web2py.com/book (Documentation)
> - http://github.com/web2py/web2py (Source code)
> - https://code.google.com/p/web2py/issues/list (Report Issues)
> ---
> You received this message because you are subscribed to a topic in the
> Google Groups "web2py-users" group.
> To unsubscribe from this topic, visit https://groups.google.com/d/
> 

[web2py] Re: 'Column table.id not found (SQLTABLE)'

2017-06-03 Thread Najtsirk
I checked this and I had pydal installed as a global module. 
When I removed it web2py's DAL works ok.



On Saturday, 3 June 2017 18:30:05 UTC+2, Najtsirk wrote:
>
> +1
> Have this problem too!
>
> On Saturday, 3 June 2017 18:13:18 UTC+2, Maurice Waka wrote:
>>
>> Hi did anyone get to solve this error? I seem to be locked in it also
>> Regards
>>
>> On Monday, March 20, 2017 at 4:39:13 PM UTC+3, Santiago Cartasegna wrote:
>>>
>>> Are you trying to use a table that you have defined in your database and 
>>> not in web2py? 
>>> If it is the case you must add an id field with autoincremental
>>>
>>> El domingo, 12 de marzo de 2017, 20:27:08 (UTC-3), LoveWeb2py escribió:

 Keep getting this error for all of my tables!! What is going on?

 What information would be helpful for me to post to get help?

>>>

-- 
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: 'Column table.id not found (SQLTABLE)'

2017-06-03 Thread Najtsirk
+1
Have this problem too!

On Saturday, 3 June 2017 18:13:18 UTC+2, Maurice Waka wrote:
>
> Hi did anyone get to solve this error? I seem to be locked in it also
> Regards
>
> On Monday, March 20, 2017 at 4:39:13 PM UTC+3, Santiago Cartasegna wrote:
>>
>> Are you trying to use a table that you have defined in your database and 
>> not in web2py? 
>> If it is the case you must add an id field with autoincremental
>>
>> El domingo, 12 de marzo de 2017, 20:27:08 (UTC-3), LoveWeb2py escribió:
>>>
>>> Keep getting this error for all of my tables!! What is going on?
>>>
>>> What information would be helpful for me to post to get help?
>>>
>>

-- 
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] KeyError issue: column.id Not found

2017-06-03 Thread Maurice Waka
I seem to have the same problem as highlighted in 
this: https://groups.google.com/forum/#!topic/web2py/oriec4bEAJQ

The traceback is the same as mine. 
Has anyone solved the problem or found the origin of it? After updating my 
laptop, i now have the same. When ever i click on any table including: 
auth_user, auth_group, any table, the error is the same.
Regards

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


[web2py] Re: 'Column table.id not found (SQLTABLE)'

2017-06-03 Thread Maurice Waka
Hi did anyone get to solve this error? I seem to be locked in it also
Regards

On Monday, March 20, 2017 at 4:39:13 PM UTC+3, Santiago Cartasegna wrote:
>
> Are you trying to use a table that you have defined in your database and 
> not in web2py? 
> If it is the case you must add an id field with autoincremental
>
> El domingo, 12 de marzo de 2017, 20:27:08 (UTC-3), LoveWeb2py escribió:
>>
>> Keep getting this error for all of my tables!! What is going on?
>>
>> What information would be helpful for me to post to get help?
>>
>

-- 
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: grid add/edit form label

2017-06-03 Thread Anthony
Oops, sorry, for some reason I wrapped the labels dict in a list -- should 
be:

formargs={'amc_master': dict(labels={'lrrflg': 'Rate Revision'}),
  'amc_details': dict(labels={'qty': 'Quantity'})}


On Saturday, June 3, 2017 at 12:32:15 AM UTC-4, T.R.Rajkumar wrote:
>
> As said I did this in controller but there is no effect in either create 
> or edit forms of amc_master or amc_details. I added the closing parenthesis 
> for the first dict. Anything I miss?
>
> form = SQLFORM.smartgrid(db.amc_master,
>  linked_tables=['amc_details'],
>  user_signature=False,
>  fields=dict(amc_master=list_of_fields),
>  formstyle='table3cols',
>  headers=headers,
>  formargs={'amc_master': 
> dict(labels=[{'lrrflg': 'Rate Revision'}]),
>'amc_details': dict(labels=[{'qty': 
> 'Quantity'}])}
> )
>

-- 
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: grid add/edit form label

2017-06-03 Thread icodk
In a controller that shows a grid/smartgrid, I have three parts.The first 
part is before the call to the SQLFORM.smartgrid, then next is the call to 
SQLFORM.smartgrid and the third part is after the call to SQLFORM.smartgrid.
In the first part I inspect the request.args to figure out what the grid is 
going to do. For example:
if 'edit' in request.args:
   db.person.email.writable=False
   db.person.street_address.label="where is your house"

This will prevent the user from editing the email in the edit form
If there are linked tables I can also detect it and prepare a title like:
"This is a list of cars owned by John Smith"
In general request.args is your friend. Print it out and see what 
information is there

The last part is after the call to SQLFORM.smartgrid. Here you can 
manipulate the serialized HTML data by for example changing the "+Add 
record" text to "+Add person" in the  auto generated button 

On Saturday, June 3, 2017 at 6:32:15 AM UTC+2, T.R.Rajkumar wrote:
>
> As said I did this in controller but there is no effect in either create 
> or edit forms of amc_master or amc_details. I added the closing parenthesis 
> for the first dict. Anything I miss?
>
> form = SQLFORM.smartgrid(db.amc_master,
>  linked_tables=['amc_details'],
>  user_signature=False,
>  fields=dict(amc_master=list_of_fields),
>  formstyle='table3cols',
>  headers=headers,
>  formargs={'amc_master': 
> dict(labels=[{'lrrflg': 'Rate Revision'}]),
>'amc_details': dict(labels=[{'qty': 
> 'Quantity'}])}
> )
>

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