~azzar1/unity/add-show-desktop-key

« back to all changes in this revision

Viewing changes to ivle/webapp/urls/__init__.py

  • Committer: William Grant
  • Date: 2009-07-04 11:36:12 UTC
  • mto: (1294.4.2 ui-the-third)
  • mto: This revision was merged to the branch mainline in revision 1353.
  • Revision ID: grantw@unimelb.edu.au-20090704113612-x67yyuyjbzjv23yl
Implement default deep views.

Show diffs side-by-side

added added

removed removed

Lines of Context:
199
199
                # Deep views may have multiple segments in their name.
200
200
                if isinstance(viewname, basestring):
201
201
                    names += [viewname]
 
202
                elif viewname[-1] == '+index' and not subpath:
 
203
                    # If the last segment of the path is the default view, we
 
204
                    # can omit it.
 
205
                    names += viewname[:-1]
202
206
                else:
203
207
                    names += viewname
204
208
 
229
233
 
230
234
                if view is not None:
231
235
                    return (obj, view, tuple(todo[1:]))
 
236
                # Now we must check for deep views.
 
237
                # A deep view is one that has a name consisting of
 
238
                # multiple segments. It's messier than it could be, because
 
239
                # we also allow omission of the final segment if it is the
 
240
                # default view name.
232
241
                elif len(todo) >= 2:
233
 
                    # Check for a deep view.
234
 
                    # A deep view is one that has a name consisting of
235
 
                    # multiple segments.
236
242
                    view = vnames.get(tuple(todo[:2]))
237
243
                    if view is not None:
238
244
                        return (obj, view, tuple(todo[2:]))
 
245
                elif len(todo) == 1:
 
246
                    # Augment it with the default view name, and look it up.
 
247
                    view = vnames.get((todo[0], self.default))
 
248
                    if view is not None:
 
249
                        return (obj, view, tuple(todo[2:]))
239
250
 
240
251
            # If there are no segments left to use, or there are no routes, we
241
252
            # get out.