question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

BlobField cannot be used with uninitialized Proxy

See original GitHub issue

BlobField 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:closed
  • Created 7 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

3reactions
coleifercommented, May 11, 2016

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.

0reactions
coleifercommented, Jan 6, 2022

@josiahlaivins - see 13e05a3 for fix.

Read more comments on GitHub >

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

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found