1 new commit in galaxy-central:
https://bitbucket.org/galaxy/galaxy-central/commits/d1f25e3734f1/
Changeset: d1f25e3734f1
User: greg
Date: 2013-03-22 21:26:07
Summary: Add an expose_api_anonymous decorator to the Galaxy web framework to enable
exposing API methods without requiring an API key or a Galaxy or Tool Shed user session.
Affected #: 2 files
diff -r dab01cbc83dceddd9f02a48deb32c7ffb1817eba -r
d1f25e3734f1e24cb4655758dbeaf44186f5af9a lib/galaxy/web/__init__.py
--- a/lib/galaxy/web/__init__.py
+++ b/lib/galaxy/web/__init__.py
@@ -1,7 +1,16 @@
"""
The Galaxy web application framework
"""
-
-from framework import expose, json, json_pretty, require_login, require_admin, url_for,
error, form, FormBuilder, expose_api, expose_api_raw
+from framework import expose
+from framework import json
+from framework import json_pretty
+from framework import require_login
+from framework import require_admin
+from framework import url_for
+from framework import error
+from framework import form
+from framework import FormBuilder
+from framework import expose_api
+from framework import expose_api_anonymous
+from framework import expose_api_raw
from framework.base import httpexceptions
-
diff -r dab01cbc83dceddd9f02a48deb32c7ffb1817eba -r
d1f25e3734f1e24cb4655758dbeaf44186f5af9a lib/galaxy/web/framework/__init__.py
--- a/lib/galaxy/web/framework/__init__.py
+++ b/lib/galaxy/web/framework/__init__.py
@@ -106,7 +106,13 @@
"""
return expose_api( func, to_json=False )
-def expose_api( func, to_json=True ):
+def expose_api_anonymous( func, to_json=True ):
+ """
+ Expose this function via the API but don't require an API key.
+ """
+ return expose_api( func, to_json=to_json, key_required=False )
+
+def expose_api( func, to_json=True, key_required=True ):
@wraps(func)
def decorator( self, trans, *args, **kwargs ):
def error( environ, start_response ):
@@ -114,7 +120,7 @@
return error_message
error_status = '403 Forbidden'
## If there is a user, we've authenticated a session.
- if not trans.user and isinstance(trans.galaxy_session, Bunch):
+ if key_required and not trans.user and isinstance( trans.galaxy_session, Bunch
):
# If trans.user is already set, don't check for a key.
# This happens when we're authenticating using session instead of an API
key.
# The Bunch clause is used to prevent the case where there's no user, but
there is a real session.
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.