Hello,

If something comes often, base of computer science is Dont Repeat Yourself :
have in your User model a method like : common_templating_info that
build part of this dict, and update it in the contoller before return.
btw GetCodeLeft, PhoneInfo and GetPhoneList  are functions that takes
the user as an argument, it seems to me it would make more sense  if
they were  @property of the User class.
And regarding PEP8 CamelCase is mostly suited for class while
under_score notation is pretty much for the rest (attributes, method
and function names).

I spot you have some strong coupling in your code between PhoneInfo
and User that might makes it difficult to apply the aforementioned
solution, maintenance will be nightmarish, but this has nothing to do
with turbogears.



Have Fun and good day

2011/10/31 Lingfeng Xiong <[email protected]>:
> hi there,
> I am building a website with a complex template, in the 'master.html'
> which every template files are included, there are several variables:
> [code]
> <li class="xos"> <a id="xlf" class="xns" href="help/">Welcome back $
> {username}</a> </li>
> ...
> <li class="xbp" py:for="phone in phonelist">
> ...
> [/code]
> For show my templates correctly, I have to make a very complex
> 'return' stances for every exposed functions:
> [code]
> return dict(page = 'rename',
> username = self.user.user_name,
> phoneinfo = self.phoneInfo,
> phonelist = PhoneInfo.GetPhoneList(self.user),
> codeleft = GetCodeLeft(self.user),
> phonename = PhoneInfo.GetPhoneName(user = self.user, imei =
> self.phoneInfo.IMEI)
> )
> [/ciode]
> In the example above, most of the parametered are common, such as
> 'username', 'codeleft' and 'phonelist'. Is there anyway for me to
> shorten my return line? Thanks.
>
> --
> 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.
>
>

-- 
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.

Reply via email to