1 new commit in galaxy-central:
https://bitbucket.org/galaxy/galaxy-central/commits/1829e8c8f8bb/
Changeset: 1829e8c8f8bb
User: carlfeberhard
Date: 2013-04-05 02:08:58
Summary: controllers/root: remove methods my_data, dataset_state, dataset_code; add documentation; clean imports
Affected #: 1 file
diff -r a64e43d6d4d52f17b53a4ceac07d48105defdc9c -r 1829e8c8f8bb632b8fd1c9224dd3da6849246568 lib/galaxy/webapps/galaxy/controllers/root.py
--- a/lib/galaxy/webapps/galaxy/controllers/root.py
+++ b/lib/galaxy/webapps/galaxy/controllers/root.py
@@ -3,25 +3,30 @@
"""
import os
import urllib
-from cgi import escape, FieldStorage
+import cgi
-from galaxy import util, datatypes, jobs, web, util
-from galaxy.web.base.controller import *
+from galaxy.web.base.controller import BaseUIController, UsesHistoryMixin, UsesHistoryDatasetAssociationMixin
+from galaxy.model.item_attrs import UsesAnnotations
+from galaxy import util, web
from galaxy.util.sanitize_html import sanitize_html
-from galaxy.model.orm import *
-from galaxy.model.item_attrs import UsesAnnotations
+#from galaxy.model.orm import *
import logging
log = logging.getLogger( __name__ )
class RootController( BaseUIController, UsesHistoryMixin, UsesHistoryDatasetAssociationMixin, UsesAnnotations ):
+ """Controller class that maps to the url root of Galaxy (i.e. '/')."""
@web.expose
def default(self, trans, target1=None, target2=None, **kwd):
+ """Called on any url that does not match a controller method.
+ """
return 'This link may not be followed from within Galaxy.'
@web.expose
def index(self, trans, id=None, tool_id=None, mode=None, workflow_id=None, m_c=None, m_a=None, **kwd):
+ """Called on the root url to display the main Galaxy page.
+ """
return trans.fill_template( "root/index.mako",
tool_id=tool_id,
workflow_id=workflow_id,
@@ -31,6 +36,8 @@
## ---- Tool related -----------------------------------------------------
@web.expose
def tool_menu( self, trans ):
+ """Renders the tool panel of the Galaxy UI.
+ """
if trans.app.config.require_login and not trans.user:
return trans.fill_template( '/no_access.mako', message='Please log in to access Galaxy tools.' )
toolbox = self.get_toolbox()
@@ -51,6 +58,11 @@
@web.json
def tool_search( self, trans, **kwd ):
+ """Searches the tool database and returns data for any tool
+ whose text matches the query.
+
+ Data are returned in JSON format.
+ """
query = kwd.get( 'query', '' )
tags = util.listify( kwd.get( 'tags[]', [] ) )
trans.log_action( trans.get_user(), "tool_search.search", "", { "query" : query, "tags" : tags } )
@@ -77,11 +89,13 @@
@web.expose
def tool_help( self, trans, id ):
- """Return help page for tool identified by 'id' if available"""
+ """Return help page for tool identified by 'id' if available
+ """
toolbox = self.get_toolbox()
tool = toolbox.get_tool( id )
yield "<html><body>"
if not tool:
+ #TODO: arent tool ids strings now?
yield "Unknown tool id '%d'" % id
elif tool.help:
yield tool.help
@@ -91,13 +105,6 @@
## ---- Root history display ---------------------------------------------
@web.expose
- def my_data( self, trans, **kwd ):
- """
- Display user's data.
- """
- return trans.fill_template_mako( "/my_data.mako" )
-
- @web.expose
def history( self, trans, as_xml=False, show_deleted=None, show_hidden=None, hda_id=None, **kwd ):
"""Display the current history, creating a new history if necessary.
@@ -167,38 +174,13 @@
## ---- Dataset display / editing ----------------------------------------
@web.expose
- def dataset_state ( self, trans, id=None, stamp=None ):
- if id is not None:
- try:
- data = trans.sa_session.query( self.app.model.HistoryDatasetAssociation ).get( id )
- except:
- return trans.show_error_message( "Unable to check dataset %s." %str( id ) )
- trans.response.headers['X-Dataset-State'] = data.state
- trans.response.headers['Pragma'] = 'no-cache'
- trans.response.headers['Expires'] = '0'
- return data.state
- else:
- return trans.show_error_message( "Must specify a dataset id.")
+ def display( self, trans, id=None, hid=None, tofile=None, toext=".txt", **kwd ):
+ """Returns data directly into the browser.
- @web.expose
- def dataset_code( self, trans, id=None, hid=None, stamp=None ):
- if id is not None:
- try:
- data = trans.sa_session.query( self.app.model.HistoryDatasetAssociation ).get( id )
- except:
- return trans.show_error_message( "Unable to check dataset %s." %str( id ) )
- trans.response.headers['Pragma'] = 'no-cache'
- trans.response.headers['Expires'] = '0'
- return trans.fill_template("root/history_item.mako", data=data, hid=hid)
- else:
- return trans.show_error_message( "Must specify a dataset id.")
-
- @web.expose
- def display( self, trans, id=None, hid=None, tofile=None, toext=".txt", **kwd ):
+ Sets the mime-type according to the extension.
"""
- Returns data directly into the browser.
- Sets the mime-type according to the extension
- """
+ #TODO: unused?
+ #TODO: unencoded id
if hid is not None:
try:
hid = int( hid )
@@ -241,9 +223,9 @@
@web.expose
def display_child(self, trans, parent_id=None, designation=None, tofile=None, toext=".txt"):
+ """Returns child data directly into the browser, based upon parent_id and designation.
"""
- Returns child data directly into the browser, based upon parent_id and designation.
- """
+ #TODO: unencoded id
try:
data = trans.sa_session.query( self.app.model.HistoryDatasetAssociation ).get( parent_id )
if data:
@@ -260,7 +242,9 @@
@web.expose
def display_as( self, trans, id=None, display_app=None, **kwd ):
- """Returns a file in a format that can successfully be displayed in display_app"""
+ """Returns a file in a format that can successfully be displayed in display_app.
+ """
+ #TODO: unencoded id
data = trans.sa_session.query( self.app.model.HistoryDatasetAssociation ).get( id )
authz_method = 'rbac'
if 'authz_method' in kwd:
@@ -283,7 +267,10 @@
@web.expose
def peek(self, trans, id=None):
- """Returns a 'peek' at the data"""
+ """Returns a 'peek' at the data.
+ """
+ #TODO: unused?
+ #TODO: unencoded id
data = trans.sa_session.query( self.app.model.HistoryDatasetAssociation ).get( id )
if data:
yield "<html><body><pre>"
@@ -295,20 +282,23 @@
## ---- History management -----------------------------------------------
@web.expose
def history_options( self, trans ):
- """Displays a list of history related actions"""
+ """Displays a list of history related actions.
+ """
return trans.fill_template( "/history/options.mako",
user=trans.get_user(),
history=trans.get_history( create=True ) )
@web.expose
def history_delete( self, trans, id ):
+ """Backward compatibility with check_galaxy script.
"""
- Backward compatibility with check_galaxy script.
- """
+ #TODO: unused?
return trans.webapp.controllers['history'].list( trans, id, operation='delete' )
@web.expose
def clear_history( self, trans ):
- """Clears the history for a user"""
+ """Clears the history for a user.
+ """
+ #TODO: unused? (seems to only be used in TwillTestCase)
history = trans.get_history()
for dataset in history.datasets:
dataset.deleted = True
@@ -319,6 +309,8 @@
@web.expose
def history_import( self, trans, id=None, confirm=False, **kwd ):
+ #TODO: unused?
+ #TODO: unencoded id
msg = ""
user = trans.get_user()
user_history = trans.get_history()
@@ -375,13 +367,19 @@
@web.expose
def history_new( self, trans, name=None ):
+ """Create a new history with the given name
+ and refresh the history panel.
+ """
trans.new_history( name=name )
trans.log_event( "Created new History, id: %s." % str(trans.history.id) )
return trans.show_message( "New history created", refresh_frames=['history'] )
@web.expose
- def history_add_to( self, trans, history_id=None, file_data=None, name="Data Added to History", info=None, ext="txt", dbkey="?", copy_access_from=None, **kwd ):
- """Adds a POSTed file to a History"""
+ def history_add_to( self, trans, history_id=None, file_data=None,
+ name="Data Added to History", info=None, ext="txt", dbkey="?", copy_access_from=None, **kwd ):
+ """Adds a POSTed file to a History.
+ """
+ #TODO: unencoded id
try:
history = trans.sa_session.query( trans.app.model.History ).get( history_id )
data = trans.app.model.HistoryDatasetAssociation( name=name,
@@ -414,12 +412,16 @@
trans.log_event("Added dataset %d to history %d" % (data.id, trans.history.id))
return trans.show_ok_message( "Dataset " + str(data.hid) + " added to history " + str(history_id) + "." )
except Exception, e:
- trans.log_event( "Failed to add dataset to history: %s" % ( e ) )
+ msg = "Failed to add dataset to history: %s" % ( e )
+ log.error( msg )
+ trans.log_event( msg )
return trans.show_error_message("Adding File to History has Failed")
@web.expose
def history_set_default_permissions( self, trans, id=None, **kwd ):
- """Sets the permissions on a history"""
+ """Sets the permissions on a history.
+ """
+ #TODO: unencoded id
if trans.user:
if 'update_roles_button' in kwd:
history = None
@@ -443,7 +445,8 @@
permissions[ trans.app.security_agent.get_action( v.action ) ] = in_roles
dataset = 'dataset' in kwd
bypass_manage_permission = 'bypass_manage_permission' in kwd
- trans.app.security_agent.history_set_default_permissions( history, permissions, dataset=dataset, bypass_manage_permission=bypass_manage_permission )
+ trans.app.security_agent.history_set_default_permissions( history, permissions,
+ dataset=dataset, bypass_manage_permission=bypass_manage_permission )
return trans.show_ok_message( 'Default history permissions have been changed.' )
return trans.fill_template( 'history/permissions.mako' )
else:
@@ -452,7 +455,10 @@
@web.expose
def dataset_make_primary( self, trans, id=None):
- """Copies a dataset and makes primary"""
+ """Copies a dataset and makes primary.
+ """
+ #TODO: unused?
+ #TODO: unencoded id
try:
old_data = trans.sa_session.query( self.app.model.HistoryDatasetAssociation ).get( id )
new_data = old_data.copy()
@@ -477,23 +483,25 @@
# ---- Debug methods ----------------------------------------------------
@web.expose
def echo(self, trans, **kwd):
- """Echos parameters (debugging)"""
+ """Echos parameters (debugging).
+ """
rval = ""
for k in trans.request.headers:
rval += "%s: %s <br/>" % ( k, trans.request.headers[k] )
for k in kwd:
rval += "%s: %s <br/>" % ( k, kwd[k] )
- if isinstance( kwd[k], FieldStorage ):
+ if isinstance( kwd[k], cgi.FieldStorage ):
rval += "-> %s" % kwd[k].file.read()
return rval
@web.json
def echo_json( self, trans, **kwd ):
- """Echos parameters as JSON (debugging)
+ """Echos parameters as JSON (debugging).
Attempts to parse values passed as boolean, float, then int. Defaults
to string. Non-recursive (will not parse lists).
"""
+ #TODO: use simplejson or json
rval = {}
for k in kwd:
rval[ k ] = kwd[k]
@@ -508,4 +516,6 @@
@web.expose
def generate_error( self, trans ):
+ """Raises an exception (debugging).
+ """
raise Exception( "Fake error!" )
Repository URL: https://bitbucket.org/galaxy/galaxy-central/
--
This is a commit notification from bitbucket.org. You are receiving
this because you have the service enabled, addressing the recipient of
this email.
1 new commit in galaxy-central:
https://bitbucket.org/galaxy/galaxy-central/commits/beb6f6acb91a/
Changeset: beb6f6acb91a
Branch: stable
User: dannon
Date: 2013-04-04 21:34:43
Summary: Fix for incorrect template inheritance causing the tool shed base_panels to be displayed in the galaxy app upon logout.
Mako's inherit directives are processed *before* non-global logic, so you need a built-in switch (as implemented, now) or, ideally, refactor into different templates for each webapp that inherit correctly.
Affected #: 1 file
diff -r dcdf81ee5f8f1dfee442ccb4c121048610d8f7f5 -r beb6f6acb91a738901993c0d4a28f48be40989f5 templates/user/logout.mako
--- a/templates/user/logout.mako
+++ b/templates/user/logout.mako
@@ -1,8 +1,15 @@
-%if trans.webapp.name == 'galaxy':
- <%inherit file="/webapps/galaxy/base_panels.mako"/>
-%elif trans.webapp.name == 'tool_shed':
- <%inherit file="/webapps/tool_shed/base_panels.mako"/>
-%endif
+<%!
+#This is a hack, we should restructure templates to avoid this.
+def inherit(context):
+ if context.get('trans').webapp.name == 'galaxy':
+ return '/webapps/galaxy/base_panels.mako'
+ elif context.get('trans').webapp.name == 'tool_shed':
+ return '/webapps/tool_shed/base_panels.mako'
+ else:
+ return '/base.mako'
+%>
+
+<%inherit file="${inherit(context)}"/><%namespace file="/message.mako" import="render_msg" />
@@ -35,4 +42,4 @@
%if message:
${render_msg( message, status )}
%endif
-</%def>
\ No newline at end of file
+</%def>
Repository URL: https://bitbucket.org/galaxy/galaxy-central/
--
This is a commit notification from bitbucket.org. You are receiving
this because you have the service enabled, addressing the recipient of
this email.
1 new commit in galaxy-central:
https://bitbucket.org/galaxy/galaxy-central/commits/b21189736eb5/
Changeset: b21189736eb5
User: dannon
Date: 2013-04-04 21:34:43
Summary: Fix for incorrect template inheritance causing the tool shed base_panels to be displayed in the galaxy app upon logout.
Mako's inherit directives are processed *before* non-global logic, so you need a built-in switch (as implemented, now) or, ideally, refactor into different templates for each webapp that inherit correctly.
Affected #: 1 file
diff -r d9d824177f5dff29b6dd1d639796c9396ee1060e -r b21189736eb5f5b7e1a57bf02f8bc0ab1359fef5 templates/user/logout.mako
--- a/templates/user/logout.mako
+++ b/templates/user/logout.mako
@@ -1,8 +1,15 @@
-%if trans.webapp.name == 'galaxy':
- <%inherit file="/webapps/galaxy/base_panels.mako"/>
-%elif trans.webapp.name == 'tool_shed':
- <%inherit file="/webapps/tool_shed/base_panels.mako"/>
-%endif
+<%!
+#This is a hack, we should restructure templates to avoid this.
+def inherit(context):
+ if context.get('trans').webapp.name == 'galaxy':
+ return '/webapps/galaxy/base_panels.mako'
+ elif context.get('trans').webapp.name == 'tool_shed':
+ return '/webapps/tool_shed/base_panels.mako'
+ else:
+ return '/base.mako'
+%>
+
+<%inherit file="${inherit(context)}"/><%namespace file="/message.mako" import="render_msg" />
@@ -35,4 +42,4 @@
%if message:
${render_msg( message, status )}
%endif
-</%def>
\ No newline at end of file
+</%def>
Repository URL: https://bitbucket.org/galaxy/galaxy-central/
--
This is a commit notification from bitbucket.org. You are receiving
this because you have the service enabled, addressing the recipient of
this email.
1 new commit in galaxy-central:
https://bitbucket.org/galaxy/galaxy-central/commits/bd6f6d645762/
Changeset: bd6f6d645762
User: greg
Date: 2013-04-04 17:59:18
Summary: Better handling for mercurial command line pushes to tool shed repositories when invalid credentials are sent.
Affected #: 1 file
diff -r c7bd5efd3e3140a1ad0de22bf3a02e4ef8e4a948 -r bd6f6d6457624d8c59f7d821b6a478e81d70b558 lib/galaxy/webapps/tool_shed/framework/middleware/hg.py
--- a/lib/galaxy/webapps/tool_shed/framework/middleware/hg.py
+++ b/lib/galaxy/webapps/tool_shed/framework/middleware/hg.py
@@ -112,6 +112,7 @@
return self.__authenticate( username, password )
def __authenticate( self, username, password ):
+ db_password = None
# Instantiate a database connection
engine = sqlalchemy.create_engine( self.db_url )
connection = engine.connect()
@@ -121,14 +122,17 @@
db_email = row[ 'email' ]
db_password = row[ 'password' ]
connection.close()
- # Check if password matches db_password when hashed.
- return new_secure_hash( text_type=password ) == db_password
+ if db_password:
+ # Check if password matches db_password when hashed.
+ return new_secure_hash( text_type=password ) == db_password
+ return False
def __authenticate_remote_user( self, environ, username, password ):
"""
Look after a remote user and "authenticate" - upstream server should already have achieved this for us, but we check that the
user exists at least. Hg allow_push = must include username - some versions of mercurial blow up with 500 errors.
"""
+ db_username = None
ru_email = environ[ 'HTTP_REMOTE_USER' ].lower()
## Instantiate a database connection...
engine = sqlalchemy.create_engine( self.db_url )
@@ -140,9 +144,8 @@
db_password = row[ 'password' ]
db_username = row[ 'username' ]
connection.close()
-
- """
- We could check the password here except that the function galaxy.web.framework.get_or_create_remote_user() does some random generation of
- a password - so that no-one knows the password and only the hash is stored...
- """
- return db_username == username
+ if db_username:
+ # We could check the password here except that the function galaxy.web.framework.get_or_create_remote_user() does some random generation of
+ # a password - so that no-one knows the password and only the hash is stored...
+ return db_username == username
+ return False
Repository URL: https://bitbucket.org/galaxy/galaxy-central/
--
This is a commit notification from bitbucket.org. You are receiving
this because you have the service enabled, addressing the recipient of
this email.
1 new commit in galaxy-central:
https://bitbucket.org/galaxy/galaxy-central/commits/c7bd5efd3e31/
Changeset: c7bd5efd3e31
User: jgoecks
Date: 2013-04-04 17:39:32
Summary: Fixes for commit 4317a15.
Affected #: 1 file
diff -r aad18e2fd35d0d323b8fe01d321dbb8a65bcc740 -r c7bd5efd3e3140a1ad0de22bf3a02e4ef8e4a948 lib/galaxy/visualization/data_providers/genome.py
--- a/lib/galaxy/visualization/data_providers/genome.py
+++ b/lib/galaxy/visualization/data_providers/genome.py
@@ -981,15 +981,24 @@
if op == 0: # Match
# Transform Ms to =s and Xs.
new_op = []
- while read_pos < op_len:
+ total_count = 0
+ while total_count < op_len and ref_seq_pos < len( ref_seq ):
match, count = counter( read_seq, read_pos, ref_seq, ref_seq_pos )
+ # Use min because count cannot exceed remainder of operation.
+ count = min( count, op_len - total_count )
if match:
new_op = 7
else:
new_op = 8
+ new_cigar.append( ( new_op, count ) )
+ total_count += count
read_pos += count
ref_seq_pos += count
- new_cigar.append( ( new_op, count ) )
+
+ # If part of read falls outside of ref_seq dat, then leave
+ # part as M.
+ if total_count < op_len:
+ new_cigar.append( ( 0, op_len - total_count ) )
elif op == 1: # Insertion
new_cigar.append( op_tuple )
elif op in [ 2, 3, 5, 6 ]: # Deletion, Skip, Soft Clipping or Padding
Repository URL: https://bitbucket.org/galaxy/galaxy-central/
--
This is a commit notification from bitbucket.org. You are receiving
this because you have the service enabled, addressing the recipient of
this email.