I do use templetor now. my current code of top bar is this: 

    <nav>
      <div class="wrapper">
        <div class="primary">
          <ul class="nav">
            <li><span>Home</span></li>
            <li><span>About</span></li>
            <li><span>Contact</span></li>
          </ul>
        </div>

        <div class="secondary">
          $if session.logged_in:
              <span>Welcome, $session.username</span>
              <a href="/new">new post</a>
              <a href="/logout">logout</a>
          $else:
              <a href="/register">register</a>
              <a href="/login">login</a>
        </div>
      </div>
    </nav>

This is part of my basic layout template which works as a wrapper. I use 
session to check user's state which means 
I have to render page in response of every request.

On Tuesday, June 25, 2013 9:48:03 PM UTC+9, Tomas Schertel wrote:
>
> On Tuesday, 25 June 2013 08:01:19 UTC-3, Jox wrote:
>>
>> Hi all,
>>
>> as to different content, I mean links in the top bar like login, 
>> register, logout and strings like "welcome $username".
>> what I'd like to do is, only hit database to get data and render these 
>> pages once and cache the wholepage into redis. 
>>
>> I've come up with a potential solution but I'm not very sure if it's a 
>> good idea. I really need experienced developers' advice.
>> the solution is on server side the app only render common parts of these 
>> pages and a piece of javascript code with them. 
>> as to data of every user like who they are or whether they are logged in, 
>> I store them into cookies, then after browser get
>> the page from my server, the javascript code will get data from cookies 
>> and get the remained rendering job done. this way
>> every time a request comes into my app, the app figures out the state of 
>> the user and save data into cookie and fetch the
>> rendered page from redis and sent them together back to users. 
>>
>> what do you think? or are there better ways to deal with this problem? or 
>> maybe I'm doing it wrong? because I'm new to
>> web developing, I don't know how popular websites deal with this. Thank 
>> you guys....any tips and helps will be appreciated.
>>
>  
> Hey Jox,
>
> You should use templates.
> Web.py comes with templetor [1], but you can also use jinja2 or mako.
>
>
> [1] http://webpy.org/docs/0.3/templetor
>

-- 
You received this message because you are subscribed to the Google Groups 
"web.py" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/webpy.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to