[sagenb] 90/179: Make flask_version a submodule of sagenb
felix salfelder
felix-guest at moszumanska.debian.org
Tue May 6 12:05:13 UTC 2014
This is an automated email from the git hooks/post-receive script.
felix-guest pushed a commit to branch master
in repository sagenb.
commit be037b2e29459a16e35f571e8b2ac90cde4b9cc7
Author: R. Andrew Ohana <andrew.ohana at gmail.com>
Date: Tue Apr 2 18:17:21 2013 -0700
Make flask_version a submodule of sagenb
This is necessary to install sagenb as a standard python library
in site-packages.
---
flask_version/admin.py | 8 ++---
flask_version/authentication.py | 10 +++---
flask_version/base.py | 12 +++----
flask_version/doc.py | 4 +--
flask_version/settings.py | 2 +-
flask_version/worksheet.py | 64 +++++++++++++++++++-------------------
flask_version/worksheet_listing.py | 18 +++++------
sagenb/flask_version | 1 +
sagenb/notebook/run_notebook.py | 5 +--
setup.py | 1 +
10 files changed, 62 insertions(+), 63 deletions(-)
diff --git a/flask_version/admin.py b/flask_version/admin.py
index bf39556..36de5ef 100644
--- a/flask_version/admin.py
+++ b/flask_version/admin.py
@@ -4,7 +4,7 @@ from decorators import login_required, admin_required, with_lock
from flask.ext.babel import Babel, gettext, ngettext, lazy_gettext
_ = gettext
-admin = Module('flask_version.admin')
+admin = Module('sagenb.flask_version.admin')
@admin.route('/users')
@admin.route('/users/reset/<reset>')
@@ -104,18 +104,18 @@ def notebook_settings():
updated = {}
if 'form' in request.values:
updated = g.notebook.conf().update_from_form(request.values)
-
+
#Make changes to the default language used
if 'default_language' in request.values:
from flask.ext.babel import refresh
refresh()
current_app.config['BABEL_DEFAULT_LOCALE'] = request.values['default_language']
-
+
template_dict = {}
template_dict['auto_table'] = g.notebook.conf().html_table(updated)
template_dict['admin'] = g.notebook.user_manager().user(g.username).is_admin()
template_dict['username'] = g.username
-
+
return render_template(os.path.join('html', 'settings', 'notebook_settings.html'),
**template_dict)
diff --git a/flask_version/authentication.py b/flask_version/authentication.py
index 1c91295..1c1b991 100644
--- a/flask_version/authentication.py
+++ b/flask_version/authentication.py
@@ -5,7 +5,7 @@ from decorators import with_lock
from flask.ext.babel import gettext, ngettext, lazy_gettext
_ = gettext
-authentication = Module('flask_version.authentication')
+authentication = Module('sagenb.flask_version.authentication')
##################
# Authentication #
@@ -22,12 +22,12 @@ def login(template_dict={}):
from sagenb.misc.misc import SAGE_VERSION
template_dict.update({'accounts': g.notebook.user_manager().get_accounts(),
'recovery': g.notebook.conf()['email'],
- 'next': request.values.get('next', ''),
+ 'next': request.values.get('next', ''),
'sage_version': SAGE_VERSION,
'openid': g.notebook.conf()['openid'],
'username_error': False,
'password_error': False})
-
+
if request.method == 'POST':
username = request.form['email']
password = request.form['password']
@@ -56,7 +56,7 @@ def login(template_dict={}):
if U is None:
pass
- elif (is_valid_password(password, username) and
+ elif (is_valid_password(password, username) and
g.notebook.user_manager().check_password(username, password)):
if U.is_suspended():
#suspended
@@ -257,7 +257,7 @@ def confirm():
if not g.notebook.conf()['email']:
return current_app.message(_('The confirmation system is not active.'))
key = int(request.values.get('key', '-1'))
-
+
invalid_confirm_key = _("""\
<h1>Invalid confirmation key</h1>
<p>You are reporting a confirmation key that has not been assigned by this
diff --git a/flask_version/base.py b/flask_version/base.py
index 20a298a..c253a27 100755
--- a/flask_version/base.py
+++ b/flask_version/base.py
@@ -6,7 +6,7 @@ from decorators import login_required, guest_or_login_required, with_lock
from decorators import global_lock
from flask.ext.autoindex import AutoIndex
-SRC = os.path.join(os.environ['SAGE_ROOT'], 'devel', 'sage', 'sage')
+SRC = os.path.join(os.environ['SAGE_SRC'], 'sage')
from flask.ext.openid import OpenID
from flask.ext.babel import Babel, gettext, ngettext, lazy_gettext, get_locale
from sagenb.misc.misc import SAGENB_ROOT, DATA, SAGE_DOC, translations_path
@@ -84,7 +84,7 @@ class SageNBFlask(Flask):
return render_template(os.path.join('html', 'error_message.html'),
**template_dict)
-base = Module('flask_version.base')
+base = Module('sagenb.flask_version.base')
#############
# Main Page #
@@ -212,7 +212,7 @@ def help():
@base.route('/history')
@login_required
def history():
- return render_template(os.path.join('html', 'history.html'), username = g.username,
+ return render_template(os.path.join('html', 'history.html'), username = g.username,
text = g.notebook.user_history_text(g.username), actions = False)
@base.route('/live_history')
@@ -285,7 +285,7 @@ def set_profiles():
if show_challenge:
template_dict['challenge_html'] = chal.html()
- return render_template('html/accounts/openid_profile.html', resp=openid_resp,
+ return render_template('html/accounts/openid_profile.html', resp=openid_resp,
challenge=show_challenge, **template_dict)
else:
return redirect(url_for('base.index'))
@@ -329,7 +329,7 @@ def set_profiles():
parse_dict['email_invalid'] = True
raise ValueError
try:
- new_user = User(username, '', email = resp.email, account_type='user')
+ new_user = User(username, '', email = resp.email, account_type='user')
g.notebook.user_manager().add_user_object(new_user)
except ValueError:
parse_dict['creation_error'] = True
@@ -338,7 +338,7 @@ def set_profiles():
session['username'] = g.username = username
session.modified = True
except ValueError:
- return render_template('html/accounts/openid_profile.html', **parse_dict)
+ return render_template('html/accounts/openid_profile.html', **parse_dict)
return redirect(url_for('base.index'))
diff --git a/flask_version/doc.py b/flask_version/doc.py
index 830b437..a4c3938 100644
--- a/flask_version/doc.py
+++ b/flask_version/doc.py
@@ -17,9 +17,9 @@ import os
from flask import Module, url_for, render_template, request, session, redirect, g, current_app
from decorators import login_required, guest_or_login_required
-doc = Module('flask_version.doc')
+doc = Module('sagenb.flask_version.doc')
-from sagenb.misc.misc import SAGE_DOC
+from sagenb.misc.misc import SAGE_DOC
DOC = os.path.join(SAGE_DOC, 'output', 'html', 'en')
################
diff --git a/flask_version/settings.py b/flask_version/settings.py
index 00057d6..86d6c87 100644
--- a/flask_version/settings.py
+++ b/flask_version/settings.py
@@ -3,7 +3,7 @@ import random
from flask import Module, url_for, render_template, request, session, redirect, g, current_app
from decorators import login_required, with_lock
-settings = Module('flask_version.settings')
+settings = Module('sagenb.flask_version.settings')
@settings.route('/settings', methods = ['GET','POST'])
@login_required
diff --git a/flask_version/worksheet.py b/flask_version/worksheet.py
index 1ed4151..7b1fab2 100644
--- a/flask_version/worksheet.py
+++ b/flask_version/worksheet.py
@@ -9,13 +9,13 @@ _ = gettext
from sagenb.notebook.interact import INTERACT_UPDATE_PREFIX
from sagenb.notebook.misc import encode_response
-ws = Module('flask_version.worksheet')
+ws = Module('sagenb.flask_version.worksheet')
worksheet_locks = defaultdict(threading.Lock)
def worksheet_view(f):
"""
The `username` in the wrapper function is the username in the URL to the worksheet, which normally
- is the owner of the worksheet. Don't confuse this with `g.username`, the actual username of the
+ is the owner of the worksheet. Don't confuse this with `g.username`, the actual username of the
user looking at the worksheet.
"""
@login_required
@@ -26,7 +26,7 @@ def worksheet_view(f):
worksheet = kwds['worksheet'] = g.notebook.get_worksheet_with_filename(worksheet_filename)
except KeyError:
return current_app.message(_("You do not have permission to access this worksheet"))
-
+
with worksheet_locks[worksheet]:
owner = worksheet.owner()
@@ -58,7 +58,7 @@ def url_for_worksheet(worksheet):
def get_cell_id():
"""
Returns the cell ID from the request.
-
+
We cast the incoming cell ID to an integer, if it's possible.
Otherwise, we treat it as a string.
"""
@@ -103,7 +103,7 @@ readonly_commands_allowed = set(['alive', 'cells', 'data', 'datafile', 'download
def worksheet_command(target, **route_kwds):
if 'methods' not in route_kwds:
route_kwds['methods'] = ['GET', 'POST']
-
+
def decorator(f):
@ws.route('/home/<username>/<id>/' + target, **route_kwds)
@worksheet_view
@@ -130,7 +130,7 @@ def worksheet_command(target, **route_kwds):
worksheet = kwds.pop('worksheet', None)
if worksheet is not None:
args = (worksheet,) + args
-
+
return f(*args, **kwds)
#This function shares some functionality with url_for_worksheet.
@@ -141,10 +141,10 @@ def worksheet_command(target, **route_kwds):
return url_for(f.__name__, *args, **kwds)
wrapper.url_for = wc_url_for
-
+
return wrapper
return decorator
-
+
@worksheet_command('rename')
def worksheet_rename(worksheet):
@@ -194,7 +194,7 @@ def worksheet_save_snapshot(worksheet):
@worksheet_command('save_and_quit')
def worksheet_save_and_quit(worksheet):
- """Save a snapshot of a worksheet then quit it. """
+ """Save a snapshot of a worksheet then quit it. """
worksheet.save_snapshot(g.username)
worksheet.quit()
return 'saved'
@@ -266,7 +266,7 @@ def worksheet_new_cell_before(worksheet):
input = unicode_str(request.values.get('input', ''))
cell = worksheet.new_cell_before(id, input=input)
worksheet.increase_state_number()
-
+
r['new_id'] = cell.id()
r['new_html'] = cell.html(div_wrap=False)
@@ -280,7 +280,7 @@ def worksheet_new_text_cell_before(worksheet):
input = unicode_str(request.values.get('input', ''))
cell = worksheet.new_text_cell_before(id, input=input)
worksheet.increase_state_number()
-
+
r['new_id'] = cell.id()
r['new_html'] = cell.html(editing=True)
@@ -311,7 +311,7 @@ def worksheet_new_text_cell_after(worksheet):
input = unicode_str(request.values.get('input', ''))
cell = worksheet.new_text_cell_after(id, input=input)
worksheet.increase_state_number()
-
+
r['new_id'] = cell.id()
r['new_html'] = cell.html(editing=True)
@@ -369,9 +369,9 @@ def worksheet_eval(worksheet):
either introspection to the documentation of the function, or the
documentation of the function and the source code of the function
respectively.
- """
+ """
from base import notebook_updates
-
+
r = {}
r['id'] = id = get_cell_id()
@@ -429,7 +429,7 @@ def worksheet_eval(worksheet):
notebook_updates()
return encode_response(r)
-
+
@worksheet_command('cell_update')
def worksheet_cell_update(worksheet):
@@ -496,7 +496,7 @@ def worksheet_introspect(worksheet):
r['command'] = 'error'
r['message'] = 'Cannot evaluate public cell introspection.'
return encode_response(r)
-
+
before_cursor = request.values.get('before_cursor', '')
after_cursor = request.values.get('after_cursor', '')
cell = worksheet.get_cell_with_id(id)
@@ -513,7 +513,7 @@ def worksheet_edit(worksheet):
"""
Return a window that allows the user to edit the text of the
worksheet with the given filename.
- """
+ """
return g.notebook.html_edit_window(worksheet, g.username)
@@ -591,7 +591,7 @@ def worksheet_invite_collab(worksheet):
pass
return redirect(url_for_worksheet(worksheet))
-
+
########################################################
# Revisions
########################################################
@@ -599,7 +599,7 @@ def worksheet_invite_collab(worksheet):
def worksheet_revisions(worksheet):
"""
Show a list of revisions of this worksheet.
- """
+ """
if 'action' not in request.values:
if 'rev' in request.values:
return g.notebook.html_specific_revision(g.username, worksheet,
@@ -628,9 +628,9 @@ def worksheet_revisions(worksheet):
return current_app.message(_('Error'))
-
+
########################################################
-# Cell directories
+# Cell directories
########################################################
@worksheet_command('cells/<path:filename>')
def worksheet_cells(worksheet, filename):
@@ -649,7 +649,7 @@ def worksheet_data_legacy(worksheet, filename):
@worksheet_command('data/<path:filename>')
def worksheed_data_folder(worksheet,filename):
- # preferred way of accessing data
+ # preferred way of accessing data
return worksheet_data(worksheet, filename)
def worksheet_data(worksheet, filename):
@@ -684,7 +684,7 @@ def worksheet_savedatafile(worksheet):
os.unlink(dest)
open(dest, 'w').write(text_field)
return g.notebook.html_download_or_delete_datafile(worksheet, g.username, filename)
-
+
@worksheet_command('link_datafile')
def worksheet_link_datafile(worksheet):
@@ -702,10 +702,10 @@ def worksheet_link_datafile(worksheet):
os.link(src,target)
return redirect(worksheet_datafile.url_for(worksheet, name=data_filename))
#return redirect(url_for_worksheet(target_ws) + '/datafile?name=%s'%data_filename) #XXX: Can we not hardcode this?
-
+
@worksheet_command('upload_data')
def worksheet_upload_data(worksheet):
- return g.notebook.html_upload_data_window(worksheet, g.username)
+ return g.notebook.html_upload_data_window(worksheet, g.username)
@worksheet_command('do_upload_data')
def worksheet_do_upload_data(worksheet):
@@ -721,7 +721,7 @@ def worksheet_do_upload_data(worksheet):
return current_app.message(_('Error uploading file (missing field "file"). %(backlinks)s', backlinks=backlinks), worksheet_url)
else:
file = request.files['file']
-
+
text_fields = ['url', 'new', 'name']
for field in text_fields:
if field not in request.values:
@@ -775,8 +775,8 @@ def worksheet_do_upload_data(worksheet):
return response
else:
file.save(dest)
- return response
-
+ return response
+
################################
#Publishing
################################
@@ -828,7 +828,7 @@ def worksheet_publish(worksheet):
else:
return g.notebook.html_beforepublish_window(worksheet, g.username)
-############################################
+############################################
# Ratings
############################################
@worksheet_command('rating_info')
@@ -879,7 +879,7 @@ def unconditional_download(worksheet, title):
from flask.helpers import send_file
return send_file(filename, mimetype='application/sage')
-
+
@worksheet_command('restart_sage')
def worksheet_restart_sage(worksheet):
@@ -895,7 +895,7 @@ def worksheet_quit_sage(worksheet):
@worksheet_command('interrupt')
def worksheet_interrupt(worksheet):
- #XXX: TODO -- this must not block long (!)
+ #XXX: TODO -- this must not block long (!)
worksheet.sage().interrupt()
return 'failed' if worksheet.sage().is_computing() else 'success'
@@ -979,7 +979,7 @@ def worksheet_file(path):
# FIXME: For some reason, an extra cell gets added so we
# remove it here.
W.cell_list().pop()
-
+
return g.notebook.html(worksheet_filename=W.filename(),
username=g.username)
diff --git a/flask_version/worksheet_listing.py b/flask_version/worksheet_listing.py
index 90ae6f5..5ce705c 100644
--- a/flask_version/worksheet_listing.py
+++ b/flask_version/worksheet_listing.py
@@ -7,7 +7,7 @@ from decorators import login_required, guest_or_login_required, with_lock
from flask.ext.babel import Babel, gettext, ngettext, lazy_gettext
_ = gettext
-worksheet_listing = Module('flask_version.worksheet_listing')
+worksheet_listing = Module('sagenb.flask_version.worksheet_listing')
def render_worksheet_list(args, pub, username):
"""
@@ -28,10 +28,10 @@ def render_worksheet_list(args, pub, username):
a string
"""
-
+
from sagenb.notebook.notebook import sort_worksheet_list
from sagenb.misc.misc import unicode_str, SAGE_VERSION
-
+
typ = args['typ'] if 'typ' in args else 'active'
search = unicode_str(args['search']) if 'search' in args else None
sort = args['sort'] if 'sort' in args else 'last_edited'
@@ -78,7 +78,7 @@ def bare_home():
def get_worksheets_from_request():
U = g.notebook.user_manager().user(g.username)
-
+
if 'filename' in request.form:
filenames = [request.form['filename']]
elif 'filenames' in request.form:
@@ -90,8 +90,8 @@ def get_worksheets_from_request():
for filename in filenames:
W = g.notebook.get_worksheet_with_filename(filename)
if W.owner() != g.username:
- # TODO BUG: if trying to stop a shared worksheet, this check means that
- # only the owner can stop from the worksheet listing (using /send_to_stop), but any
+ # TODO BUG: if trying to stop a shared worksheet, this check means that
+ # only the owner can stop from the worksheet listing (using /send_to_stop), but any
# shared person can stop the worksheet by quitting it.
continue
worksheets.append(W)
@@ -134,7 +134,7 @@ def empty_trash():
return redirect(request.headers['referer'])
else:
return redirect(url_for('home', typ='trash'))
-
+
#####################
# Public Worksheets #
@@ -155,7 +155,7 @@ def public_worksheet(id):
except KeyError:
return _("Requested public worksheet does not exist"), 404
worksheet = pub_worksheet(original_worksheet)
-
+
owner = worksheet.owner()
worksheet.set_owner('pub')
s = g.notebook.html(worksheet_filename=worksheet.filename(),
@@ -192,7 +192,7 @@ def public_worksheet_cells(id, filename):
@login_required
def download_worksheets():
from sagenb.misc.misc import walltime, tmp_filename
-
+
t = walltime()
print "Starting zipping a group of worksheets in a separate thread..."
zip_filename = tmp_filename() + ".zip"
diff --git a/sagenb/flask_version b/sagenb/flask_version
new file mode 120000
index 0000000..19a98b0
--- /dev/null
+++ b/sagenb/flask_version
@@ -0,0 +1 @@
+../flask_version
\ No newline at end of file
diff --git a/sagenb/notebook/run_notebook.py b/sagenb/notebook/run_notebook.py
index 1617f6a..d288b1d 100644
--- a/sagenb/notebook/run_notebook.py
+++ b/sagenb/notebook/run_notebook.py
@@ -46,15 +46,12 @@ sagenb.notebook.misc.DIR = %(cwd)r #We should really get rid of this!
# Flask #
#########
import os, sys, random
-flask_dir = os.path.join(os.environ['SAGE_ROOT'], 'devel', 'sagenb', 'flask_version')
-sys.path.append(flask_dir)
-import base as flask_base
+import sagenb.flask_version.base as flask_base
opts={}
startup_token = '{0:x}'.format(random.randint(0, 2**128))
if %(automatic_login)s:
opts['startup_token'] = startup_token
flask_app = flask_base.create_app(%(notebook_opts)s, **opts)
-sys.path.remove(flask_dir)
def save_notebook(notebook):
print "Quitting all running worksheets..."
diff --git a/setup.py b/setup.py
index 5f99e20..9a59566 100644
--- a/setup.py
+++ b/setup.py
@@ -52,6 +52,7 @@ if __name__ == '__main__':
install_requires = install_requires,
test_suite = 'sagenb.testing.run_tests.all_tests',
packages = [ 'sagenb'
+ , 'sagenb.flask_version'
, 'sagenb.interfaces'
, 'sagenb.misc'
, 'sagenb.notebook'
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/debian-science/packages/sagenb.git
More information about the debian-science-commits
mailing list