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:
This leads me to believe, at first glance, that I need:
So my question comes down to:
And if there are any other general bits of advice for me on this topic, please feel free to share. :-)
Finally figured this out myself. A combination of this and django get-parameters works. The general take-away:
{% tags %}
and {{ variables }}
in index.template.html
without worry, as there is no way to customize the currently-existing macros there like ${title}
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.)foo-debug.template.html
<object ...
<param name="movie" value="{{ bin_debug_url }}/${swf}.swf" ...
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's run-debug target:
/url-to-django/djangoflash/?name=foo
When you debug foo.mxml, flex:
&debug=true
to the url/url-to-djangoflash/djangoflash/?name=foo&debug=true
djangoflash/
in urls.py
djangoflashview
and {'name':'foo','debug':'true'}
to request.GET
in views.py
foo-debug.html
location, passing it to the flash_template
context variablebin_debug_url
context variabledjangoflash.html
djangoflash.html
, includes the foo-debug.html
wrapper for flash using the flash_template
context variablebin_debug_url
context variable to point the foo.swf reference correctly to the thing you just compiledWhew. :-P