You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@allura.apache.org by br...@apache.org on 2012/09/25 04:13:10 UTC
[14/14] git commit: [#4637] ticket:168 fix upsert
[#4637] ticket:168 fix upsert
Project: http://git-wip-us.apache.org/repos/asf/incubator-allura/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-allura/commit/577a7193
Tree: http://git-wip-us.apache.org/repos/asf/incubator-allura/tree/577a7193
Diff: http://git-wip-us.apache.org/repos/asf/incubator-allura/diff/577a7193
Branch: refs/heads/master
Commit: 577a7193a9298ebad77a3ac88e3839ce0d6b0623
Parents: 89c5ce2
Author: Igor Bondarenko <je...@gmail.com>
Authored: Wed Sep 19 22:05:13 2012 +0300
Committer: Cory Johns <jo...@geek.net>
Committed: Fri Sep 21 20:06:16 2012 +0000
----------------------------------------------------------------------
ForgeShortUrl/forgeshorturl/model/shorturl.py | 10 +++++++---
1 files changed, 7 insertions(+), 3 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/577a7193/ForgeShortUrl/forgeshorturl/model/shorturl.py
----------------------------------------------------------------------
diff --git a/ForgeShortUrl/forgeshorturl/model/shorturl.py b/ForgeShortUrl/forgeshorturl/model/shorturl.py
index 4ceeff6..a720dd0 100644
--- a/ForgeShortUrl/forgeshorturl/model/shorturl.py
+++ b/ForgeShortUrl/forgeshorturl/model/shorturl.py
@@ -1,4 +1,7 @@
import pymongo
+import pylons
+pylons.c = pylons.tmpl_context
+from pylons import c
from ming.orm import FieldProperty, ForeignIdProperty, session
from datetime import datetime
from allura.model.auth import User
@@ -26,15 +29,16 @@ class ShortUrl(M.Artifact):
@classmethod
def upsert(cls, shortname):
- u = cls.query.get(short_name=shortname)
+ u = cls.query.get(short_name=shortname, app_config_id=c.app.config._id)
if u is not None:
return u
try:
- u = cls(short_name=shortname)
+ u = cls(short_name=shortname, app_config_id=c.app.config._id)
session(u).flush(u)
except pymongo.errors.DuplicateKeyError:
session(u).expunge(u)
- u = cls.query.get(short_name=shortname)
+ u = cls.query.get(short_name=shortname,
+ app_config_id=c.app.config._id)
return u
def index(self):