#4624 Repo changes break in python 2.6


Originally created by: sechastain

Hey folks.

We're running a hacked up Allura on RHEL 6.2, and trying to use Python 2.6. I know there is the stated compatibility of 2.7, but we haven't run into any significant problems yet... until today.

The problem we were encountering was in repo_refresh.py and model/repo.py, with this error:

ValueError: zero length field name in format

One of the changes introduced for newest repo stuff uses the new, index-less regex field notation (as described on stackoverflow)

Here's a patch that fixes this little shortcoming of 2.6.

diff --git a/Allura/allura/model/repo.py b/Allura/allura/model/repo.py
index 442be0a..7cdb9b8 100644
--- a/Allura/allura/model/repo.py
+++ b/Allura/allura/model/repo.py
@@ -326,7 +326,7 @@ def ls(self):
         lc_index = dict(
             (lc.object_id, lc.commit_info)
             for lc in LastCommitDoc.m.find(dict(
-                    _id=re.compile("^{}:".format(self.repo._id)),
+                    _id=re.compile("^{0}:".format(self.repo._id)),
                     object_id={'$in': oids})))
         results = []
         def _get_last_commit(oid):
diff --git a/Allura/allura/model/repo_refresh.py b/Allura/allura/model/repo_refresh.py
index 51c02e2..607451e 100644
--- a/Allura/allura/model/repo_refresh.py
+++ b/Allura/allura/model/repo_refresh.py
@@ -316,7 +316,7 @@ def _walk_tree(tree, tree_index):
             for d in last_commit_collection.find(
                 dict(object_id={'$in': rhs_tree_ids},
-                     _id=re.compile("^{}:".format(repo_id))),
+                     _id=re.compile("^{0}:".format(repo_id))),
                 { 'object_id': 1, '_id': 0 }))
         for tree_id in rhs_tree_ids:
             if tree_id not in last_commits:

Since we'll be continuing to work with 2.6, we're happy to help in watching the compatibility... until some really new and novel feature is required, we hope this compatibility can be maintained!


  • Dave Brondsema

    Dave Brondsema - 2012-07-30
    • status: open --> closed
    • assigned_to: Dave Brondsema
    • size: --> 1
    • milestone: limbo --> forge-aug-10
  • Dave Brondsema

    Dave Brondsema - 2012-07-30

    Committed to 'dev'


Log in to post a comment.