~jcsackett/charmworld/bac-tag-constraints

« back to all changes in this revision

Viewing changes to charmworld/views/api.py

  • Committer: Tarmac
  • Author(s): Brad Crittenden
  • Date: 2013-08-06 21:29:09 UTC
  • mfrom: (335.1.1 bug-1208035)
  • Revision ID: tarmac-20130806212909-z7h9sgmm12pulhs0
[r=abentley][bug=1208035][author=bac] Return a 404 if no path information is passed to API URL for charm or bundle.

Show diffs side-by-side

added added

removed removed

Lines of Context:
324
324
                charm = None
325
325
        return charm_id, trailing, charm
326
326
 
327
 
    def charm(self, path):
 
327
    def charm(self, path=None):
328
328
        """Retrieve a charm according to its charm_id."""
 
329
        if path is None:
 
330
            raise HTTPNotFound(self.request.path)
329
331
        charm_id, trailing, charm_data = self._find_charm(path)
330
332
        if charm_data is None:
331
333
            return json_response(
344
346
        else:
345
347
            raise HTTPNotFound(self.request.path)
346
348
 
347
 
    def bundle(self, path):
 
349
    def bundle(self, path=None):
348
350
        """Retrieve a bundle based on id."""
 
351
        if path is None:
 
352
            raise HTTPNotFound(self.request.path)
349
353
        fullpath = '/'.join(path)
350
354
        if len(path) == 3:
351
355
            # We have an owner.