Supspicious code in CursorWrapper.
Shouldn't it be __getattribute__()
?
If we want set_dirty() to be called on every access to 'db' and 'cursor' attributes, definitely yes. Otherwise "if attr in self.dict: ..." should be removed.
# Django 1.4
class CursorWrapper(object):
def __init__(self, cursor, db):
self.cursor = cursor
self.db = db
def set_dirty(self):
if self.db.is_managed():
self.db.set_dirty()
def __getattr__(self, attr):
self.set_dirty()
if attr in self.__dict__:
return self.__dict__[attr]
else:
return getattr(self.cursor, attr)
Change History
(6)
Description: |
modified (diff)
|
Type: |
Uncategorized → Cleanup/optimization
|
Triage Stage: |
Unreviewed → Accepted
|
Resolution: |
→ fixed
|
Status: |
new → closed
|
Current coverage report for this file seems to give you credit: http://ci.djangoproject.com/job/Django%20Coverage/HTML_Coverage_Report/_var_lib_jenkins_jobs_Django%20Coverage_workspace_django_db_backends_util.html
I'd rather suppress the
if attr in self.__dict__
part, as we mainly want to catch the calls to execute/executemany on this class' instances.