django 1.4, wsgi, flex deploy best practices

111 views
Skip to first unread message

Sells, Fred

unread,
May 31, 2012, 2:54:35 PM5/31/12
to django...@googlegroups.com

I use Flex for the client side and XML between client and server.  I am a “one man team” and so elegance sometimes gets sacrifices for “it works”.   My typical deploy has been

/var/www/html/my flex swf and html code

And

/home/projectname/current/djangositename

 

This works well, except that I have to use absolute URL’s in Flex (including the server name) because Flex will use either absolute or relative to the location of the .swf file.  This means I have to rebuild for different servers.

 

Are there any recommendations of “best practices”

1.       I could have the django view return the html page that includes the swf file.  This has the advantage of allowing django to pass in some flashvars to the application,  the disadvantage is closer coupling (at least for deploy) of client and server; or

2.       I could use the url redirect to allow a relative reference to get redirected to my django home.

 

I’m not an Apache expert and so I defer to the community which is more experienced with these issues for a clean, generic solution I can use going forward as I port to Django 1.4 and CentOs 6.

Sells, Fred

unread,
Jun 4, 2012, 9:47:02 AM6/4/12
to django...@googlegroups.com

That’s a nice clean solution requiring only a minimal edit on a redeploy(server move).

 

I had previously tried to semi-automate this using the javascript code below; but that did not provide a host or hostname; however I’m not really a javascript guru and may have missed something.

 

            var flashvars = {};

            flashvars.hostname = window.location.hostname;

            flashvars.host     = window.location.host;

            flashvars.port     = window.location.port;

            flashvars.mode     = "fred put this in to test";

            var params = {};

            params.quality = "high";

            params.bgcolor = "${bgcolor}";

            params.allowscriptaccess = "sameDomain";

            params.allowfullscreen = "true";

            var attributes = {};

            attributes.id = "${application}";

            attributes.name = "${application}";

            attributes.align = "middle";

            swfobject.embedSWF(

                "${swf}.swf", "flashContent",

                "${width}", "${height}",

                swfVersionStr, xiSwfUrlStr,

                flashvars, params, attributes);

 

 

From: django...@googlegroups.com [mailto:django...@googlegroups.com] On Behalf Of Joni Bekenstein
Sent: Friday, June 01, 2012 9:40 AM
To: django...@googlegroups.com
Subject: Re: django 1.4, wsgi, flex deploy best practices

 

You can configure a basePath through flashvars as you said, but you don't have to make django serve the index.html to set that dynamically. You can put it by hand, allowing you to deploy on different servers in a decoupled manner.

 

Maybe I'm missing something here but I don't see anything wrong with that approach. I almost always use flashvars to specify at least one location, probably for a configuration file, which contains the paths to the backend services, external assets, etc. 

 

Another thing you could do is configure a CNAME record so that backend.frontendserver.com points to backendserver.com

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To view this discussion on the web visit https://groups.google.com/d/msg/django-users/-/KqN3HWLknioJ.
To post to this group, send email to django...@googlegroups.com.
To unsubscribe from this group, send email to django-users...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

Joni Bekenstein

unread,
Jun 5, 2012, 9:34:42 AM6/5/12
to django...@googlegroups.com
Well, since this is the django group, I'll suppose that ${application} is a template variable (Maybe it's a template used by ant when compiling the flex app).

If this index is indeed handled by a django view, you could then configure the basePath / host like this:

1. You could add it to your settings.py or even better some kind of local_settings.py if you have that kind of setup. Then the index view would pass on that setting to the template so that you can pass it through flashvars.
2. You could also use the Sites app already integrated into django. So each deploy would properly configure the site domain (through the admin site), and you'll pass that through flashvars.

Just some ideas, hope it helps.

To unsubscribe from this group, send email to django-users+unsubscribe@googlegroups.com.


For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

To unsubscribe from this group, send email to django-users+unsubscribe@googlegroups.com.


For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

To unsubscribe from this group, send email to django-users+unsubscribe@googlegroups.com.

Reply all
Reply to author
Forward
0 new messages