That's what i came up with: (you should probably change it to match your way of doing things, but i tested it and works for me)

--- /opt/invenio/lib/python/invenio/inveniocfg.py.orig 2012-10-28 12:54:58.007229495 +0200 +++ /opt/invenio/lib/python/invenio/inveniocfg.py 2012-10-28 13:05:24.055227141 +0200
@@ -412,7 +412,12 @@
run_sql("""INSERT INTO collection (id, name, dbquery, reclist) VALUES (1,%s,NULL,NULL)""", (sitename,))
    except IntegrityError:
- run_sql("""UPDATE collection SET name=%s WHERE id=1""", (sitename,))
+        try:
+ run_sql("""UPDATE collection SET name=%s WHERE id=1""", (sitename,))
+        except IntegrityError, errorcode:
+             if errorcode[0] == 1062:   # Duplicate sitename
+ print ">>> ERROR: %s already exists in collections! CFG_SITE_NAME NOT updated." %sitename
+                  sys.exit(1)
    # reset CFG_SITE_NAME_INTL:
    for lang in conf.get("Invenio", "CFG_SITE_LANGS").split(","):
sitename_lang = conf.get("Invenio", "CFG_SITE_NAME_INTL_" + lang)

I think It should be enough to put the check in inveniocfg... Unless someone messes up with config.py (in which case, he should know what he's doing :) ) I see of no other 'documented' way to change the sitename, so the uncaught exception in websearchadminlib.py should never appear (at least because of this).

Best regards,
Theodoros Theodoropoulos

Reply via email to