BlobField cannot be used with uninitialized Proxy
See original GitHub issueBlobField determines its binary type on its initialization. BlobField then cannot be used with Proxied database that is not initialized. An AttributeError
is risen right after module execution/import.
Reproducer:
import peewee
class NonWorkingBlobFieldOnProxy(peewee.Model):
class Meta:
database = peewee.Proxy()
myblob = peewee.BlobField()
Raises:
Traceback (most recent call last):
File "proxy_example.py", line 3, in <module>
class NonWorkingBlobFieldOnProxy(peewee.Model):
File "venv/lib/python2.7/site-packages/peewee.py", line 4479, in __new__
field.add_to_class(cls, name)
File "venv/lib/python2.7/site-packages/peewee.py", line 1081, in add_to_class
self._constructor = model_class._meta.database.get_binary_type()
File "venv/lib/python2.7/site-packages/peewee.py", line 407, in __getattr__
raise AttributeError('Cannot use uninitialized Proxy.')
AttributeError: Cannot use uninitialized Proxy.
This affects version 2.8.1. In later versions (2.6.X) this problem did not occur. Commit that introduced this regression: b32e967e
Issue Analytics
- State:
- Created 7 years ago
- Comments:5 (3 by maintainers)
Top Results From Across the Web
Peewee error on model.create() [ Proxy ] - Stack Overflow
Possible, that i'm getting this error because using Proxy class, but can't find mistake in my code. init.py from flask import Flask from ......
Read more >Source code for peewee
... is None: raise AttributeError('Cannot use uninitialized Proxy.') return getattr(self.obj, attr) def __setattr__(self, attr, value): if attr not in self.
Read more >peewee — pyfact 0.10.4 documentation - PythonHosted.org
These helpers are used internally and are # not exported. ... attr): if self.obj is None: raise AttributeError('Cannot use uninitialized Proxy.
Read more >https://raw.githubusercontent.com/coleifer/peewee/...
#933 - fixed bug where `BlobField` could not be used if it's parent model pointed to an uninitialized database `Proxy`. * #935 -...
Read more >peewee - freshcode.club
#933 - where BlobField could not be used if it's parent model. Pointed to an uninitialized database Proxy. #935 - greater consistency with...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
The proxy should have a way to attach callbacks if I remember correctly, so I just need to move the binary type binding to a hook. I’ll fix it regardless, but glad you’re not blocked at the moment.
@josiahlaivins - see 13e05a3 for fix.