Revision c48acbfd
b/docs/source/adminguide.rst | ||
---|---|---|
164 | 164 |
|
165 | 165 |
Create database and user:: |
166 | 166 |
|
167 |
CREATE DATABASE pithos; |
|
167 |
CREATE DATABASE pithosdb CHARACTER SET utf8 COLLATE utf8_bin;
|
|
168 | 168 |
GRANT ALL ON pithos.* TO pithos@localhost IDENTIFIED BY 'password'; |
169 | 169 |
GRANT ALL ON pithos.* TO pithos@'%' IDENTIFIED BY 'password'; |
170 | 170 |
|
b/pithos/api/functions.py | ||
---|---|---|
49 | 49 |
update_manifest_meta, update_sharing_meta, update_public_meta, validate_modification_preconditions, |
50 | 50 |
validate_matching_preconditions, split_container_object_string, copy_or_move_object, |
51 | 51 |
get_int_parameter, get_content_length, get_content_range, socket_read_iterator, |
52 |
object_data_response, put_object_block, hashmap_hash, api_method) |
|
52 |
object_data_response, put_object_block, hashmap_hash, api_method, json_encode_decimal)
|
|
53 | 53 |
from pithos.backends import connect_backend |
54 | 54 |
from pithos.backends.base import NotAllowedError |
55 | 55 |
|
... | ... | |
542 | 542 |
if request.serialization == 'xml': |
543 | 543 |
data = render_to_string('objects.xml', {'container': v_container, 'objects': object_meta}) |
544 | 544 |
elif request.serialization == 'json': |
545 |
data = json.dumps(object_meta) |
|
545 |
data = json.dumps(object_meta, default=json_encode_decimal)
|
|
546 | 546 |
response.status_code = 200 |
547 | 547 |
response.content = data |
548 | 548 |
return response |
... | ... | |
619 | 619 |
d['object'] = v_object |
620 | 620 |
data = render_to_string('versions.xml', d) |
621 | 621 |
elif request.serialization == 'json': |
622 |
data = json.dumps(d) |
|
622 |
data = json.dumps(d, default=json_encode_decimal)
|
|
623 | 623 |
|
624 | 624 |
response = HttpResponse(data, status=200) |
625 | 625 |
response['Content-Length'] = len(data) |
b/pithos/api/util.py | ||
---|---|---|
55 | 55 |
import re |
56 | 56 |
import hashlib |
57 | 57 |
import uuid |
58 |
|
|
58 |
import decimal |
|
59 | 59 |
|
60 | 60 |
logger = logging.getLogger(__name__) |
61 | 61 |
|
... | ... | |
70 | 70 |
def dst(self, dt): |
71 | 71 |
return timedelta(0) |
72 | 72 |
|
73 |
def json_encode_decimal(obj): |
|
74 |
if isinstance(obj, decimal.Decimal): |
|
75 |
return str(obj) |
|
76 |
raise TypeError(repr(obj) + " is not JSON serializable") |
|
77 |
|
|
73 | 78 |
def isoformat(d): |
74 | 79 |
"""Return an ISO8601 date string that includes a timezone.""" |
75 | 80 |
|
b/pithos/backends/lib/sqlalchemy/dbwrapper.py | ||
---|---|---|
46 | 46 |
def connect(self, dbapi_con, con_record): |
47 | 47 |
db_cursor = dbapi_con.execute('pragma foreign_keys=ON') |
48 | 48 |
self.engine = create_engine(db, connect_args={'check_same_thread': False}, poolclass=NullPool, listeners=[ForeignKeysListener()]) |
49 |
if db.startswith('mysql://'): |
|
50 |
db = '%s?charset=utf8&use_unicode=0' %db |
|
51 |
self.engine = create_engine(db, convert_unicode=True) |
|
49 | 52 |
else: |
50 | 53 |
self.engine = create_engine(db) |
51 | 54 |
#self.engine.echo = True |
b/pithos/backends/lib/sqlalchemy/node.py | ||
---|---|---|
32 | 32 |
# or implied, of GRNET S.A. |
33 | 33 |
|
34 | 34 |
from time import time |
35 |
from sqlalchemy import Table, Integer, BigInteger, Float, Column, String, MetaData, ForeignKey
|
|
35 |
from sqlalchemy import Table, Integer, BigInteger, DECIMAL, Column, String, MetaData, ForeignKey
|
|
36 | 36 |
from sqlalchemy.schema import Index, Sequence |
37 | 37 |
from sqlalchemy.sql import func, and_, or_, null, select, bindparam |
38 | 38 |
from sqlalchemy.ext.compiler import compiles |
... | ... | |
128 | 128 |
primary_key=True)) |
129 | 129 |
columns.append(Column('population', Integer, nullable=False, default=0)) |
130 | 130 |
columns.append(Column('size', BigInteger, nullable=False, default=0)) |
131 |
columns.append(Column('mtime', Float))
|
|
131 |
columns.append(Column('mtime', DECIMAL))
|
|
132 | 132 |
columns.append(Column('cluster', Integer, nullable=False, default=0, |
133 | 133 |
primary_key=True)) |
134 | 134 |
self.statistics = Table('statistics', metadata, *columns) |
... | ... | |
143 | 143 |
columns.append(Column('hash', String(255))) |
144 | 144 |
columns.append(Column('size', BigInteger, nullable=False, default=0)) |
145 | 145 |
columns.append(Column('source', Integer)) |
146 |
columns.append(Column('mtime', Float))
|
|
146 |
columns.append(Column('mtime', DECIMAL))
|
|
147 | 147 |
columns.append(Column('muser', String(255), nullable=False, default='')) |
148 | 148 |
columns.append(Column('cluster', Integer, nullable=False, default=0)) |
149 | 149 |
self.versions = Table('versions', metadata, *columns) |
Also available in: Unified diff