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

2017-09-21 Thread Jordan Ladora
My bad - I was confused there. Forgot to post this earlier, but you were 
totally right; it's only happening when not logged in. 

Thanks again for your patience & help.

-j



On Tuesday, June 6, 2017 at 2:41:56 PM UTC-6, Jordan Ladora wrote:
>
> Thank you for checking that.
>
> Yeah, I'm still getting this, even when logged in. As a temp workaround I 
> swapped all the instances of "validate_and_insert" in my app for "insert".
>
> I did find a note I made a couple years ago from back before I upgraded to 
> the latest version that said validate_and_insert would not work if no 
> fields were set, like in the '## no fields-' example I posted on 6/3, so 
> maybe this is due to something else I have e.g. in db.py...
>
>
>
> On Monday, June 5, 2017 at 10:43:16 AM UTC-6, Anthony wrote:
>>
>> On Monday, June 5, 2017 at 12:32:09 PM UTC-4, Jordan Ladora wrote:
>>>
>>> Thanks. It's also throwing the identical error when using the app's web 
>>> page as a logged in user.
>>>
>>
>> Are you sure? I tried it as a logged in user and it works fine (using 
>> your exact table definition and insert code).
>>
>> 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.


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

2017-06-06 Thread Jordan Ladora
Thank you for checking that.

Yeah, I'm still getting this, even when logged in. As a temp workaround I 
swapped all the instances of "validate_and_insert" in my app for "insert".

I did find a note I made a couple years ago from back before I upgraded to 
the latest version that said validate_and_insert would not work if no 
fields were set, like in the '## no fields-' example I posted on 6/3, so 
maybe this is due to something else I have e.g. in db.py...



On Monday, June 5, 2017 at 10:43:16 AM UTC-6, Anthony wrote:
>
> On Monday, June 5, 2017 at 12:32:09 PM UTC-4, Jordan Ladora wrote:
>>
>> Thanks. It's also throwing the identical error when using the app's web 
>> page as a logged in user.
>>
>
> Are you sure? I tried it as a logged in user and it works fine (using your 
> exact table definition and insert code).
>
> 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.


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

2017-06-05 Thread Anthony
On Monday, June 5, 2017 at 12:32:09 PM UTC-4, Jordan Ladora wrote:
>
> Thanks. It's also throwing the identical error when using the app's web 
> page as a logged in user.
>

Are you sure? I tried it as a logged in user and it works fine (using your 
exact table definition and insert code).

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.


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

2017-06-05 Thread Jordan Ladora
Thanks. It's also throwing the identical error when using the app's web
page as a logged in user.

Suggestions?


On Mon, Jun 5, 2017 at 10:19 AM, Anthony  wrote:

> The problem is that you have auth.signature but are doing inserts without
> a logged in user. As a result, the values of the created_by and modified_by
> fields are None but are required to be id's from the db.auth_user table.
> This should simply result in a failed validation rather than an exception,
> but the IS_IN_DB validator breaks when None values are passed in for id or
> integer fields (I would consider it a bug).
>
> Anthony
>
>
> On Saturday, June 3, 2017 at 2:17:31 PM UTC-4, Jordan Ladora wrote:
>
>> 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
>>   

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

2017-06-05 Thread Anthony
The problem is that you have auth.signature but are doing inserts without a 
logged in user. As a result, the values of the created_by and modified_by 
fields are None but are required to be id's from the db.auth_user table. 
This should simply result in a failed validation rather than an exception, 
but the IS_IN_DB validator breaks when None values are passed in for id or 
integer fields (I would consider it a bug).

Anthony

On Saturday, June 3, 2017 at 2:17:31 PM UTC-4, Jordan Ladora wrote:
>
> 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, 

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: 'validate_and_insert' throws error each time on latest version where it was fine before on prev version

2017-06-02 Thread Anthony
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 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: 'validate_and_insert' throws error each time on latest version where it was fine before on prev version

2017-06-02 Thread Jordan Ladora
Hi Anthony,

Thanks for your response. 

I didn't use the admin gui to upgrade but rather DL'd the new src zip and 
moved my app into it and then replaced all the files within the app that 
get upgraded (like static, languages, some of the views, etc.) 

I just checked that everything has been upgraded, incl pydal. 

-j



On Friday, June 2, 2017 at 5:56:11 AM UTC-6, Anthony wrote:
>
> How did you upgrade? Is it possible you did not upgrade PyDAL or get its 
> proper version?
>
> Anthony
>
> On Thursday, June 1, 2017 at 11:00:11 PM UTC-4, Jordan Ladora wrote:
>>
>> Hello,
>>
>> I just belatedly upgraded from 8/9/15 (v2.12.2-stable) -> 5/10/16 
>> (v2.14.6-stable) 
>> and have about 100 instances of 'validate_and_insert' in my application.
>>
>> My app was previously (with 8/9/15 version) running these instances of 
>> 'validate_and_insert' A-OK but now, basically every instance of 
>> 'validate_and_insert' is throwing an error. When I use the shell I get a 
>> traceback that ends in:
>>
>> if isinstance(value, (int, long)) or value.isdigit():
>> AttributeError: 'NoneType' object has no attribute 'isdigit'
>>
>> It does this every single time I try to run 'validate_and_insert' when 
>> otherwise everything seems fine (and when I go back to the previous version 
>> and run the same exact code in the shell it goes fine).
>>
>> If I change the 'validate_and_insert' to just 'insert' it works, but I'd 
>> like to keep the code the way it was before.. anyone else stumble on this 
>> or have a suggestion?
>>
>> fyi it seems a little similar to the 5/8/17 thread "Validate_and_insert 
>> fails because "id" has no value" where he is also using 2.14.6-stable.
>>
>> Thank you!
>>
>>

-- 
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: 'validate_and_insert' throws error each time on latest version where it was fine before on prev version

2017-06-02 Thread Anthony
How did you upgrade? Is it possible you did not upgrade PyDAL or get its 
proper version?

Anthony

On Thursday, June 1, 2017 at 11:00:11 PM UTC-4, Jordan Ladora wrote:
>
> Hello,
>
> I just belatedly upgraded from 8/9/15 (v2.12.2-stable) -> 5/10/16 
> (v2.14.6-stable) 
> and have about 100 instances of 'validate_and_insert' in my application.
>
> My app was previously (with 8/9/15 version) running these instances of 
> 'validate_and_insert' A-OK but now, basically every instance of 
> 'validate_and_insert' is throwing an error. When I use the shell I get a 
> traceback that ends in:
>
> if isinstance(value, (int, long)) or value.isdigit():
> AttributeError: 'NoneType' object has no attribute 'isdigit'
>
> It does this every single time I try to run 'validate_and_insert' when 
> otherwise everything seems fine (and when I go back to the previous version 
> and run the same exact code in the shell it goes fine).
>
> If I change the 'validate_and_insert' to just 'insert' it works, but I'd 
> like to keep the code the way it was before.. anyone else stumble on this 
> or have a suggestion?
>
> fyi it seems a little similar to the 5/8/17 thread "Validate_and_insert 
> fails because "id" has no value" where he is also using 2.14.6-stable.
>
> Thank you!
>
>

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