~ubuntu-branches/ubuntu/raring/glance/raring-updates

« back to all changes in this revision

Viewing changes to glance/registry/api/v1/members.py

  • Committer: Package Import Robot
  • Author(s): Chuck Short, Adam Gandleman, Chuck Short
  • Date: 2012-08-16 13:58:32 UTC
  • mfrom: (1.1.41)
  • Revision ID: package-import@ubuntu.com-20120816135832-4m40ppptd1l073fr
Tags: 2012.2~f3-0ubuntu1
[ Adam Gandleman ]
* debian/patches/sql_conn.patch: Also set default sqlite path for
  in glance-api.conf. (LP: #1028711)
* debian/patches/fix-docs-build.patch: Fix docs build

[ Chuck Short ]
* New upstream version.
* debian/control: python-xattr is no longer a required depends.
  (LP: #1031396)
* debian/control: Move python-jsonschema to glance.
  (LP: #1030152)
* debian/control: Start the slow transition to python-glanceclient.

Show diffs side-by-side

added added

removed removed

Lines of Context:
15
15
#    License for the specific language governing permissions and limitations
16
16
#    under the License.
17
17
 
18
 
import logging
19
 
 
20
18
import webob.exc
21
19
 
22
20
from glance.common import exception
23
21
from glance.common import utils
24
22
from glance.common import wsgi
25
23
import glance.db
 
24
import glance.openstack.common.log as logging
26
25
 
27
26
 
28
27
LOG = logging.getLogger(__name__)
30
29
 
31
30
class Controller(object):
32
31
 
 
32
    def _check_can_access_image_members(self, context):
 
33
        if context.owner is None and not context.is_admin:
 
34
            raise webob.exc.HTTPUnauthorized(_("No authenticated user"))
 
35
 
33
36
    def __init__(self):
34
37
        self.db_api = glance.db.get_api()
35
38
        self.db_api.configure_db()
68
71
                 ["can_share": [True|False]]}, ...
69
72
            ]}
70
73
        """
71
 
        if req.context.owner is None:
72
 
            raise webob.exc.HTTPUnauthorized(_("No authenticated user"))
 
74
        self._check_can_access_image_members(req.context)
73
75
 
74
76
        # Make sure the image exists
75
77
        session = self.db_api.get_session()
175
177
        set accordingly.  If it is not provided, existing memberships
176
178
        remain unchanged and new memberships default to False.
177
179
        """
178
 
        if req.context.owner is None:
179
 
            raise webob.exc.HTTPUnauthorized(_("No authenticated user"))
 
180
        self._check_can_access_image_members(req.context)
180
181
 
181
182
        # Make sure the image exists
182
183
        try:
231
232
        """
232
233
        Removes a membership from the image.
233
234
        """
234
 
        if req.context.owner is None:
235
 
            raise webob.exc.HTTPUnauthorized(_("No authenticated user"))
 
235
        self._check_can_access_image_members(req.context)
236
236
 
237
237
        # Make sure the image exists
238
238
        try: