]> git.openstreetmap.org Git - osqa.git/blobdiff - forum/models/base.py
making the default confirm AJAX prompt a bit wider
[osqa.git] / forum / models / base.py
index bf132c4e1bca3177cfe666ade6f95742c0bfe5a0..1111b43e8b9beac21c3c19fe61a5aa60671462e7 100644 (file)
@@ -150,6 +150,7 @@ class CachedQuerySet(models.query.QuerySet):
                 to_return = [(isinstance(tr, ToFetch) and fetched[str(tr)] or tr) for tr in to_return]
                 to_cache.update(dict([(self.model.infer_cache_key({on_cache_query_attr: attr}), r._as_dict()) for attr, r in fetched.items()]))
 
+
         if len(to_cache):
             cache.set_many(to_cache, 60 * 60)
 
@@ -161,7 +162,7 @@ class CachedQuerySet(models.query.QuerySet):
                     yield row
 
     def _get_query_hash(self):
-        return md5(str(self.query)).hexdigest()
+        return md5(unicode(self.query).encode("utf-8")).hexdigest()
 
 
 
@@ -257,6 +258,9 @@ class BaseModel(models.Model):
     def save(self, full_save=False, *args, **kwargs):
         put_back = [k for k, v in self.__dict__.items() if isinstance(v, models.expressions.ExpressionNode)]
 
+        if hasattr(self, '_state'):
+            self._state.db = 'default'
+
         if self.id and not full_save:
             self.__class__.objects.filter(id=self.id).update(**self._get_update_kwargs())
         else: