Flex 4 + Django:测试和发布选项 [英] Flex 4 + Django: Testing and Release Options

查看:165
本文介绍了Flex 4 + Django:测试和发布选项的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在创建一个基于django的站点,它将为通过 pyamf 偶尔访问数据的Flash应用程序提供服务。我需要能够在django框架的上下文中轻松测试Flash,即所有的登录cookie和一切都可用,所以当我进行一个pyamf调用时,它具有所有的用户上下文。而且我需要测试,以一种合理的方式发布swf和wrapper html。但是:

I am creating a django-based site that will serve flash apps that occasionally access data via pyamf. I need to be able to easily test the flash in the context of the django framework, i.e. with all the login cookies and everything available, so that when I make a pyamf call, it has all the user context there. And I need to be able to test and release both the swf's and the wrapper html's in a sane way. However:


  1. flex中的html模板已经是模板,所以如果我将模板代码放在django中,那么在flashapp.html被创建。

  2. html和swf自动发布到同一个目录,但我希望他们去不同的目录,因为swf不应该由django提供, html应该在一个控制django的区域。

这让我相信,乍一看,我需要: p>

This leads me to believe, at first glance, that I need:


  1. 将html和swf文件释放到不同位置的方法。 (我不知道该怎么做)。

  2. 将html作为存根(no html / body标签)发布的方式,以便我们可以将它们从django中的另一个位置包含起来。 (我想只是从index.template.html剥离我不想要的东西?)

  3. 然后我可以指向flex到django网站,反过来包含生成的flashapp。 html反过来引用swf,它应该都可以工作。 (通过将交替的html提供给运行/调试设置,我假设。)

所以我的问题归结为:


  1. 上述是最好的做法,还是这个方向呢?

  2. 如果是,如何将html和swf发布到不同的目录? (对于调试和释放模式,如果有两种不同的方法。)

  3. 如果没有,什么是正确的?

如果有关于这个话题的任何其他一般建议,请随时分享。 : - )

And if there are any other general bits of advice for me on this topic, please feel free to share. :-)

推荐答案

的组合这个 django get-parameters 的作品。一般外包:

Finally figured this out myself. A combination of this and django get-parameters works. The general take-away:


  1. 您可以将 {%tags%} {{variable}} index.template.html 中,不用担心,因为没有办法自定义当前 - 现在的宏就像 $ {title}

  2. 如果你做一个 foo.template.html foo-debug.template.html 在项目的 html-template 目录中,然后前者将覆盖版本构建的 index.template.html ,后者用于调试版本(注意,结果将是foo-debug.html而不是foo.html。 )

  3. 您可以将参数中的SWF名称传递给django,并将其填入您的目录

  1. You can put {% tags %} and {{ variables }} in index.template.html without worry, as there is no way to customize the currently-existing macros there like ${title}
  2. If you make a foo.template.html and foo-debug.template.html in the html-template directory of your project, then the former will override index.template.html for release builds, and the latter for debug builds (note that the result will be foo-debug.html instead of foo.html though.)
  3. You can pass the name of the SWF in a parameter to django, and have it fill in the directory for you

foo-debug.template.html

foo-debug.template.html

<object ...
  <param name="movie" value="{{ bin_debug_url }}/${swf}.swf" ...

djangoflash.html

djangoflash.html

{% block content %}
  {% include flash_template %}
{% endblock %}

views.py

def djangoflashview( request, **kwargs ):
  if not kwargs.has_key('extra_context'):
    kwargs['extra_context'] = {}
  if request.GET.has_key('name'):
    debug = "-debug" if request.GET.has_key('debug') else ""
    bin_debug_dir = '/dir-to-bin-debug/'
    bin_debug_url = 'url-to-bin-debug'
    name = bin_debug_dir + request.GET['name'] + debug + '.html'
    kwargs['extra_context']['flash_template'] = name
    kwargs['extra_context']['bin_debug_url' ] = bin_debug_url
  return direct_to_template( request, **kwargs ) 

urls.py

url( r'^djangoflash/', 'views.djangoflashview', 
     { 'template': 'djangoflash.html' }

foo.mxml的运行调试目标:

foo.mxml's run-debug target:

/url-to-django/djangoflash/?name=foo

当您调试foo.mxml时,flex:

When you debug foo.mxml, flex:


  1. 添加& debug = true 到url

  2. 将浏览器置于 / url-to-djangoflash / djangoflash /?name = foo& debug = true

  3. urls.py djangoflash / >

  4. 将请求传递给 djangoflashview {'name':'foo','debug'在 views.py
  5. request.GET
  6. 其中指出了 foo-debug.html 位置的名称和位置,将其传递给 flash_template 上下文变量

  7. 将swf的url转换为 bin_debug_url 上下文变量

  8. 加载直接模板 djangoflash.html

  9. djangoflash.html 包括fla的 foo-debug.html 包装器sh使用 flash_template 上下文变量

  10. 其中,依次填写 bin_debug_url 上下文变量将foo.swf引用正确地指向刚刚编译的东西

  1. Adds &debug=true to the url
  2. Brings up a browser to /url-to-djangoflash/djangoflash/?name=foo&debug=true
  3. Which picks djangoflash/ in urls.py
  4. Which passes the request to djangoflashview and {'name':'foo','debug':'true'} to request.GET in views.py
  5. Which figures out the name and location of the foo-debug.html location, passing it to the flash_template context variable
  6. And the url of the swf to the bin_debug_url context variable
  7. And loads up the direct template djangoflash.html
  8. Which, in djangoflash.html, includes the foo-debug.html wrapper for flash using the flash_template context variable
  9. Which, in turn fills in the bin_debug_url context variable to point the foo.swf reference correctly to the thing you just compiled

:-P

这篇关于Flex 4 + Django:测试和发布选项的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆