| 235 | | node = getattr(node, objname, None) |
|---|
| 236 | | if node is not None: |
|---|
| | 237 | is_index = False |
|---|
| | 238 | |
|---|
| | 239 | subnode = getattr(node, objname, None) |
|---|
| | 240 | if subnode is None: |
|---|
| | 241 | # Try a "default" method on the current leaf. |
|---|
| | 242 | subnode = getattr(node, "default", None) |
|---|
| | 243 | if subnode is not None: |
|---|
| | 244 | is_index = path.endswith('/') |
|---|
| | 245 | # Include the current (unfound) name in the vpath args |
|---|
| | 246 | vpath = names[i:-1] |
|---|
| | 247 | else: |
|---|
| | 248 | if i == len(names) - 1: |
|---|
| | 249 | # We found the extra ".index". Mark request so tools |
|---|
| | 250 | # can redirect if path_info has no trailing slash. |
|---|
| | 251 | is_index = True |
|---|
| | 252 | else: |
|---|
| | 253 | # We're not at an 'index' handler. Mark request so tools |
|---|
| | 254 | # can redirect if path_info has NO trailing slash. |
|---|
| | 255 | # Note that this also includes handlers which take |
|---|
| | 256 | # positional parameters (virtual paths). |
|---|
| | 257 | is_index = False |
|---|
| | 258 | vpath = names[i+1:-1] |
|---|
| | 259 | object_trail.append([name, subnode, nodeconf, curpath, vpath, is_index]) |
|---|
| | 260 | |
|---|
| | 261 | if subnode is not None: |
|---|
| 266 | | |
|---|
| 267 | | # Try a "default" method on the current leaf. |
|---|
| 268 | | if hasattr(candidate, "default"): |
|---|
| 269 | | defhandler = candidate.default |
|---|
| 270 | | if getattr(defhandler, 'exposed', False): |
|---|
| 271 | | # Insert any extra _cp_config from the default handler. |
|---|
| 272 | | conf = getattr(defhandler, "_cp_config", {}) |
|---|
| 273 | | object_trail.insert(i+1, ["default", defhandler, conf, curpath]) |
|---|
| 274 | | request.config = set_conf() |
|---|
| 275 | | # See http://www.cherrypy.org/ticket/613 |
|---|
| 276 | | request.is_index = path.endswith("/") |
|---|
| 277 | | return defhandler, names[i:-1] |
|---|
| 278 | | |
|---|
| 279 | | # Uncomment the next line to restrict positional params to "default". |
|---|
| 280 | | # if i < num_candidates - 2: continue |
|---|
| 285 | | if i == num_candidates: |
|---|
| 286 | | # We found the extra ".index". Mark request so tools |
|---|
| 287 | | # can redirect if path_info has no trailing slash. |
|---|
| 288 | | request.is_index = True |
|---|
| 289 | | else: |
|---|
| 290 | | # We're not at an 'index' handler. Mark request so tools |
|---|
| 291 | | # can redirect if path_info has NO trailing slash. |
|---|
| 292 | | # Note that this also includes handlers which take |
|---|
| 293 | | # positional parameters (virtual paths). |
|---|
| 294 | | request.is_index = False |
|---|
| 295 | | return candidate, names[i:-1] |
|---|
| | 294 | request.is_index = is_index |
|---|
| | 295 | return candidate, vpath |
|---|