Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
N
neoppod
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Ivan Tyagov
neoppod
Commits
59d142fd
Commit
59d142fd
authored
Feb 10, 2012
by
Vincent Pelletier
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Make storage.database.manager ctor API consistent with its subclasses.
Also, make it call _parse to simplify subclasses.
parent
6b6ab5d1
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
10 additions
and
8 deletions
+10
-8
neo/storage/database/btree.py
neo/storage/database/btree.py
+1
-1
neo/storage/database/manager.py
neo/storage/database/manager.py
+6
-3
neo/storage/database/mysqldb.py
neo/storage/database/mysqldb.py
+3
-4
No files found.
neo/storage/database/btree.py
View file @
59d142fd
...
@@ -122,7 +122,7 @@ def safeIter(func, *args, **kw):
...
@@ -122,7 +122,7 @@ def safeIter(func, *args, **kw):
class
BTreeDatabaseManager
(
DatabaseManager
):
class
BTreeDatabaseManager
(
DatabaseManager
):
def
__init__
(
self
,
database
):
def
__init__
(
self
,
database
):
super
(
BTreeDatabaseManager
,
self
).
__init__
()
super
(
BTreeDatabaseManager
,
self
).
__init__
(
database
)
self
.
setup
(
reset
=
1
)
self
.
setup
(
reset
=
1
)
@
property
@
property
...
...
neo/storage/database/manager.py
View file @
59d142fd
...
@@ -25,13 +25,16 @@ class CreationUndone(Exception):
...
@@ -25,13 +25,16 @@ class CreationUndone(Exception):
class
DatabaseManager
(
object
):
class
DatabaseManager
(
object
):
"""This class only describes an interface for database managers."""
"""This class only describes an interface for database managers."""
def
__init__
(
self
,
database
):
def
__init__
(
self
):
"""
"""
Initialize the object.
Initialize the object.
"""
"""
self
.
_under_transaction
=
False
self
.
_under_transaction
=
False
self
.
_parse
(
database
)
def
_parse
(
self
,
database
):
"""Called during instanciation, to process database parameter."""
pass
def
isUnderTransaction
(
self
):
def
isUnderTransaction
(
self
):
return
self
.
_under_transaction
return
self
.
_under_transaction
...
...
neo/storage/database/mysqldb.py
View file @
59d142fd
...
@@ -56,8 +56,7 @@ class MySQLDatabaseManager(DatabaseManager):
...
@@ -56,8 +56,7 @@ class MySQLDatabaseManager(DatabaseManager):
_use_partition
=
False
_use_partition
=
False
def
__init__
(
self
,
database
):
def
__init__
(
self
,
database
):
super
(
MySQLDatabaseManager
,
self
).
__init__
()
super
(
MySQLDatabaseManager
,
self
).
__init__
(
database
)
self
.
user
,
self
.
passwd
,
self
.
db
,
self
.
socket
=
self
.
_parse
(
database
)
self
.
conn
=
None
self
.
conn
=
None
self
.
_config
=
{}
self
.
_config
=
{}
self
.
_connect
()
self
.
_connect
()
...
@@ -65,8 +64,8 @@ class MySQLDatabaseManager(DatabaseManager):
...
@@ -65,8 +64,8 @@ class MySQLDatabaseManager(DatabaseManager):
def
_parse
(
self
,
database
):
def
_parse
(
self
,
database
):
""" Get the database credentials (username, password, database) """
""" Get the database credentials (username, password, database) """
# expected pattern : [user[:password]@]database[unix_socket]
# expected pattern : [user[:password]@]database[unix_socket]
return
re
.
match
(
'(?:([^:]+)(?::(.*))?@)?([^./]+)(.+)?$'
,
self
.
user
,
self
.
passwd
,
self
.
db
,
self
.
socket
=
re
.
match
(
database
).
groups
()
'(?:([^:]+)(?::(.*))?@)?([^./]+)(.+)?$'
,
database
).
groups
()
def
close
(
self
):
def
close
(
self
):
self
.
conn
.
close
()
self
.
conn
.
close
()
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment