+ ##################################################
+ # truncate helper method
+ ##################################################
+ def _truncate(string, style=0):
+ max_len = max(27 - len(self.get_name()), 3)
+ if len(string) > max_len:
+ if style < 0: #front truncate
+ string = '...' + string[3-max_len:]
+ elif style == 0: #center truncate
+ string = string[:max_len/2 -3] + '...' + string[-max_len/2:]
+ elif style > 0: #rear truncate
+ string = string[:max_len-3] + '...'
+ return string
+ ##################################################
+ # simple conditions
+ ##################################################
+ if not self.is_valid(): return _truncate(self.get_value())