Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSebastian Silva <sebastian@somosazucar.org>2013-11-19 09:22:02 (GMT)
committer Sebastian Silva <sebastian@somosazucar.org>2013-11-19 09:22:02 (GMT)
commited544cecc6ba9c3e7a70d331ad45c8646aa97e7f (patch)
treee5fe2683542fdd573271426b28fac3dd8f415abb
parentce809f48f405475deebf007030e6defed5bd293e (diff)
Try to decouple webui
-rwxr-xr-xrunserver.py (renamed from red-azucar.py)47
-rw-r--r--sugar_network_webui/app.py1
2 files changed, 27 insertions, 21 deletions
diff --git a/red-azucar.py b/runserver.py
index 3a03b57..7fc926a 100755
--- a/red-azucar.py
+++ b/runserver.py
@@ -21,33 +21,42 @@ from os.path import dirname, join, realpath
from gettext import gettext as _
from gevent.wsgi import WSGIServer
-from sugar_network import sugar
-
+from sugar_network import client
+from sugar_network.toolkit.http import Connection
+from sugar_network.toolkit import application,Option
+from sugar_network_webui import get_app
SRC_ROOT = dirname(realpath(__file__))
-host = optparse.Option(
- _('address to listen for Web clients'),
+host = optparse.Option("-h", "--host", type="string",
+ help=_('address to listen for Web clients'),
default='127.0.0.1')
-port = optparse.Option(
- _('address to listen for Web clients'),
+port = optparse.Option("-p", "--port", type="int",
+ help=_('address to listen for Web clients'),
default=5000)
+api_url = optparse.Option("-a", "--api_url", type="string",
+ help=_('address of node server to connect to'),
+ default='http://node-devel.sugarlabs.org/')
+
+anonymous = optparse.Option("--anonymous", action="store_true",
+ help=_('connect as anonymous user'),
+ default=False)
class Application(application.Daemon):
httpd = None
def start(self):
- application.logdir.value = sugar.profile_path('logs')
- application.rundir.value = sugar.profile_path('run')
+ application.logdir.value = client.profile_path('logs')
+ application.rundir.value = client.profile_path('run')
application.Daemon.start(self)
def run(self):
app = self._get_app()
- self.httpd = WSGIServer((host.value, port.value), app)
+ self.httpd = WSGIServer((host.default, port.default), app)
self.httpd.serve_forever()
def shutdown(self):
@@ -58,21 +67,17 @@ class Application(application.Daemon):
def debug(self):
app = self._get_app()
app.debug = True
- app.run(host=host.value, port=port.value)
+ app.run(host=host.default, port=port.default)
def _get_app(self):
- try:
- from mejorar_sistema.app import app
- except ImportError:
- # Reuse from sources diretory
- sys.path.insert(0, join(SRC_ROOT, 'app'))
- from app import app
- return app
+ self.connection = Connection(api_url)
+ return get_app(self.connection.call,
+ api_url, anonymous)
-optparse.Option.seek('mejorar-sistema')
-optparse.Option.seek('mejorar-sistema',
- [application.debug, application.foreground])
+Option.seek('mejorar-sistema')
+Option.seek('mejorar-sistema',
+ [application.debug, application.foreground])
app = Application(
name='mejorar-sistema',
@@ -82,6 +87,6 @@ app = Application(
config_files=[
'/etc/sweets.conf',
'~/.config/sweets/config',
- sugar.profile_path('sweets.conf'),
+ client.profile_path('sweets.conf'),
])
app.start()
diff --git a/sugar_network_webui/app.py b/sugar_network_webui/app.py
index 6d46394..2e45374 100644
--- a/sugar_network_webui/app.py
+++ b/sugar_network_webui/app.py
@@ -637,6 +637,7 @@ def project_browser(context_guid=None):
@app.route('/reload/<path:href>')
def reload(href=None):
+ g.Artifacts._reset()
g.Solutions._reset()
g.Comments._reset()
g.Contexts._reset()