Permalink
Browse files

Some updates for django v1.2 API changes

Change version string and add last commit date
  • Loading branch information...
1 parent 3be3dfc commit 5373c99d10b3cca7a6d78def2ce15a2098288f02 @jedie jedie committed Apr 11, 2011
Showing with 99 additions and 24 deletions.
  1. +8 −3 README.rst
  2. +9 −3 setup.py
  3. +7 −8 testproject/settings.py
  4. 0 update.sh
  5. +67 −2 weave/__init__.py
  6. +2 −2 weave/views/misc.py
  7. +3 −3 weave/views/sync.py
  8. +3 −3 weave/views/user.py
View
@@ -4,9 +4,9 @@
django-sync-server is a reusable application which implements a Mozilla Labs Weave server for Django.
---------------
-What is weave?
---------------
+---------------------
+What is Firefox Sync?
+---------------------
Firefox Sync (formerly Mozilla Labs Weave Browser Sync) is a free browser
add-on from Mozilla Labs that keeps your bookmarks, saved passwords, browsing
@@ -42,6 +42,11 @@ Unofficial debian packages: http://debian.fladi.at/pool/main/d/django-sync-serve
history
=========
+- v0.2.1
+
+ - Some updates for django v1.2 API changes
+ - Change version string and add last commit date
+
- v0.2.0
- django-sync-server own basic auth function can be disabled via app settings.
View
12 setup.py 100644 → 100755
@@ -26,15 +26,21 @@
def get_authors():
authors = []
- f = file(os.path.join(PACKAGE_ROOT, "AUTHORS"), "r")
+ try:
+ f = file(os.path.join(PACKAGE_ROOT, "AUTHORS"), "r")
+ except Exception, err:
+ return ["[Error reading AUTHORS file: %s]" % err]
for line in f:
if line.startswith('*'):
authors.append(line[1:].strip())
f.close()
return authors
def get_long_description():
- f = file(os.path.join(PACKAGE_ROOT, "README.rst"), "r")
+ try:
+ f = file(os.path.join(PACKAGE_ROOT, "README.rst"), "r")
+ except Exception, err:
+ return "[Error reading README.rst file: %s]" % err
long_description = f.read()
f.close()
long_description.strip()
@@ -56,7 +62,7 @@ def get_long_description():
# "Development Status :: 1 - Planning",
# "Development Status :: 2 - Pre-Alpha",
# "Development Status :: 3 - Alpha",
- "Development Status :: 4 - Beta",
+# "Development Status :: 4 - Beta",
"Development Status :: 5 - Production/Stable",
"Environment :: Web Environment",
"Intended Audience :: Developers",
View
@@ -47,8 +47,12 @@
MANAGERS = ADMINS
-DATABASE_ENGINE = 'sqlite3'
-DATABASE_NAME = os.path.join(PROJECT_ROOT, 'test.db3')
+DATABASES = {
+ 'default': {
+ 'ENGINE': 'django.db.backends.sqlite3',
+ 'NAME': os.path.join(PROJECT_ROOT, 'test.db3')
+ }
+}
TIME_ZONE = "UTC"
@@ -66,15 +70,10 @@
SECRET_KEY = "Make this unique, and don't share it with anybody!"
-TEMPLATE_LOADERS = (
- 'django.template.loaders.filesystem.load_template_source',
- 'django.template.loaders.app_directories.load_template_source',
-)
-
MIDDLEWARE_CLASSES = (
'django.middleware.common.CommonMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
- 'django.contrib.csrf.middleware.CsrfViewMiddleware',
+ 'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.middleware.transaction.TransactionMiddleware',
)
View
0 update.sh 100644 → 100755
No changes.
View
@@ -1,18 +1,34 @@
# coding:utf-8
+"""
+ -Logger helper class
+ -build version string
+
+ @license: GNU GPL v3 or above, see LICENSE for more details.
+ @copyleft: 2010-2011 by the django-sync-server team, see AUTHORS for more details.
+"""
+
-import os
import logging
+import os
+import subprocess
+import time
+import warnings
-__version__ = (0, 2, 0)
+__version__ = (0, 2, 1)
__api__ = (1, 0)
VERSION_STRING = '.'.join(str(part) for part in __version__)
API_STRING = '.'.join(str(integer) for integer in __api__)
+# Display get_git_hash() errors as warnings?
+#VERBOSE = True
+VERBOSE = False
+
+
class Logging(object):
"""
A private class that loads and caches some global objects.
@@ -34,3 +50,52 @@ def emit(self, record):
return cls.logger
get_logger = classmethod(get_logger)
+
+
+
+def _error(msg):
+ if VERBOSE:
+ warnings.warn(msg)
+ return ""
+
+def get_commit_timestamp(path=None):
+ if path is None:
+ path = os.path.abspath(os.path.dirname(__file__))
+
+ try:
+ process = subprocess.Popen(
+ # %ct: committer date, UNIX timestamp
+ ["/usr/bin/git", "log", "--pretty=format:%ct", "-1", "HEAD"],
+ shell=False, cwd=path,
+ stdout=subprocess.PIPE, stderr=subprocess.PIPE,
+ )
+ except Exception, err:
+ return _error("Can't get git hash: %s" % err)
+
+ process.wait()
+ returncode = process.returncode
+ if returncode != 0:
+ return _error(
+ "Can't get git hash, returncode was: %r"
+ " - git stdout: %r"
+ " - git stderr: %r"
+ % (returncode, process.stdout.readline(), process.stderr.readline())
+ )
+
+ output = process.stdout.readline().strip()
+ try:
+ timestamp = int(output)
+ except Exception, err:
+ return _error("git log output is not a number, output was: %r" % output)
+
+ try:
+ return time.strftime(".%m%d", time.gmtime(timestamp))
+ except Exception, err:
+ return _error("can't convert %r to time string: %s" % (timestamp, err))
+
+
+VERSION_STRING += get_commit_timestamp()
+
+
+if __name__ == "__main__":
+ print VERSION_STRING
View
@@ -4,13 +4,13 @@
Created on 27.03.2010
@license: GNU GPL v3 or above, see LICENSE for more details.
- @copyleft: 2010 by the django-sync-server team, see AUTHORS for more details.
+ @copyleft: 2010-2011 by the django-sync-server team, see AUTHORS for more details.
'''
# Due to Mozilla Weave supporting Recaptcha solely, we have to stick with it until
# they decide to change the interface to pluggable captchas.
from django.conf import settings
from django.core.exceptions import ImproperlyConfigured
-from django.contrib.csrf.middleware import csrf_exempt
+from django.views.decorators.csrf import csrf_exempt
from django.http import HttpResponse
# django-sync-server own stuff
View
@@ -6,7 +6,7 @@
Created on 15.03.2010
@license: GNU GPL v3 or above, see LICENSE for more details.
- @copyleft: 2010 by the django-sync-server team, see AUTHORS for more details.
+ @copyleft: 2010-2011 by the django-sync-server team, see AUTHORS for more details.
'''
from datetime import datetime
@@ -17,7 +17,7 @@
from django.utils import simplejson as json
from django.conf import settings
-from django.contrib.csrf.middleware import csrf_exempt
+from django.views.decorators.csrf import csrf_exempt
from django.core.exceptions import ValidationError
from django.http import Http404
from django.shortcuts import get_object_or_404
@@ -171,7 +171,7 @@ def storage(request, version, username, timestamp, col_name=None, wboid=None):
raise Http404()
else:
logger.info("Delete Wbo %s in collection %s for user %s" % (wbo.wboid, col_name, request.user))
- wbo.delete()
+ wbo.delete()
else:
ids = request.GET.get('ids', None)
if ids is not None:
View
@@ -7,7 +7,7 @@
Created on 15.03.2010
@license: GNU GPL v3 or above, see LICENSE for more details.
- @copyleft: 2010 by the django-sync-server team, see AUTHORS for more details.
+ @copyleft: 2010-2011 by the django-sync-server team, see AUTHORS for more details.
'''
try:
import json # New in Python v2.6
@@ -17,7 +17,7 @@
from django.conf import settings
from django.core.exceptions import ImproperlyConfigured
from django.contrib.auth.models import User
-from django.contrib.csrf.middleware import csrf_exempt
+from django.views.decorators.csrf import csrf_exempt
from django.http import HttpResponseBadRequest, HttpResponse, \
HttpResponseNotFound
@@ -70,7 +70,7 @@ def node(request, version, username):
"""
finding cluster for user -> return 404 -> Using serverURL as data cluster (multi-cluster support disabled)
"""
-
+
try:
User.objects.get(username=username)
except User.DoesNotExist:

0 comments on commit 5373c99

Please sign in to comment.