Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
itminedu
synnefo
Commits
00a40523
Commit
00a40523
authored
Oct 05, 2012
by
Christos Stavrakakis
Browse files
Pool connections to snf-pithos-backend
parent
0456269f
Changes
2
Hide whitespace changes
Inline
Side-by-side
snf-cyclades-app/setup.py
View file @
00a40523
...
...
@@ -75,10 +75,10 @@ INSTALL_REQUIRES = [
'pycrypto>=2.1.0'
,
'puka'
,
'python-daemon>=1.5.5, <1.6'
,
'snf-common>0.
9.14
'
,
'snf-common>0.
11
'
,
'vncauthproxy>=1.2'
,
'south>=0.7, <=0.7.3'
,
'snf-pithos-backend>=0.
9.
1'
,
'snf-pithos-backend>=0.
1
1'
,
'lockfile>=0.8, <0.9'
,
'ipaddr'
,
'bitarray'
...
...
snf-cyclades-app/synnefo/plankton/backend.py
View file @
00a40523
...
...
@@ -58,7 +58,6 @@ from time import gmtime, strftime, time
from
django.conf
import
settings
from
pithos.backends
import
connect_backend
from
pithos.backends.base
import
NotAllowedError
...
...
@@ -75,6 +74,7 @@ def get_location(account, container, object):
assert
'/'
not
in
container
,
"Invalid container"
return
'pithos://%s/%s/%s'
%
(
account
,
container
,
object
)
def
split_location
(
location
):
"""Returns (accout, container, object) from a location string"""
t
=
location
.
split
(
'/'
,
4
)
...
...
@@ -86,20 +86,29 @@ class BackendException(Exception):
pass
from
pithos.backends.util
import
PithosBackendPool
POOL_SIZE
=
8
_pithos_backend_pool
=
\
PithosBackendPool
(
POOL_SIZE
,
db_connection
=
settings
.
BACKEND_DB_CONNECTION
,
block_path
=
settings
.
BACKEND_BLOCK_PATH
)
def
get_pithos_backend
():
return
_pithos_backend_pool
.
pool_get
()
class
ImageBackend
(
object
):
"""A wrapper arround the pithos backend to simplify image handling."""
def
__init__
(
self
,
user
):
self
.
user
=
user
original_filters
=
warnings
.
filters
warnings
.
simplefilter
(
'ignore'
)
# Suppress SQLAlchemy warnings
db_connection
=
settings
.
BACKEND_DB_CONNECTION
block_path
=
settings
.
BACKEND_BLOCK_PATH
self
.
backend
=
connect_backend
(
db_connection
=
db_connection
,
block_path
=
block_path
)
self
.
backend
=
get_pithos_backend
()
warnings
.
filters
=
original_filters
# Restore warnings
def
_get_image
(
self
,
location
):
def
format_timestamp
(
t
):
return
strftime
(
'%Y-%m-%d %H:%M:%S'
,
gmtime
(
t
))
...
...
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