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
b6f8b8d2
Commit
b6f8b8d2
authored
May 05, 2011
by
Sofia Papagiannaki
Browse files
#Refs #447
parent
9887bd5e
Changes
1
Show whitespace changes
Inline
Side-by-side
pithos/backends/dummy.py
View file @
b6f8b8d2
import
os
import
os
import
sqlite3
import
sqlite3
import
json
import
logging
import
logging
import
types
import
types
import
hashlib
import
hashlib
import
shutil
import
shutil
import
basebackend
logger
=
logging
.
getLogger
(
__name__
)
logger
=
logging
.
getLogger
(
__name__
)
class
BackEnd
:
class
BackEnd
(
basebackend
.
BaseBackEnd
)
:
def
__init__
(
self
,
basepath
):
def
__init__
(
self
,
basepath
):
self
.
basepath
=
basepath
self
.
basepath
=
basepath
...
@@ -196,6 +196,10 @@ class BackEnd:
...
@@ -196,6 +196,10 @@ class BackEnd:
fullname
=
os
.
path
.
join
(
self
.
basepath
,
account
,
container
)
fullname
=
os
.
path
.
join
(
self
.
basepath
,
account
,
container
)
if
not
os
.
path
.
exists
(
fullname
):
if
not
os
.
path
.
exists
(
fullname
):
raise
NameError
(
'Container does not exist'
)
raise
NameError
(
'Container does not exist'
)
try
:
link
=
self
.
__get_linkinfo
(
os
.
path
.
join
(
account
,
container
,
name
))
except
NameError
:
raise
NameError
(
'Object does not exist'
)
self
.
__put_metadata
(
os
.
path
.
join
(
account
,
container
,
name
),
meta
)
self
.
__put_metadata
(
os
.
path
.
join
(
account
,
container
,
name
),
meta
)
return
return
...
@@ -259,6 +263,8 @@ class BackEnd:
...
@@ -259,6 +263,8 @@ class BackEnd:
dest_location
=
os
.
path
.
join
(
self
.
basepath
,
account
,
dest_container
,
link
)
dest_location
=
os
.
path
.
join
(
self
.
basepath
,
account
,
dest_container
,
link
)
shutil
.
copyfile
(
src_location
,
dest_location
)
shutil
.
copyfile
(
src_location
,
dest_location
)
# TODO: accept metadata changes
self
.
__put_metadata
(
os
.
path
.
join
(
account
,
dest_container
,
dest_name
),
self
.
__get_metadata
(
os
.
path
.
join
(
account
,
src_container
,
src_name
)))
return
return
def
delete_object
(
self
,
account
,
container
,
name
):
def
delete_object
(
self
,
account
,
container
,
name
):
...
@@ -306,8 +312,6 @@ class BackEnd:
...
@@ -306,8 +312,6 @@ class BackEnd:
else
:
else
:
link
=
self
.
con
.
execute
(
'insert into objects (name) values (?)'
,
(
path
,)).
lastrowid
link
=
self
.
con
.
execute
(
'insert into objects (name) values (?)'
,
(
path
,)).
lastrowid
for
k
,
v
in
meta
.
iteritems
():
for
k
,
v
in
meta
.
iteritems
():
if
type
(
v
)
!=
types
.
StringType
:
v
=
json
.
dumps
(
v
)
self
.
con
.
execute
(
'insert or replace into metadata (object_id, name, value) values (?, ?, ?)'
,
(
link
,
k
,
v
))
self
.
con
.
execute
(
'insert or replace into metadata (object_id, name, value) values (?, ?, ?)'
,
(
link
,
k
,
v
))
self
.
con
.
commit
()
self
.
con
.
commit
()
return
return
...
...
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