Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAleksey Lim <alsroot@sugarlabs.org>2013-08-12 23:52:59 (GMT)
committer Aleksey Lim <alsroot@sugarlabs.org>2013-08-13 00:46:57 (GMT)
commitd343478684062dc458b49710a5deac94ece11221 (patch)
tree4fa5d13b46a5e4f0d2d44f576f167e0ddd30223f
parenta46d4a6c8eb72514b9537d1ad56d6e1f7bd36039 (diff)
Revert default reply list for GET /resource/guid request
-rwxr-xr-xsugar-network50
-rw-r--r--sugar_network/db/routes.py7
2 files changed, 29 insertions, 28 deletions
diff --git a/sugar-network b/sugar-network
index 7c71936..99a5e1c 100755
--- a/sugar-network
+++ b/sugar-network
@@ -203,7 +203,7 @@ class Application(application.Application):
self._parse_path(request)
self._parse_args(request)
result = self._connect().meta(request.path, request.query)
- self._dump(result, [])
+ self._dump(result)
@application.command(hidden=True)
def HEAD(self):
@@ -269,7 +269,7 @@ class Application(application.Application):
return
if response.content_type == 'application/json':
- self._dump(result, reply.get('reply') or ['guid'])
+ self._dump(result)
elif response.content_type == 'text/event-stream':
while True:
chunk = toolkit.readline(result)
@@ -312,35 +312,35 @@ class Application(application.Application):
else:
props[arg] = value
- def _dump(self, result, reply):
+ def _dump(self, result):
+ if not porcelain.value:
+ print dumps(result, indent=2, ensure_ascii=False)
+ return
def porcelain_dump(value):
- if type(value) not in (list, tuple):
- value = [value]
- for n, i in enumerate(value):
- if n:
- print '\t',
- if type(i) is dict and len(i) == 1:
- i = i.values()[0]
- print i,
+ if type(value) is dict:
+ for i in value.items():
+ print '%-18s%s' % i
+ else:
+ if type(value) not in (list, tuple):
+ value = [value]
+ for n, i in enumerate(value):
+ if n:
+ print '\t',
+ if type(i) is dict and len(i) == 1:
+ i = i.values()[0]
+ print i,
print ''
- if porcelain.value:
- if type(result) in (list, tuple):
- for i in result:
- porcelain_dump(i)
- elif type(result) is dict and \
- 'total' in result and 'result' in result:
- for i in result['result']:
- porcelain_dump(i)
- else:
+ if type(result) in (list, tuple):
+ for i in result:
+ porcelain_dump(i)
+ elif type(result) is dict and \
+ 'total' in result and 'result' in result:
+ for i in result['result']:
porcelain_dump(i)
- elif reply:
- for key in reply:
- key = _ESCAPE_VALUE_RE.sub("'\\1'", key)
- print eval('result%s' % key)
else:
- print dumps(result, indent=2, ensure_ascii=False)
+ porcelain_dump(result)
# Let toolkit.http work in concurrence
diff --git a/sugar_network/db/routes.py b/sugar_network/db/routes.py
index 5706587..a796834 100644
--- a/sugar_network/db/routes.py
+++ b/sugar_network/db/routes.py
@@ -94,13 +94,14 @@ class Routes(object):
def delete(self, request):
self.volume[request.resource].delete(request.guid)
- @route('GET', [None, None], arguments={'reply': ('guid',)},
+ @route('GET', [None, None], arguments={'reply': list},
mime_type='application/json')
def get(self, request, reply):
if not reply:
reply = []
for prop in self.volume[request.resource].metadata.values():
- if prop.acl & ACL.READ and not (prop.acl & ACL.LOCAL):
+ if isinstance(prop, StoredProperty) and \
+ prop.acl & ACL.READ and not (prop.acl & ACL.LOCAL):
reply.append(prop.name)
self._preget(request)
doc = self.volume[request.resource].get(request.guid)
@@ -256,7 +257,7 @@ class Routes(object):
self.after_post(doc)
def _preget(self, request):
- reply = request['reply']
+ reply = request.get('reply')
if not reply:
request['reply'] = ('guid',)
else: