Dear John,
Unfortunatly, I have another problem.
The galaxy version in use for our institute was last updated on December
10th.
Weirdly, when i put the patch in the library_contents.py file, I get
another error (which i don't have on my local version)
Actually, it never goes in the code i patched... and it doesn't
underdand the string which is the role.
the error in the following:
_
157.99.60.187 - - [07/Jan/2014:16:36:31 +0200] GET
/api/libraries/79449a84684b4136/contents?key=API_key HTTP/1.1 200 -
- python-requests/2.0.1 CPython/2.7.5+ Linux/3.11.0-12-generic
sqlalchemy.pool.QueuePool WARNING 2014-01-07 16:36:32,212 Error
closing cursor: current transaction is aborted, commands ignored until
end of transaction block
galaxy.web.framework ERROR 2014-01-07 16:36:32,212 Uncaught exception
in exposed API method:
Traceback (most recent call last):
File
//galaxy/galaxy-dist/lib/galaxy/web/framework/__init__.py, line
197, in decorator
rval = func( self, trans, *args, **kwargs)
File
//galaxy/galaxy-dist/lib/galaxy/webapps/galaxy/api/library_contents.py,
line 183, in create
role = str( trans.security.decode_id( role ) )
File
//galaxy/galaxy-dist/lib/galaxy/webapps/galaxy/controllers/library_common.py,
line 843, in upload_library_dataset
trans.app.security_agent.derive_roles_from_access( trans,
library.id, cntrller, library=True, **vars )
File //galaxy/galaxy-dist/lib/galaxy/security/__init__.py,
line 939, in derive_roles_from_access
in_roles = [ self.sa_session.query( self.model.Role ).get( x ) for
x in listify( kwd.get( k + '_in', [] ) ) ]
File
//galaxy/galaxy-dist/eggs/SQLAlchemy-0.7.9-py2.6-linux-x86_64-ucs4.egg/sqlalchemy/orm/query.py,
line 775, in get
return self._load_on_ident(key)
File
//galaxy/galaxy-dist/eggs/SQLAlchemy-0.7.9-py2.6-linux-x86_64-ucs4.egg/sqlalchemy/orm/query.py,
line 2512, in _load_on_ident
return q.one()
File
//galaxy/galaxy-dist/eggs/SQLAlchemy-0.7.9-py2.6-linux-x86_64-ucs4.egg/sqlalchemy/orm/query.py,
line 2184, in one
ret = list(self)
File
//galaxy/galaxy-dist/eggs/SQLAlchemy-0.7.9-py2.6-linux-x86_64-ucs4.egg/sqlalchemy/orm/query.py,
line 2227, in __iter__
return self._execute_and_instances(context)
File
//galaxy/galaxy-dist/eggs/SQLAlchemy-0.7.9-py2.6-linux-x86_64-ucs4.egg/sqlalchemy/orm/query.py,
line 2242, in _execute_and_instances
result = conn.execute(querycontext.statement, self._params)
File
//galaxy/galaxy-dist/eggs/SQLAlchemy-0.7.9-py2.6-linux-x86_64-ucs4.egg/sqlalchemy/engine/base.py,
line 1449, in execute
params)
File
//galaxy/galaxy-dist/eggs/SQLAlchemy-0.7.9-py2.6-linux-x86_64-ucs4.egg/sqlalchemy/engine/base.py,
line 1584, in _execute_clauseelement
compiled_sql, distilled_params
File
//galaxy/galaxy-dist/eggs/SQLAlchemy-0.7.9-py2.6-linux-x86_64-ucs4.egg/sqlalchemy/engine/base.py,
line 1698, in _execute_context
context)
File
//galaxy/galaxy-dist/eggs/SQLAlchemy-0.7.9-py2.6-linux-x86_64-ucs4.egg/sqlalchemy/engine/base.py,
line 1691, in _execute_context
context)
File
//galaxy/galaxy-dist/eggs/SQLAlchemy-0.7.9-py2.6-linux-x86_64-ucs4.egg/sqlalchemy/engine/default.py,
line 331, in do_execute
cursor.execute(statement, parameters)
DataError: (DataError) invalid input syntax for integer:
odoppelt__at__pasteur.fr
LINE 3: WHERE role.id = E'odoppelt__at__pasteur.fr'
^
'SELECT role.id AS role_id, role.create_time AS role_create_time,
role.update_time AS role_update_time, role.name AS role_name,
role.description AS role_description, role.type AS role_type,
role.deleted AS role_deleted \nFROM role \nWHERE role.id =
%(param_1)s' {'param_1': 'odoppelt__at__pasteur.fr'}
_
Le 06/01/14 18:34, Olivia Doppelt a écrit :
Hello John,
Thank you very much for the patch. It works now with the argument 'roles'.
I tested with the wrong role in order to be sure that it filters when
the role is not the right one and it does get filtered :)
However, I need to add a few lines to the patch in order to avoid the
use of this method without a defined role.
basically, the complete patch is:
+roles = payload.get(roles, None)
+if roles:
+roles = util.listify(roles)
+
+def to_id_as_str(role):
+role = role.replace(__at__, @)
+if @ in role:
+role = str( trans.sa_session.query( trans.app.model.Role
).filter( trans.app.model.Role.table.c.name == role ).first().id )
+else:
+role = str( trans.security.decode_id( role ) )
+return role
+
+payload[roles] = map( to_id_as_str, roles )
+
+else:
+trans.response.status = 400
+return Missing required roles definition
I don't know if you (could/want to) add this to your commit.
Thank you very much for your help.
--
Olivia
Le