Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
Coopdevs OCB mirror
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
External wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Coopdevs
Odoo
Coopdevs OCB mirror
Commits
578c8832
Commit
578c8832
authored
10 years ago
by
Xavier Morel
Browse files
Options
Downloads
Plain Diff
Merge pull request #663 from xmo-odoo/master-remove-pg1cursor-xmo
Remove psycopg1.cursor usage
parents
981362b2
64ca79cc
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
openerp/sql_db.py
+13
-4
13 additions, 4 deletions
openerp/sql_db.py
with
13 additions
and
4 deletions
openerp/sql_db.py
+
13
−
4
View file @
578c8832
...
...
@@ -30,12 +30,11 @@ the ORM does, in fact.
from
contextlib
import
contextmanager
from
functools
import
wraps
import
logging
import
time
import
uuid
import
psycopg2.extras
import
psycopg2.extensions
from
psycopg2.extensions
import
ISOLATION_LEVEL_AUTOCOMMIT
,
ISOLATION_LEVEL_READ_COMMITTED
,
ISOLATION_LEVEL_REPEATABLE_READ
from
psycopg2.pool
import
PoolError
from
psycopg2.psycopg1
import
cursor
as
psycopg1cursor
psycopg2
.
extensions
.
register_type
(
psycopg2
.
extensions
.
UNICODE
)
...
...
@@ -76,7 +75,7 @@ sql_counter = 0
class
Cursor
(
object
):
"""
Represents an open transaction to the PostgreSQL DB backend,
acting as a lightweight wrapper around psycopg2
'
s
``
psycopg1
cursor`` objects.
``cursor`` objects.
``Cursor`` is the object behind the ``cr`` variable used all
over the OpenERP code.
...
...
@@ -175,7 +174,7 @@ class Cursor(object):
self
.
_serialized
=
serialized
self
.
_cnx
=
pool
.
borrow
(
dsn
(
dbname
))
self
.
_obj
=
self
.
_cnx
.
cursor
(
cursor_factory
=
psycopg1cursor
)
self
.
_obj
=
self
.
_cnx
.
cursor
()
if
self
.
sql_log
:
self
.
__caller
=
frame_codeinfo
(
currentframe
(),
2
)
else
:
...
...
@@ -188,6 +187,16 @@ class Cursor(object):
self
.
cache
=
{}
def
__build_dict
(
self
,
row
):
return
{
d
.
name
:
row
[
i
]
for
i
,
d
in
enumerate
(
self
.
_obj
.
description
)
}
def
dictfetchone
(
self
):
row
=
self
.
_obj
.
fetchone
()
return
row
and
self
.
__build_dict
(
row
)
def
dictfetchmany
(
self
,
size
):
return
map
(
self
.
__build_dict
,
self
.
_obj
.
fetchmany
(
size
))
def
dictfetchall
(
self
):
return
map
(
self
.
__build_dict
,
self
.
_obj
.
fetchall
())
def
__del__
(
self
):
if
not
self
.
_closed
and
not
self
.
_cnx
.
closed
:
# Oops. 'self' has not been closed explicitly.
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment