弹性 4 + Django:测试和发布选项
我正在创建一个基于 django 的网站,该网站将为偶尔通过 pyamf 访问数据的 Flash 应用程序提供服务。我需要能够在 django 框架的上下文中轻松测试 flash,即使用所有登录 cookie 和所有可用的内容,以便当我进行 pyamf 调用时,它具有所有用户上下文。我需要能够以合理的方式测试并释放 swf 和包装 html。但是:
- flex 中的 html 模板已经是模板,因此如果我将 django 的模板代码放入其中,它会在创建 flashapp.html 之前被删除。
- html 和 swf 自动发布到同一目录,但我希望它们转到不同的目录,因为 swf 不应该由 django 提供服务,而 html 应该位于 django 控制的区域中。
乍一看,这让我相信我需要:
- 一种将 html 和 swf 文件发布到不同位置的方法。 (我不知道如何做到这一点。)
- 一种将 html 作为存根(没有 html/body 标记)发布的方法,以便我可以从 django 中的另一个位置包含它们。 (我想只是从index.template.html中删除我不想要的内容?)
- 然后我可以将flex指向django站点,该站点又包含生成的flashapp.html,而flashapp.html又引用了swf,并且它应该所有工作。 (我认为,通过将备用 html 提供给运行/调试设置。)
所以我的问题归结为:
- 上面是执行此操作的最佳方法,还是这甚至是正确的方向?
- 如果是这样,如何将html和swf发布到不同的目录? (对于debug和release模式,是否有两种不同的方法。)
- 如果不是,怎样才是正确的?
如果我对这个主题有任何其他一般性建议,请随时分享。 :-)
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:
- The html templates in flex are already templates, so if I put template code in there for django, it gets scraped out before the flashapp.html is created.
- The html's and swf's automatically get released to the same directory, but I want them to go to different directories because the swf's shouldn't be served by django and the html's should be in an area in control of django.
This leads me to believe, at first glance, that I need:
- A way of having the html and swf files be released to different locations. (I don't know how to do this.)
- A way of releasing the html's as stubs (no html/body tag) so that I can include them from another location in django. (I guess just strip what I don't want from the index.template.html?)
- Then I can point flex to go to the django site that in turn includes the generated flashapp.html that in turn references the swf, and it should all work. (By feeding that alternate html to the run/debug settings, I assume.)
So my question comes down to:
- Is the above the best way of doing this, or is this even the right direction?
- If so, how do I release the html and swf to different directories? (For debug and release mode, if there are two different methods.)
- If not, what is proper?
And if there are any other general bits of advice for me on this topic, please feel free to share. :-)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
终于我自己弄清楚了这一点。 的组合这和django get-parameters 有效。一般要点:
{% Tags %}
和{{ Variables }}
放入index.template.html
中,因为无法自定义当前存在的宏,例如${title}
foo.template.html
和foo-debug.template .html
位于项目的html-template
目录中,那么前者将覆盖index.template.html
进行发布版本,后者用于调试版本(请注意,结果将是 foo-debug.html 而不是 foo.html。)foo-debug.template.html
djangoflash.html
views.py
urls.py
foo.mxml 的运行调试目标:
当您调试 foo.mxml 时,flex:
&debug=true
添加到 url/url-to-djangoflash/djangoflash/?name=foo&debug=true
urls.py
中选择djangoflash/
djangoflashview
和{'name':'foo','debug':'true'}
到views.py< 中的
request.GET
/code>foo-debug.html
位置的名称和位置,将其传递给flash_template
上下文变量>bin_debug_url
上下文变量djangoflash.html
djangoflash.html
中包含foo-debug.html 使用
flash_template
上下文变量对 flash 进行包装bin_debug_url
上下文变量,将 foo.swf 引用正确指向您刚刚编译的东西唷。 :-P
Finally figured this out myself. A combination of this and django get-parameters works. The general take-away:
{% tags %}
and{{ variables }}
inindex.template.html
without worry, as there is no way to customize the currently-existing macros there like${title}
foo.template.html
andfoo-debug.template.html
in thehtml-template
directory of your project, then the former will overrideindex.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.)foo-debug.template.html
djangoflash.html
views.py
urls.py
foo.mxml's run-debug target:
When you debug foo.mxml, flex:
&debug=true
to the url/url-to-djangoflash/djangoflash/?name=foo&debug=true
djangoflash/
inurls.py
djangoflashview
and{'name':'foo','debug':'true'}
torequest.GET
inviews.py
foo-debug.html
location, passing it to theflash_template
context variablebin_debug_url
context variabledjangoflash.html
djangoflash.html
, includes thefoo-debug.html
wrapper for flash using theflash_template
context variablebin_debug_url
context variable to point the foo.swf reference correctly to the thing you just compiledWhew. :-P