1
0
mirror of https://github.com/djohnlewis/stackdump synced 2024-12-04 23:17:37 +00:00

Added check in the import script to make sure sites aren't inserted with a site key that clashes with Stackdump URLs, e.g. /search or /media.

This commit is contained in:
Samuel Lai 2012-02-12 14:23:59 +11:00
parent 84f5a951ed
commit 67f1ac7a3a

View File

@ -620,6 +620,13 @@ if not (site_name and site_key and site_desc and dump_date):
print 'Use command-line parameters to specify the missing details (listed as None).'
sys.exit(1)
# prevent importing sites with keys that clash with method names in the app,
# e.g. a site key of 'search' would clash with the Stackdump-wide search page.
if site_key in ('search', 'import', 'media'):
print 'The site key given, %s, is a reserved word in Stackdump.' % site_key
print 'Use the --site-key parameter to specify an alternate site key.'
sys.exit(2)
# check if site is already in database; if so, purge the data.
site = list(Site.select(Site.q.key==site_key))
if len(site) > 0: