Files
postgres-web/pgweb/util/sitestruct.py
Magnus Hagander 428f299f48 Generate internal sitemap including devel docs
We'll use this to index some things in our own search engine without
exposing it to external sitemap parsers. Not from a security standpoint
of course, but something that will lead to it being possible to search
the devel docs again.
2017-03-23 12:11:22 +01:00

23 lines
652 B
Python

from django.conf import settings
def get_all_pages_struct(method='get_struct'):
"""
Return an iterator over all distinct pages on the site.
Each page is returned as a tuple consisting of:
(url, search weight, last_modified)
It will do so by looking for the module "struct" in all
installed applications, and calling the get_struct() function
in all such modules.
"""
for app in settings.INSTALLED_APPS:
if app.startswith('pgweb.'):
try:
m = __import__(app+".struct", {}, {}, method)
except:
# Failed to import - probably module didnd't exist
continue
if hasattr(m, method):
for x in getattr(m, method)(): yield x