Skip to content

Commit

Permalink
Some fixes to LargeObject and FSObject
Browse files Browse the repository at this point in the history
  • Loading branch information
lw committed Jul 16, 2018
1 parent 52df2c9 commit dcf919f
Showing 1 changed file with 6 additions and 9 deletions.
15 changes: 6 additions & 9 deletions cms/db/fsobject.py
Expand Up @@ -120,7 +120,7 @@ def __init__(self, loid, mode='rb'):
self._fd = self._execute("SELECT lo_open(%(loid)s, %(mode)s);",
{'loid': self.loid, 'mode': open_mode},
"Couldn't open large object with LOID "
"%s." % (self.loid), cursor)
"%s." % self.loid, cursor)

cursor.close()

Expand Down Expand Up @@ -283,9 +283,9 @@ def tell(self):
if self._fd is None:
raise io.UnsupportedOperation("Large object is closed.")

pos = self._.execute("SELECT lo_tell(%(fd)s);",
{'fd': self._fd},
"Couldn't tell large object.")
pos = self._execute("SELECT lo_tell(%(fd)s);",
{'fd': self._fd},
"Couldn't tell large object.")
return pos

def truncate(self, size=None):
Expand Down Expand Up @@ -347,11 +347,8 @@ def unlink(loid, conn=None):
conn = custom_psycopg2_connection()
conn.autocommit = True

# FIXME Use context manager as soon as we require psycopg2-2.5.
cursor = conn.cursor()
cursor.execute("SELECT lo_unlink(%(loid)s);",
{'loid': loid})
cursor.close()
with conn.cursor() as cursor:
cursor.execute("SELECT lo_unlink(%(loid)s);", {'loid': loid})


class FSObject(Base):
Expand Down

0 comments on commit dcf919f

Please sign in to comment.