Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAleksey Lim <alsroot@sugarlabs.org>2012-05-08 20:47:12 (GMT)
committer Aleksey Lim <alsroot@sugarlabs.org>2012-05-08 20:47:12 (GMT)
commitd808323aabc8052b407d889bd3429d0f3b4a98f1 (patch)
treeefe705dc31d472534ffbba456a9902eb86e1f0b7
parent660bfd2260644027c408625612366b049b5bdc2d (diff)
Reflect on deps changes
-rwxr-xr-xsugar-network-server11
-rw-r--r--sugar_network_server/application.py2
-rw-r--r--sugar_network_server/resources/implementation.py13
-rw-r--r--sugar_network_server/resources/user.py23
4 files changed, 24 insertions, 25 deletions
diff --git a/sugar-network-server b/sugar-network-server
index 6ce441a..ce16c0b 100755
--- a/sugar-network-server
+++ b/sugar-network-server
@@ -26,6 +26,12 @@ from active_document import optparse
from sugar_network_server import env, stats, application, resources
+data_root = optparse.Option(
+ _('path to the root directory for placing documents\' ' \
+ 'data and indexes'),
+ default='/var/lib/sugar-network/db')
+
+
class Application(application.Daemon):
httpd = None
@@ -38,7 +44,7 @@ class Application(application.Daemon):
if rd.certfile.value:
ssl_args['certfile'] = rd.certfile.value
- self.folder = ad.SingleFolder(resources.path)
+ self.folder = ad.SingleVolume(data_root.value, resources.path)
self.httpd = WSGIServer((rd.host.value, rd.port.value),
rd.Router(self.folder), **ssl_args)
self.httpd.serve_forever()
@@ -53,7 +59,8 @@ class Application(application.Daemon):
self.folder.close()
-optparse.Option.seek('main', application)
+optparse.Option.seek('sugar-network-server')
+optparse.Option.seek('sugar-network-server', application)
optparse.Option.seek('stats', stats)
optparse.Option.seek('restful-document', rd)
optparse.Option.seek('active-document', ad)
diff --git a/sugar_network_server/application.py b/sugar_network_server/application.py
index 8b24660..7b2f32a 100644
--- a/sugar_network_server/application.py
+++ b/sugar_network_server/application.py
@@ -17,7 +17,7 @@
$Repo: git://git.sugarlabs.org/alsroot/codelets.git$
$File: src/application.py$
-$Data: 2012-05-02$
+$Data: 2012-05-08$
"""
diff --git a/sugar_network_server/resources/implementation.py b/sugar_network_server/resources/implementation.py
index 450b347..c4d2ad3 100644
--- a/sugar_network_server/resources/implementation.py
+++ b/sugar_network_server/resources/implementation.py
@@ -16,7 +16,6 @@
# pylint: disable-msg=E1101,E0102,E0202
import active_document as ad
-import restful_document as rd
from sweets_recipe import GOOD_LICENSES
from sugar_network_server import env
@@ -62,11 +61,7 @@ class Implementation(Resource):
return value
@ad.active_property(ad.BlobProperty)
- def bundle(self, value):
- return value
-
- def get_blob(self, prop_name, raw=False):
- if prop_name == 'bundle':
- if self['url']:
- raise rd.SeeOther(self['url'])
- return Resource.send_blob(self, prop_name, raw)
+ def bundle(self, path):
+ if self.url:
+ raise ad.Redirect(self.url)
+ return path
diff --git a/sugar_network_server/resources/user.py b/sugar_network_server/resources/user.py
index 3380ec2..383d6ac 100644
--- a/sugar_network_server/resources/user.py
+++ b/sugar_network_server/resources/user.py
@@ -64,16 +64,13 @@ class User(ad.Document):
return value
@classmethod
- def create(cls, properties):
- enforce('pubkey' in properties,
+ def on_create(cls, props):
+ enforce('pubkey' in props,
_('Property "pubkey" is required for user registeration'))
- guid, properties['pubkey'] = _load_pubkey(properties['pubkey'].strip())
- doc = cls(**(properties or {}))
- doc.set('guid', guid, raw=True)
- doc.post()
- return doc
+ props['guid'], props['pubkey'] = _load_pubkey(props['pubkey'].strip())
+ super(User, cls).on_create(props)
- @ad.active_method(cmd='stats-info',
+ @ad.active_command(cmd='stats-info',
permissions=ad.ACCESS_AUTHOR)
def _stats_info(self):
status = {}
@@ -86,11 +83,11 @@ class User(ad.Document):
'status': status,
}
- @ad.active_method(http_method='POST', cmd='stats-upload',
+ @ad.active_command(method='POST', cmd='stats-upload',
permissions=ad.ACCESS_AUTHOR)
- def _stats_upload(self):
- name = rd.request.content['name']
- values = rd.request.content['values']
+ def _stats_upload(self, request):
+ name = request.content['name']
+ values = request.content['values']
rrd = User._get_rrd(self.guid)
for timestamp, values in values:
rrd.put(name, values, timestamp)
@@ -122,6 +119,6 @@ def _load_pubkey(pubkey):
# Keep SSH key for further converting to PKCS8
pubkey_pkcs8 = pubkey
else:
- raise rd.Forbidden(message)
+ raise ad.Forbidden(message)
return str(hashlib.sha1(pubkey.split()[1]).hexdigest()), pubkey_pkcs8