diff options
author | Sebastian Silva <sebastian@somosazucar.org> | 2013-10-04 10:05:15 (GMT) |
---|---|---|
committer | Sebastian Silva <sebastian@somosazucar.org> | 2013-10-04 10:05:15 (GMT) |
commit | e9688a0991bd8764b9228344cbaa90ff33047e8a (patch) | |
tree | a5ef4eb8df34d34623a1c89533e0e4f9e8904d0d | |
parent | 3261bfd64f5c61394deb73e536d62f30e514fe9b (diff) |
revert "Changes to support backend polish by alsroot"
-rw-r--r-- | sugar_network_webui/app.py | 13 | ||||
-rw-r--r-- | sugar_network_webui/client.py | 35 | ||||
-rw-r--r-- | sugar_network_webui/cursors.py | 20 | ||||
-rw-r--r-- | sugar_network_webui/objects.py | 1 | ||||
-rw-r--r-- | sugar_network_webui/templates/_browser-grid.html | 4 | ||||
-rw-r--r-- | sugar_network_webui/templates/_review-list.html | 2 | ||||
-rw-r--r-- | sugar_network_webui/templates/context-view.html | 4 |
7 files changed, 50 insertions, 29 deletions
diff --git a/sugar_network_webui/app.py b/sugar_network_webui/app.py index 16e47f3..29d1651 100644 --- a/sugar_network_webui/app.py +++ b/sugar_network_webui/app.py @@ -236,7 +236,8 @@ def moon(context=None): clone = request.args.get('clone', None) guid = context[5:] # remove "moon-" from id - Client.call('PUT', ['context', guid], 'clone', clone == 'true', spawn=True) + Client.call('PUT', ['context', guid], 'clone', + content=1 if clone == 'true' else 0) return jsonify(clone=clone) @@ -290,7 +291,7 @@ def new_resource(context_guid=None): context = g.Contexts[offset] else: context = g.client.Context(context_guid, - reply=['title', 'layer']) + reply=['title', 'favorite', 'clone']) return render_template('resource-form.html', context=context) @@ -617,7 +618,7 @@ def project_browser(context_guid=None): template = 'context-view.html' context = g.client.Context(context_guid, reply=['guid', 'title', 'description', 'author', - 'summary', 'layer', 'type']) + 'summary', 'favorite', 'clone', 'type']) try: session['last_context_title'] = context['title'] except NotFound: @@ -664,7 +665,7 @@ def reviews_browser(resource_guid=None, review_guid=None): template = 'context-view.html' context = g.client.Context(resource_guid, reply=['guid', 'title', 'description', 'author', - 'summary', 'layer', 'type']) + 'summary', 'favorite', 'clone', 'type']) try: session['last_context_title'] = context['title'] except NotFound: @@ -710,7 +711,7 @@ def solution_browser(resource_guid=None): try: context = g.client.Context(resource['context'], reply=['guid', 'title', 'description', 'summary', 'author', - 'layer', 'type']) + 'favorite', 'clone', 'type']) except: return redirect(url_for('resource_list')) @@ -771,7 +772,7 @@ def context_resource_browser(context_guid=None, query=None): context = resource_cursor[offset] else: context = g.client.Context(context_guid, reply=['guid', 'title', - 'author', 'summary', 'description', 'layer', 'type']) + 'author', 'summary', 'description', 'favorite', 'clone', 'type']) try: session['last_context'] = context['guid'] session['last_context_title'] = context['title'] diff --git a/sugar_network_webui/client.py b/sugar_network_webui/client.py index edb1da2..88992dd 100644 --- a/sugar_network_webui/client.py +++ b/sugar_network_webui/client.py @@ -13,8 +13,8 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. +import json import logging -from urllib import urlencode from sugar_network.toolkit import coroutine @@ -37,11 +37,8 @@ class Client(object): _pull = None @classmethod - def call(cls, method, path, cmd=None, content=None, - content_type='application/json', - **kwargs): - return _call(method=method, path=path, cmd=cmd, content=content, - content_type=content_type, **kwargs) + def call(cls, *args, **kwargs): + return _call(*args, **kwargs) @classmethod def connect(cls, callback, **condition): @@ -57,6 +54,7 @@ class Client(object): @classmethod def _pull_events(cls): for event in Client.call('GET', [], 'subscribe'): + event = json.loads(event[6:]) for callback, condition in cls._subscriptions.items(): for key, value in condition.items(): if event.get(key) != value: @@ -74,8 +72,29 @@ class Client(object): def inline(self): return self.call('GET', [], 'inline') or Client.anonymous - def launch(self, context, **kwargs): - return self.call('GET', ['context', context], 'launch', spawn=True, **kwargs) + def launch(self, context, command='activity', object_id=None, uri=None, + args=None): + """Launch context implementation. + + Function will call fork at the beginning. In forked process, + it will try to choose proper implementation to execute and launch it. + + Execution log will be stored in `~/.sugar/PROFILE/logs` directory. + + :param context: + context GUID to look for implementations + :param command: + command that selected implementation should support + :param object_id: + optional id to restore Journal object + :param uri: + optional uri to open; if implementation supports it + :param args: + optional list of arguments to pass to launching implementation + + """ + return self.call('GET', ['context', context], 'launch', + object_id=object_id, uri=uri, args=args) def __getattr__(self, name): """Class-like object to access to a resource or call a method. diff --git a/sugar_network_webui/cursors.py b/sugar_network_webui/cursors.py index f129188..52462b8 100644 --- a/sugar_network_webui/cursors.py +++ b/sugar_network_webui/cursors.py @@ -25,36 +25,36 @@ class Mount: self.Contexts = self.client.Context.cursor( type=["activity", "project"], reply=['guid', 'type', 'title', 'author', 'summary', - 'description', 'layer', 'mtime'], + 'description', 'favorite', 'clone', 'mtime'], order_by='-mtime') self.autocomplete_Contexts = self.client.Context.cursor( reply=['guid', 'title'], order_by='-mtime') self.Projects = self.client.Context.cursor(type='project', reply=['guid', 'type', 'title', 'author', 'summary', - 'description', 'layer', 'mtime'], + 'description', 'favorite', 'clone', 'mtime'], order_by='-mtime') self.Activities = self.client.Context.cursor(type='activity', reply=['guid', 'type', 'title', 'author', 'summary', - 'description', 'layer', 'mtime'], + 'description', 'favorite', 'clone', 'mtime'], order_by='-mtime') else: self.Contexts = self.client.Context.cursor( - layer='clone', + clone=clone, reply=['guid', 'type', 'title', 'author', 'summary', - 'description', 'layer', 'mtime'], + 'description', 'favorite', 'clone', 'mtime'], order_by='-mtime') self.autocomplete_Contexts = self.client.Context.cursor( - layer='clone', + clone=clone, reply=['guid', 'title'], order_by='-mtime') self.Projects = self.client.Context.cursor(type='project', reply=['guid', 'type', 'title', 'author', 'summary', - 'description', 'layer', 'mtime'], + 'description', 'favorite', 'clone', 'mtime'], order_by='-mtime') self.Activities = self.client.Context.cursor(type='activity', - layer='clone', + clone=clone, reply=['guid', 'type', 'title', 'author', 'summary', - 'description', 'layer', 'mtime'], + 'description', 'favorite', 'clone', 'mtime'], order_by='-mtime') self.Questions = self.client.Feedback.cursor(type="question", @@ -85,4 +85,4 @@ class Mount: network_mount = Mount() -home_mount = Mount(True) +home_mount = Mount(clone=2) diff --git a/sugar_network_webui/objects.py b/sugar_network_webui/objects.py index 62c971d..83186d6 100644 --- a/sugar_network_webui/objects.py +++ b/sugar_network_webui/objects.py @@ -17,6 +17,7 @@ import logging from cStringIO import StringIO from os.path import isdir, abspath +from sugar_network import client from sugar_network.toolkit import enforce from client import Client diff --git a/sugar_network_webui/templates/_browser-grid.html b/sugar_network_webui/templates/_browser-grid.html index 2f2a63b..987f156 100644 --- a/sugar_network_webui/templates/_browser-grid.html +++ b/sugar_network_webui/templates/_browser-grid.html @@ -33,14 +33,14 @@ <div class="context-label"> <span class="context-controls"> <img title="{{_('available offline')}}" id="moon-{{context['guid']}}" - {% if 'clone' in context['layer'] %} + {% if context['clone'] %} style="background-color:{{fill}}; border: 1px solid {{stroke}};" data-clone="true" {% endif %} class="moon-emblem has_tooltip" src="/static/icons/moon.png"/> <img title="{{_('favorite')}}" id="star-{{context['guid']}}" - {% if 'favorite' in context['layer'] %} + {% if context['favorite'] %} style="background-color:{{fill}}; border: 1px solid {{stroke}};" data-favorite="true" {% endif %} diff --git a/sugar_network_webui/templates/_review-list.html b/sugar_network_webui/templates/_review-list.html index 2f597ca..fb3459b 100644 --- a/sugar_network_webui/templates/_review-list.html +++ b/sugar_network_webui/templates/_review-list.html @@ -40,7 +40,7 @@ </div> <!-- <div class="icon-column"> - %- if 'favorite' in item['layer'] % + %- if item['favorite'] % <img class="star" src="/static/icons/emblem-favorite.png"/> %- else % <img class="star" src="/static/icons/add-link.png"/> diff --git a/sugar_network_webui/templates/context-view.html b/sugar_network_webui/templates/context-view.html index 8a1ba7b..2986572 100644 --- a/sugar_network_webui/templates/context-view.html +++ b/sugar_network_webui/templates/context-view.html @@ -52,14 +52,14 @@ <span class="context-controls"> <img id="moon-{{context['guid']}}" title="{{_('available offline')}}" - {% if 'clone' in context['layer'] %} + {% if context['clone'] %} style="background-color:{{fill}}; border: 1px solid {{stroke}};" data-clone="true" {% endif %} class="moon-emblem has_tooltip" src="/static/icons/moon.png"/> <img id="star-{{context['guid']}}" title="{{_('favorite')}}" - {% if 'favorite' in context['layer'] %} + {% if context['favorite'] %} style="background-color:{{fill}}; border: 1px solid {{stroke}};" data-favorite="true" {% endif %} |