Marcin Kuzminski avatar Marcin Kuzminski committed a27e4d4

Use __unicode__ instead of __repr__ in models.

Comments (0)

Files changed (2)

rhodecode/model/db.py

     def delete(cls, id_):
         obj = cls.query().get(id_)
         Session.delete(obj)
-
+    
+    def __repr__(self):
+        if hasattr(self, '__unicode__'):
+            # python repr needs to return str
+            return safe_str(self.__unicode__())
+        return '<DB:%s>' % (self.__class__.__name__)
 
 class RhodeCodeSetting(Base, BaseModel):
     __tablename__ = 'rhodecode_settings'
         """
         self._app_settings_value = safe_unicode(val)
 
-    def __repr__(self):
-        return "<%s('%s:%s')>" % (
+    def __unicode__(self):
+        return u"<%s('%s:%s')>" % (
             self.__class__.__name__,
             self.app_settings_name, self.app_settings_value
         )
     def is_admin(self):
         return self.admin
 
-    def __repr__(self):
-        return "<%s('id:%s:%s')>" % (self.__class__.__name__,
+    def __unicode__(self):
+        return u"<%s('id:%s:%s')>" % (self.__class__.__name__,
                                      self.user_id, self.username)
 
     @classmethod
     users_group_to_perm = relationship('UsersGroupToPerm', cascade='all')
     users_group_repo_to_perm = relationship('UsersGroupRepoToPerm', cascade='all')
 
-    def __repr__(self):
-        return '<userGroup(%s)>' % (self.users_group_name)
+    def __unicode__(self):
+        return u'<userGroup(%s)>' % (self.users_group_name)
 
     @classmethod
     def get_by_group_name(cls, group_name, cache=False,
 
     logs = relationship('UserLog')
 
-    def __repr__(self):
-        return "<%s('%s:%s')>" % (self.__class__.__name__,
-                                  self.repo_id, self.repo_name)
+    def __unicode__(self):
+        return u"<%s('%s:%s')>" % (self.__class__.__name__,self.repo_id, 
+                                   self.repo_name)
 
     @classmethod
     def url_sep(cls):
         self.group_name = group_name
         self.parent_group = parent_group
 
-    def __repr__(self):
-        return "<%s('%s:%s')>" % (self.__class__.__name__, self.group_id,
+    def __unicode__(self):
+        return u"<%s('%s:%s')>" % (self.__class__.__name__, self.group_id,
                                   self.group_name)
 
     @classmethod
     permission_name = Column("permission_name", String(length=255, convert_unicode=False, assert_unicode=None), nullable=True, unique=None, default=None)
     permission_longname = Column("permission_longname", String(length=255, convert_unicode=False, assert_unicode=None), nullable=True, unique=None, default=None)
 
-    def __repr__(self):
-        return "<%s('%s:%s')>" % (
+    def __unicode__(self):
+        return u"<%s('%s:%s')>" % (
             self.__class__.__name__, self.permission_id, self.permission_name
         )
 
         Session.add(n)
         return n
 
-    def __repr__(self):
-        return '<user:%s => %s >' % (self.user, self.repository)
+    def __unicode__(self):
+        return u'<user:%s => %s >' % (self.user, self.repository)
 
 
 class UserToPerm(Base, BaseModel):
         Session.add(n)
         return n
 
-    def __repr__(self):
-        return '<userGroup:%s => %s >' % (self.users_group, self.repository)
+    def __unicode__(self):
+        return u'<userGroup:%s => %s >' % (self.users_group, self.repository)
 
 
 class UsersGroupToPerm(Base, BaseModel):
         self.cache_args = cache_args
         self.cache_active = False
 
-    def __repr__(self):
-        return "<%s('%s:%s')>" % (self.__class__.__name__,
+    def __unicode__(self):
+        return u"<%s('%s:%s')>" % (self.__class__.__name__,
                                   self.cache_id, self.cache_key)
     @classmethod
     def clear_cache(cls):

rhodecode/model/notification.py

             kwargs.update(email_kwargs)
             email_body_html = EmailNotificationModel()\
                                 .get_email_tmpl(type_, **kwargs)
+
             run_task(tasks.send_email, rec.email, email_subject, email_body,
                      email_body_html)
 
         else:
             DTF = lambda d: datetime.datetime.strftime(d, DATETIME_FORMAT)
             when = DTF(notification.created_on)
+
         data = dict(
             user=notification.created_by_user.username,
             action=_map[notification.type_], when=when,
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.