[Google AppEngine] 中使用Flex实现Google Account SignIn/SignOut
Monday, January 4th, 2010在AppEngine中可以使用Google Account实现认证。如果使用Flex Application作为UI,使用按钮实现Sign In/Sign Out需要把URL通过HTML页面的FlashVars传递到Flex Application中。但是这个URL的值是几个HTTP地址经过&符号拼接而成,在Flex里通过FlexGlobals.topLevelApplication.parameters读取的时候只能读取第一个&符号前的地址。所以这个URL需要在Python代码里面进行URL encode,在Flex Application中URL decode。
Python代码:
def get (self): user = users.get_current_user() #Check login user if user: sign = urllib2.quote(users.create_logout_url('/openparty')) else: sign = urllib2.quote(users.create_login_url('/openparty')) #Init template vars template_values = { 'sign' : sign, }
Flex代码:
var url : String = decodeURI(FlexGlobals.topLevelApplication.parameters['sign']);