Making templatetags on App Engine is a bit different from the real django. Here is how i made mine.
* Create a templatetags folder under your root folder
* Create a empty file named __init__.py
* Create your templatetags file, for this example we will use ads_manager.py
Open your ads_manager.py and enter the following code
from google.appengine.ext.webapp import template
register = template.create_template_register()
def checkShowAds(remote_add):
if remote_add == "127.0.0.1":
return ""
else:
return "ADS HERE"
register.filter("checkShowAds",checkShowAds)
from google.appengine.ext.webapp import template
– means import the template class from the package google…
register = template.create_template_register()
– register this template or something like that
def checkShowAds(remote_add):……………..
– our function
register.filter(”checkShowAds”,checkShowAds)
– add our function as custom filter
Next stop is to open your python file that you will use this templatetags/filter
and insert the following code
from google.appengine.ext.webapp import template
template.register_template_library('templatetags.ads_manager')
class MainPage(webapp.RequestHandler):
def get(self):
template_values = {
'remote_add': self.request.remote_addr
}
directory = os.path.dirname(__file__)
path = os.path.join(directory,os.path.join('templates','index.html'))
self.response.out.write(template.render(path,template_values))
template.register_template_library(’templatetags.ads_manager’)
– What this do is that it register your templatetags so you can use it on your template/view.
class MainPage(webapp.RequestHandler):……
– This and the rest of the code will just render your template while passing the remote address as ‘remote_add’ variable
Next is to open your template and add the following:
{{ remote_add|checkShowAds }}
I hope this helps. It took me days to understand the basic concept of how templatetags on app engine works.
Google chrome was released last week and its already got around 2-4% of US market share, while its sounds so small, actually it a lot, if you compare it to opera or safari which took them years to get to 4% it only took google one week or even a day. I really hate the news when i saw it before the day it was released, and the reason was we web developers have to cater another browser with different javascript engine.
But this move brings significance to the whole computer industry, of course its not just Google Chrome but other stuff that make news this few week. One of them is JIT or Just in Time Compiler, thanks to Adobe for opening their Javascript JIT engine, we can see the result of these in TraceMonkey, the javascript engine of the next version of firefox and V8 the javascript engine of Google Chrome, so whats so good about it? The source are now compiled like java or .net and the browser need not to download binaries, this will make javascript to be executed a lot faster, 4-10% of the current speed.
Another thing which i believe google will do in the long run is the instant on linux(SplashTop) feature and they might even release a computer of their own, with this one feature sort of a cloud book but with no operating system except the prebuild linux and their android team will help them achieve this goal. Currently SplashTop includes firefox as the build in browser, but i’m looking at the opportunity that once Chrome reached the linux land they will make a dell with them or they will make their own.
Is this the end of MS? I don’t think so but i do hope that its the end of IE, ahha. Coz after IE8 is released we have to cater 3 browser from MS and that sucks. This is actually good for MS coz now their force to do better but the question now is that will IE8 commit to its promise of being standard or web programmer will just ignore them in the long run when firefox, safari, chrome and opera (all comply to the standard) reached over 50% of market share?
Why China? Have you guys seen any phones from china that looks exactly like the real phone except the ugly interface? I personally believe that would change because of android. Why? Here are some of my reason.
* Operating System - These small mobile company made their own mobile os simply because they could not use Symbian or Windows Mobile os or Apple due to the license stuff, dont know about Symbian now that they are open source. So it would be wise for these company to stop making their own and just use something that is already build then just remodify some part of it.
* Cost - Making your own mobile os with all the programmers that you will hire to do all the stuff that will make your mobile work is way too expensive for these company compare to using something that is already build. Not just they have to pay for their people to do the software, they also have to pay over the maintenance of it, translation of the manual and some technical support to their client???


* Revenue - Over the 3rd world countries, mobiles from China are hot, why? Not just because their cheap but because of the features but some people especially the one who can afford to buy 2nd class phones would not buy them, why? Not because they think its cheap but because they hate their first experience they had with these phones because of the interface. So using android would make them more richer.
* Innovation - This is purely my imagination, but i forecast that the Chinese people will not just make android on smart phone but on different gadget as well, like PMP, PDA, and Laptop computer (they might port it, these people are freakin awesome and insane)
I believe that smart phone will be huge and China will pay a major role on it. But what’s with Google on this? The more android phones they got, the more people will have use their services, the better standing they will get not just in China but over the globe. So its better for everyone after all.
You have wordpress and you put ads on it, like this blog (sorry if you feel its too much, haha), and you want to hide your ads when you and the other admins are viewing the site. Here is a small script that might help you.
Go to the location of your ads, it could be found on your template if you add it manually (if you use plugins your on your own)
For example you add an ads on your sidebar, you can access this page through the admin’s Design Tab -> Theme Editor -> Sidebar (sidebar.php). Enter this code:
<? if(!current_user_can('edit_users')): ?>
Your Ads here
<? endif; ?>


What does this do, it will check if the user can edit users which means it will check if the current user is an admin, another thing to notice here is that i didn’t use curly brackets on PHP’s if, so if you didn’t know yet PHP is quite a messy language, it can have C syntax and some Basic kinda like syntax, usually i use Basic kinda like syntax on view. Why? Coz using the if-endif,for-endfor,foreach-endforeach of it seems to be more readable then curly brackets when combined with html tags.
Verinoca of tekzilla explained clearly the newest feature of gmail. You watch the video at
http://revision3.com/tzdaily/2008-07-15gmailinfo/