(key, limit_redirs=5)
| 251 | |
| 252 | @public |
| 253 | def get_document(key, limit_redirs=5): |
| 254 | doc = None |
| 255 | for i in range(limit_redirs): |
| 256 | doc = web.ctx.site.get(key) |
| 257 | if doc is None: |
| 258 | return None |
| 259 | if doc.type.key == "/type/redirect": |
| 260 | key = doc.location |
| 261 | else: |
| 262 | return doc |
| 263 | return doc |
| 264 | |
| 265 | |
| 266 | class revert(delegate.mode): |