Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

drop support for 2.5 and add compatibility for 2.6

  • Loading branch information...
commit 671d7ad1387063b75e18d842c73f6cb40cb41f8e 1 parent 7777ab3
@posativ authored
View
2  README.md
@@ -15,7 +15,7 @@ fetch fail apt-get install. It just works.
Setup and Configuration
-----------------------
-You need `python` ≥ 2.5. See `weave-minimal --help` for a list of parameters
+You need `python` ≥ 2.6. See `weave-minimal --help` for a list of parameters
including a short description. As fast and lightweight WSGI server,
[bjoern](https://github.com/jonashaag/bjoern) is supported out of the box.
View
8 setup.py
@@ -6,11 +6,6 @@
from setuptools import setup, find_packages
-requires = ['werkzeug']
-
-if sys.version_info < (2, 6):
- requires.append('simplejson')
-
version = re.search("__version__ = '([^']+)'",
open('weave/__init__.py').read()).group(1)
@@ -30,11 +25,10 @@
"Topic :: Internet :: WWW/HTTP :: HTTP Servers",
"Topic :: Internet :: WWW/HTTP :: WSGI :: Application",
"License :: OSI Approved :: BSD License",
- "Programming Language :: Python :: 2.5",
"Programming Language :: Python :: 2.6",
"Programming Language :: Python :: 2.7"
],
- install_requires=requires,
+ install_requires=['werkzeug'],
entry_points={
'console_scripts':
['weave-minimal = weave:main'],
View
26 weave/minimal/storage.py
@@ -1,20 +1,32 @@
#!/usr/bin/env python
# -*- encoding: utf-8 -*-
+import sys
import math
import time
+import json
import sqlite3
+if sys.version_info < (2, 7):
+ import __builtin__
+
+ class Float(float):
+
+ def __new__(self, x, i):
+ self.i = i
+ return float.__new__(self, x)
+
+ def __repr__(self):
+ return (('%%.%sf' % self.i ) % self)
+
+ defaultround = round
+ setattr(__builtin__, 'round', lambda x, i: Float(defaultround(x, 2), i))
+
from werkzeug import Response
from weave.minimal.utils import login, path, wbo2dict, initialize, convert
from weave.minimal.errors import WeaveException
-try:
- import json
-except ImportError:
- import simplejson as json
-
WEAVE_INVALID_WRITE = "4" # Attempt to overwrite data that can't be
WEAVE_MALFORMED_JSON = "6" # Json parse failure
WEAVE_INVALID_WBO = "8" # Invalid Weave Basic Object
@@ -186,7 +198,7 @@ def storage(app, environ, request, version, uid):
if request.headers.get('X-Confirm-Delete', '0') == '1':
try:
initialize(uid, request.authorization.password, app.data_dir)
- except WeaveException as e:
+ except WeaveException, e:
return Response(str(e), 500)
return Response(json.dumps(time.time()), 200)
@@ -395,7 +407,7 @@ def item(app, environ, request, version, uid, cid, id):
return Response(json.dumps(obj['modified']), 200,
content_type='application/json',
- headers={'X-Weave-Timestamp': obj['modified']})
+ headers={'X-Weave-Timestamp': round(obj['modified'], 2)})
elif request.method == 'DELETE':
with sqlite3.connect(dbpath) as db:
View
6 weave/minimal/user.py
@@ -17,13 +17,9 @@
WEAVE_OVER_QUOTA = "14" # User over quota
import os
+import json
import sqlite3
-try:
- import json
-except ImportError:
- import simplejson as json
-
from werkzeug.wrappers import Response
from weave.minimal.utils import login, path
View
6 weave/minimal/utils.py
@@ -5,6 +5,7 @@
import os
import re
+import json
import base64
import struct
import sqlite3
@@ -12,11 +13,6 @@
from os.path import join, isfile
from hashlib import sha1
-try:
- import json
-except ImportError:
- import simplejson as json
-
def path(dir, user, passwd):
"""return joined path to database using data_dir + '/' + user.sha1(passwd)
Please sign in to comment.
Something went wrong with that request. Please try again.