Created
April 12, 2017 00:25
-
-
Save luhn/f56873c758ae07e59d7b50db197d1751 to your computer and use it in GitHub Desktop.
URL traversal sitemap
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
Inspect a Pyramid app using URL traversal and construct URLs for all the views. | |
""" | |
def get_resources(self, root): | |
resources = { | |
type(root): root, | |
} | |
for resource in root.values(): | |
resources.update(self.get_resources(resource)) | |
return resources | |
root_factory = config.introspector.get('root factories', None)['factory'] | |
root = root_factory(None) | |
resources = self.get_resources(root) | |
views = config.introspector.get_category('views') | |
for view in views: | |
introspectable = view['introspectable'] | |
context = introspectable['context'] | |
resource = resources.get(context) | |
callable = introspectable['callable'] | |
path = resource_path(resource, introspectable['name']) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment