我在前端应用程序引擎中使用了python和webapp框架,在后端使用了flex 4。 我想传递一个字符串形式后端前端,所以我写入以下代码在main.py:如何将数据从Google App Engine(Python)传递到Flex 4应用程序
class MainPage(webapp.RequestHandler):
def get(self):
userVO = "test"
template_values = {
'url': self.request.uri,
'userVO': userVO,
}
self.response.out.write(template.render("templates/index.html", template_values))
而在柔性4,I有以下代码:
var user:String = FlexGlobals.topLevelApplication.parameters['userVO'];
但是,我收到空值。
请指教如何改正它。谢谢。
编辑:2月25日
感谢谁回答我的问题的人。对于我的问题,我试图弄清楚当应用程序渲染包含swf文件的html文件时,python应用程序引擎如何将数据传递给flex应用程序。也许,我可以在main.py,swfobject.js或index.html中设置一些内容来完成我的任务。
我知道如何使用Pyamf作为服务Flex应用程序的网关,我正在考虑如何让应用程序变得更简单。
谢谢。
编辑:2月28日
罗伯特中的index.html是由Flash Builder 4中创建的标准文件希望你能给我一些提示如何修改它。以下是该文件:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<!-- saved from url=(0014)about:internet -->
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
<!--
Smart developers always View Source.
This application was built using Adobe Flex, an open source framework
for building rich Internet applications that get delivered via the
Flash Player or to desktops via Adobe AIR.
Learn more about Flex at http://flex.org
// -->
<head>
<title></title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
HTML,身体{高度:100%; } body {margin:0;填充:0;溢出:隐藏;文本对齐:中心; }
#flashContent {display:none; }
<script type="text/javascript" src="/js/swfobject.js"></script>
<script type="text/javascript">
<!-- For version detection, set to min. required Flash Player version, or 0 (or 0.0.0), for no version detection. -->
var swfVersionStr = "10.0.0";
<!-- To use express install, set to playerProductInstall.swf, otherwise the empty string. -->
var xiSwfUrlStr = "/swfs/playerProductInstall.swf";
var flashvars = {};
var params = {};
params.quality = "high";
params.bgcolor = "#ffffff";
params.allowscriptaccess = "sameDomain";
var attributes = {};
attributes.id = "index";
attributes.name = "index";
attributes.align = "middle";
swfobject.embedSWF(
"/swfs/index.swf", "flashContent",
"100%", "100%",
swfVersionStr, xiSwfUrlStr,
flashvars, params, attributes);
swfobject.createCSS( “#flashContent”, “显示:块;文本对齐:左;”);
要查看此页面确保Adobe Flash Player版本 10.0.0或更高安装。

<noscript>
<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="100%" height="100%" id="index">
<param name="movie" value="index.swf" />
<param name="quality" value="high" />
<param name="bgcolor" value="#ffffff" />
<param name="allowScriptAccess" value="sameDomain" />
<!--[if !IE]>
<object type="application/x-shockwave-flash" data="index.swf" width="100%" height="100%">
<param name="quality" value="high" />
<param name="bgcolor" value="#ffffff" />
<param name="allowScriptAccess" value="sameDomain" />
<![endif]-->
<!--[if gte IE 6]>
<p>
Either scripts and active content are not permitted to run or Adobe Flash Player version
10.0.0 or greater is not installed.
</p>
<![endif]-->
<a href="http://www.adobe.com/go/getflashplayer">
<img src="https://www.adobe.com/images/shared/download_buttons/get_flash_player.gif" alt="Get Adobe Flash Player" />
</a>
<!--[if !IE]>
</object>
<![endif]-->
</object>
</noscript>
谢谢,罗伯特。
编辑:3月7日。
罗伯特,
参考http://help.adobe.com/en_US/Flex/4.0/html/WS2db454920e96a9e51e63e3d11c0bf626ae-7feb.html
之前,我在这里发表的问题,我尝试下面的代码:
在index.html的,
<%
String user = (String) request.getParameter("userVO");
%>
,也
flashvars.userVO = "<%= user %>";
结果,我得到:
<用户
你知道为什么我不能得到正确的数据。谢谢。
感谢Robert,我知道我可以调整Flashvars来完成任务,并且我已经尝试了很多次。但是,它不成功。对于livedocs,Flex 3和4,我已经读过好几次了。 – michael 2010-02-27 14:25:07
你可以发布你的index.html模板的内容吗? – 2010-02-27 16:22:30
罗伯特,我在问题中发布文件。 – michael 2010-02-28 16:13:15