On Monday, June 14, 2010 18:13:13 Timuçin Kızılay wrote: > I'm trying this on version tg2.b1, The auth.py file I use is the default > one created by quickstart. > > I'm trying to modify auth.py model file like this: > > in the object: > class Group(DeclarativeBase): > I'm trying to add a property to get a string of permission names in that > group. I've added this function to achieve this. > ----------- > @property > def permissions_str(self): > permissions = [p.permission_name for p in self.permissions] > p_str = u', '.join(permissions) > return p_str > ----------- > > it works ok, gives me a string of permissions but I want them to be > sorted by permission_name field. what should I add to achieve this?
Use the builtin "sorted"? sorted(["c", "a", "b"]) Just on a side note, to me it looks as if you are confusing model code with presentation logic here. Such kind of stuff shouldn't go to the model. Put it into the controller, if you need it only once. Or create some helper/wrapper function or object if you need it severeal times. Diez -- You received this message because you are subscribed to the Google Groups "TurboGears" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/turbogears?hl=en.

