<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	xmlns:creativeCommons="http://backend.userland.com/creativeCommonsRssModule"
>

<channel>
	<title>Building Blocks &#187; python</title>
	<atom:link href="http://joelhooks.com/category/python/feed/" rel="self" type="application/rss+xml" />
	<link>http://joelhooks.com</link>
	<description>[without unit tests] you&#039;re not refactoring; you&#039;re just changing shit. -Hamlet D&#039;Arcy</description>
	<lastBuildDate>Fri, 30 Dec 2011 04:11:45 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3</generator>
<creativeCommons:license>http://creativecommons.org/licenses/by/3.0/us/</creativeCommons:license>
		<item>
		<title>Piping the Machine: PureMVC Multicore with Pipes and the Finite State Machine (FSM)</title>
		<link>http://joelhooks.com/2009/05/18/piping-the-machine-puremvc-multicore-with-pipes-and-the-finite-state-machine-fsm/</link>
		<comments>http://joelhooks.com/2009/05/18/piping-the-machine-puremvc-multicore-with-pipes-and-the-finite-state-machine-fsm/#comments</comments>
		<pubDate>Mon, 18 May 2009 20:19:43 +0000</pubDate>
		<dc:creator>Joel</dc:creator>
				<category><![CDATA[actionscript]]></category>
		<category><![CDATA[AIR]]></category>
		<category><![CDATA[design patterns]]></category>
		<category><![CDATA[flex]]></category>
		<category><![CDATA[puremvc]]></category>
		<category><![CDATA[pyAMF]]></category>
		<category><![CDATA[python]]></category>
		<category><![CDATA[software architecture]]></category>

		<guid isPermaLink="false">http://joelhooks.com/?p=177</guid>
		<description><![CDATA[<style type="text/css">
#leftcontainerBox {
float:left;
position: fixed;
top: 60%;
left: 5px;
}

#leftcontainerBox .buttons {
float:left;
clear:both;
margin:4px 4px 4px 4px;

padding-bottom:2px;
}


#bottomcontainerBox {
height: 30px;
width:50%;
padding-top:1px;
}

#bottomcontainerBox .buttons {
float:left;
height: 30px;
margin:4px 4px 4px 4px;
}

</style>
This is going to be a walkthrough of making use of PureMVC Multicore (AS3). To help in building a PureMVC Multicore application, we are going to make use of the StateMachine utility for initial setup and configuration as well as the Pipes utility for communication between cores. Here's the Source. 
<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
			id="fm_PipingTheMachine_192959336"
			class="flashmovie"
			width="400"
			height="300">
	<param name="movie" value="/examples/pipemachine/PipingTheMachine.swf" />
	<!--[if !IE]>-->
	<object	type="application/x-shockwave-flash"
			data="/examples/pipemachine/PipingTheMachine.swf"
			name="fm_PipingTheMachine_192959336"
			width="400"
			height="300">
	<!--<![endif]-->
		]]></description>
			<content:encoded><![CDATA[<style type="text/css">
#leftcontainerBox {
float:left;
position: fixed;
top: 60%;
left: 5px;
}

#leftcontainerBox .buttons {
float:left;
clear:both;
margin:4px 4px 4px 4px;

padding-bottom:2px;
}


#bottomcontainerBox {
height: 30px;
width:50%;
padding-top:1px;
}

#bottomcontainerBox .buttons {
float:left;
height: 30px;
margin:4px 4px 4px 4px;
}

</style>
<p>This is going to be a walkthrough of making use of PureMVC Multicore (AS3). To help in building a PureMVC Multicore application, we are going to make use of the StateMachine utility for initial setup and configuration as well as the Pipes utility for communication between cores.</p>
<p><a href="http://joelhooks.com/examples/pipemachine/srcview/">Here's the Source.</a></p>
<p style="text-align: center;">[kml_flashembed fversion="9.0.124" movie="/examples/pipemachine/PipingTheMachine.swf" targetclass="flashmovie" useexpressinstall="true" publishmethod="static" width="450" height="500"]<a href="http://adobe.com/go/getflashplayer"><img src="http://www.adobe.com/images/shared/download_buttons/get_flash_player.gif" alt="Get Adobe Flash player" /></a></p>

	<!--[if !IE]>-->
	</object>
	<!--<![endif]-->
</object><br />
<span id="more-177"></span></p>
<h2>Overview</h2>
<p>PureMVC can seem a bit overwhelming at first, but once the core concepts are understood the simplicity of the framework is possibly its biggest strength. Developing multicore applications in PureMVC, that is applications that create multiple instances of the PureMVC core actors (Facade, Model, View, Controller), adds another level of complexity that can be daunting. Luckily, there are utilities to help us out here, and abstract some of the problems with communication between modules loaded into an application.</p>
<p>This tutorial is based on the <a href="http://www.seaofarrows.com" target="_blank">Sea of Arrows player</a> put together by Cliff Hall. My goal was to remove some of the complexity involved with a real application and deconstruct the blocks used to build the player in a form that is easier to digest. It is highly recommended that you check out the player for a further example of this particular application structure.</p>
<p>For the purposes of demonstration this application is kept as simple as possible. For a trivial project, this level of complexity in regards to multiple cores, dynamically loaded modules, a finite state machine, and a plumbed framework for components to communicate is over-engineered (at best). It seems like a lot of work, and it is, but the payoff is when you have a complex project with multiple developers and designers working across many modules. This structure is made to scale, and scale well providing many options for efficient development. It allows for finely grained control of all of the actors in your system.</p>
<h2>The Tools</h2>
<p>Here is a brief overview of the tools we are going to use, and then we will get into some code and look at a simple example of everything put together.</p>
<h3>PureMVC</h3>
<p style="text-align: center;"><img class="aligncenter" src="http://puremvc.org/images/stories/puremvc-icon.jpg" alt="" width="318" height="200" /></p>
<p><em>From the website:</em></p>
<blockquote><p><a href="http://puremvc.org/content/view/67/178/" target="_blank">PureMVC is a lightweight framework</a> for creating applications based upon the classic Model, View and Controller concept.</p>
<p>Based upon proven design patterns, this free, open source framework which was originally implemented in the ActionScript 3 language for use with Adobe Flex, Flash and AIR, is now being ported to all major development platforms.</p></blockquote>
<p>If you want a tutorial for basic PureMVC usage, <a href="http://flash.tutsplus.com/tutorials/workflow/understanding-the-puremvc-open-source-framework/">click here</a>.</p>
<h3>Pipes</h3>
<p><a href="http://trac.puremvc.org/Utility_AS3_MultiCore_Pipes">Pipes</a> is a drop in utility for <a href="http://trac.puremvc.org/PureMVC_AS3_MultiCore">multicore PureMVC</a> applications that utilizes a plumbing metaphor to facilitate communication between cores. If you've ever walked down the PVC aisle of your local mega-hardware store, you are familiar with the objects represented in the utility.</p>
<p style="text-align: center;"><img class="size-full wp-image-187  aligncenter" title="pipes-diagram" src="http://69.164.207.135/wp-content/uploads/2009/05/pipes-diagram.png" alt="pipes-diagram" width="500" height="208" /></p>
<p style="text-align: left;">The above diagram comes from the excellent <a href="http://www.joshuaostrom.com/2008/06/15/understanding-puremvc-pipes/">Pipes overview written by Joshua Ostrom</a>.</p>
<h3>StateMachine</h3>
<p>The <a href="http://trac.puremvc.org/Utility_AS3_StateMachine">StateMachine utility</a> is a <a href="http://en.wikipedia.org/wiki/Finite_state_machine">finite state machine</a> for controlling application state in PureMVC. Configured by XML it seems daunting at first, but is relatively simple with only a handful of classes in the utility to make things happen. It makes for an elegant way to step through logical progressions and control available actions inside your application. This example is utilizing the StateMachine for the initial configuration, but it is possible to create complex workflows with the utility.</p>
<p>Check out the <a href="http://code.google.com/p/puremvc-utilities/">FSMVisualizer</a> for a really cool way to look at the PureMVC StateMachine.</p>
<h2>The Code</h2>
<h3>The Shell</h3>
<p>The shell of the application is the root container that will be in charge of creating instances of the modules and displaying their visual components. In this Flex example of the shell, the main MXML file serves as the viewComponent of the first PureMVC core that will be created.</p>
<p>The application is started like a typical PureMVC application. The difference here is with the naming convention being used. Normally in an application that will make use of a single PureMVC core will will create an ApplicationFacade. In this multicore application we are going to instead name the facade <a href="http://joelhooks.com/examples/pipemachine/srcview/source/com/joelhooks/pipingthemachine/shell/ShellFacade.as.html">ShellFacade</a>.</p>
<p>The <a href="http://joelhooks.com/examples/pipemachine/srcview/source/com/joelhooks/pipingthemachine/shell/ShellFacade.as.html">ShellFacade</a> class contains our notification constants. In this case it also cotains constants related to the StateMachine utility that define the states, their actions, and the notifications associated with those actions.</p>
<p>The StateMachine is initialized in our <a href="http://joelhooks.com/examples/pipemachine/srcview/source/com/joelhooks/pipingthemachine/shell/controller/StartupCommand.as.html">StartupCommand</a>, which is a typical MacroCommand found in most PureMVC applications. The first Command run is the <a href="http://joelhooks.com/examples/pipemachine/srcview/source/com/joelhooks/pipingthemachine/shell/controller/state/InjectFSMCommand.as.html">InjectFSMCommand</a> which initializes the StateMachine and provides it with the XML configuration defining the various states. The next Command issued is the <a href="http://joelhooks.com/examples/pipemachine/srcview/source/com/joelhooks/pipingthemachine/shell/controller/state/StartShellCommand.as.html">StartShellCommand</a>, which is our initial state as configured by the StateMachine.</p>

<div class="wp_codebox"><table><tr id="p1772"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
</pre></td><td class="code" id="p177code2"><pre class="xml" style="font-family:monospace;">var fsm:XML =
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;fsm</span> <span style="color: #000066;">initial</span>=<span style="color: #66cc66;">&#123;</span>ShellFacade.STARTING<span style="color: #66cc66;">&#125;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
&nbsp;
	<span style="color: #808080; font-style: italic;">&lt;!-- STARTUP THE SHELL --&gt;</span>
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;state</span> <span style="color: #000066;">name</span>=<span style="color: #66cc66;">&#123;</span>ShellFacade.STARTING<span style="color: #66cc66;">&#125;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
&nbsp;
       <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;transition</span> <span style="color: #000066;">action</span>=<span style="color: #66cc66;">&#123;</span>ShellFacade.STARTED<span style="color: #66cc66;">&#125;</span></span>
<span style="color: #009900;">       			   <span style="color: #000066;">target</span>=<span style="color: #66cc66;">&#123;</span>ShellFacade.PLUMBING<span style="color: #66cc66;">&#125;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
&nbsp;
       <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;transition</span> <span style="color: #000066;">action</span>=<span style="color: #66cc66;">&#123;</span>ShellFacade.STARTUP_FAILED<span style="color: #66cc66;">&#125;</span></span>
<span style="color: #009900;">       			   <span style="color: #000066;">target</span>=<span style="color: #66cc66;">&#123;</span>ShellFacade.FAILING<span style="color: #66cc66;">&#125;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/state<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
&nbsp;
	<span style="color: #808080; font-style: italic;">&lt;!-- PLUMB THE CORES --&gt;</span>
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;state</span> <span style="color: #000066;">name</span>=<span style="color: #66cc66;">&#123;</span>ShellFacade.PLUMBING<span style="color: #66cc66;">&#125;</span> <span style="color: #000066;">changed</span>=<span style="color: #66cc66;">&#123;</span>ShellFacade.PLUMB<span style="color: #66cc66;">&#125;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
&nbsp;
       <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;transition</span> <span style="color: #000066;">action</span>=<span style="color: #66cc66;">&#123;</span>ShellFacade.PLUMBED<span style="color: #66cc66;">&#125;</span></span>
<span style="color: #009900;">       			   <span style="color: #000066;">target</span>=<span style="color: #66cc66;">&#123;</span>ShellFacade.ASSEMBLING<span style="color: #66cc66;">&#125;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
&nbsp;
       <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;transition</span> <span style="color: #000066;">action</span>=<span style="color: #66cc66;">&#123;</span>ShellFacade.PLUMB_FAILED<span style="color: #66cc66;">&#125;</span></span>
<span style="color: #009900;">       			   <span style="color: #000066;">target</span>=<span style="color: #66cc66;">&#123;</span>ShellFacade.FAILING<span style="color: #66cc66;">&#125;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
&nbsp;
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/state<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
&nbsp;
	<span style="color: #808080; font-style: italic;">&lt;!-- ASSEMBLE THE VIEW --&gt;</span>
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;state</span> <span style="color: #000066;">name</span>=<span style="color: #66cc66;">&#123;</span>ShellFacade.ASSEMBLING<span style="color: #66cc66;">&#125;</span> <span style="color: #000066;">changed</span>=<span style="color: #66cc66;">&#123;</span>ShellFacade.ASSEMBLE<span style="color: #66cc66;">&#125;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
&nbsp;
       <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;transition</span> <span style="color: #000066;">action</span>=<span style="color: #66cc66;">&#123;</span>ShellFacade.ASSEMBLED<span style="color: #66cc66;">&#125;</span></span>
<span style="color: #009900;">       			   <span style="color: #000066;">target</span>=<span style="color: #66cc66;">&#123;</span>ShellFacade.NAVIGATING<span style="color: #66cc66;">&#125;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
&nbsp;
       <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;transition</span> <span style="color: #000066;">action</span>=<span style="color: #66cc66;">&#123;</span>ShellFacade.ASSEMBLY_FAILED<span style="color: #66cc66;">&#125;</span></span>
<span style="color: #009900;">       			   <span style="color: #000066;">target</span>=<span style="color: #66cc66;">&#123;</span>ShellFacade.FAILING<span style="color: #66cc66;">&#125;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
&nbsp;
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/state<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
&nbsp;
	<span style="color: #808080; font-style: italic;">&lt;!-- READY TO ACCEPT BROWSER OR USER NAVIGATION --&gt;</span>
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;state</span> <span style="color: #000066;">name</span>=<span style="color: #66cc66;">&#123;</span>ShellFacade.NAVIGATING<span style="color: #66cc66;">&#125;</span> <span style="color: #000066;">changed</span>=<span style="color: #66cc66;">&#123;</span>ShellFacade.NAVIGATE<span style="color: #66cc66;">&#125;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
&nbsp;
	<span style="color: #808080; font-style: italic;">&lt;!-- REPORT FAILURE FROM ANY STATE --&gt;</span>
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;state</span> <span style="color: #000066;">name</span>=<span style="color: #66cc66;">&#123;</span>ShellFacade.FAILING<span style="color: #66cc66;">&#125;</span> <span style="color: #000066;">changed</span>=<span style="color: #66cc66;">&#123;</span>ShellFacade.FAIL<span style="color: #66cc66;">&#125;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
&nbsp;
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/fsm<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>;</pre></td></tr></table></div>

<p>StateMachine states are defined by their <strong>name</strong>, a<strong> changed</strong> property, and <strong>transitions</strong>. Transitions define an <strong>action</strong> that triggers the move to a new state, and a <strong>target</strong> which defines the name of the state in which to move when the action notification is received by the StateMachine. The changed property of a state corresponds directly to the Command defined in the <a href="http://joelhooks.com/examples/pipemachine/srcview/source/com/joelhooks/pipingthemachine/shell/ShellFacade.as.html">ShellFacade</a>. When the StateMachine receives a notification to move to a new state, the Command defined in the changed property is executed.</p>
<p><img class="aligncenter size-full wp-image-182" title="pipingthemachinestatediagram" src="http://69.164.207.135/wp-content/uploads/2009/05/pipingthemachinestatediagram.png" alt="pipingthemachinestatediagram" width="491" height="131" /></p>
<p>We start off in the <em>Starting</em> state which simply mediates the shell application. From there we move to the <em>Plumbing</em> state which creates some of the initial Pipes, instantiates the <a href="http://joelhooks.com/examples/pipemachine/srcview/source/com/joelhooks/pipingthemachine/modules/logger/LoggerModule.as.html">LoggerModule</a> and connects it to the shell. From there we move to the <em>Assembling</em> state which requests a <a href="http://joelhooks.com/examples/pipemachine/srcview/source/com/joelhooks/pipingthemachine/modules/logger/view/components/LoggerWindow.mxml.html">LoggerWindow</a> viewComponent to add to the stage. From here we move to the <em>Navigating</em> state which has no transitions associated with it. It is our final state and means that our application is configured and ready for the user to interact with. There is also a <em>Failing</em> state, which like the <em>Navigating</em> state has no transitions. If some portion of the configuration process were to fail, this state would be called to notify the user that something horrible has happened.</p>
<p>Communications between modules happens in a module's JunctionMediator. This mediator's viewComponent is a Junction. One issue to consider when utilizing dynamic modules is memory management. The connections made between modules with the Pipes utility need to be managed so that when they are disconnect there are no artifacts left to get in the way of Garbage Collection. This application utilizes an extended JunctionMediator defined by the <a href="http://joelhooks.com/examples/pipemachine/srcview/source/com/joelhooks/pipingthemachine/common/view/ManagedJunctionMediator.as.html">ManagedJunctionMediator</a> class which defines a connection pool for the various pipes. When a module is instantiated, the connections are stored in a HashMap. Later, when we want to remove the module, the <a href="http://joelhooks.com/examples/pipemachine/srcview/source/com/joelhooks/pipingthemachine/common/view/ManagedJunctionMediator.as.html">ManagedJunctionMediator</a> references its pool of connections and removes any connections related to that particular module. This is an area that needs more refinement, and while it works well for this demonstration, it could be further abstracted to make a more complete solution for this issue. The <a href="http://joelhooks.com/examples/pipemachine/srcview/source/com/joelhooks/pipingthemachine/shell/view/ShellJunctionMediator.as.html">ShellJunctionMediator</a> is the only class extending <a href="http://joelhooks.com/examples/pipemachine/srcview/source/com/joelhooks/pipingthemachine/common/view/ManagedJunctionMediator.as.html">ManagedJunctionMediator</a> in this application.</p>
<p>It is important to note that a JunctionMediator's handleNotifications method needs to have the default in the switch set to super.handleNotification( note ). There are standard notifications that a JunctionMediator listens for that need to be handled. In addition, the listNotificationInterests method is handled a bit differently to accommodate this functionality.</p>
<h2>Adding a Doodad</h2>
<p>When you click on the Add Doodad button, the <a href="http://joelhooks.com/examples/pipemachine/srcview/source/com/joelhooks/pipingthemachine/shell/controller/AddNewDoodadCommand.as.html">AddNewDoodadCommand</a> is called. This command instantiates a new <a href="http://joelhooks.com/examples/pipemachine/srcview/source/com/joelhooks/pipingthemachine/modules/doodad/DoodadModule.as.html">DoodadModule</a> and registers a <a href="http://joelhooks.com/examples/pipemachine/srcview/source/com/joelhooks/pipingthemachine/shell/view/DoodadModuleMediator.as.html">DoodadModuleMediator</a> with the shell's core. The command then connects the module's pipes to the shell's STDIN and STDOUT pipes. After the module is wired to the shell for communication a notification is sent to get the UI associated with the <a href="http://joelhooks.com/examples/pipemachine/srcview/source/com/joelhooks/pipingthemachine/modules/doodad/DoodadModule.as.html">DoodadModule</a></p>
<p>The <a href="http://joelhooks.com/examples/pipemachine/srcview/source/com/joelhooks/pipingthemachine/modules/doodad/DoodadModule.as.html">DoodadModule</a> is not a visual component. It extends <a href="http://joelhooks.com/examples/pipemachine/srcview/source/com/joelhooks/pipingthemachine/common/view/components/PipeAwareModule.as.html">PipeAwareModule</a>, which is itself an extension of ModuleBase. This is as opposed to Module, which is a visual class, but in this demonstration the visual components are created by the module and then sent to the shell for display. All of the visual components are mediated by their module, but control of their placement rests with the shell.</p>
<p>A <a href="http://joelhooks.com/examples/pipemachine/srcview/source/com/joelhooks/pipingthemachine/common/view/components/PipeAwareModule.as.html">PipeAwareModule</a> is instantiated with a unique identifier. This provides a way to differentiate it from other instances of the module easily. The <a href="http://joelhooks.com/examples/pipemachine/srcview/source/com/joelhooks/pipingthemachine/modules/doodad/DoodadModule.as.html">DoodadModule</a> itself also creates a sequential integer identifier, but this is used here for the purposes of labeling and not marking the module for unique identification.</p>
<p>When the shell asks for a new Doodad, the <a href="http://joelhooks.com/examples/pipemachine/srcview/source/com/joelhooks/pipingthemachine/common/model/message/UIQueryMessage.as.html">UIQueryMessage</a> of type GET is sent from the <a href="http://joelhooks.com/examples/pipemachine/srcview/source/com/joelhooks/pipingthemachine/shell/view/ShellJunctionMediator.as.html">ShellJunctionMediator</a> and is received by the <a href="http://joelhooks.com/examples/pipemachine/srcview/source/com/joelhooks/pipingthemachine/modules/doodad/view/DoodadJunctionMediator.as.html">DoodadJunctionMediator</a>. The <a href="http://joelhooks.com/examples/pipemachine/srcview/source/com/joelhooks/pipingthemachine/modules/doodad/DoodadModule.as.html">DoodadModule</a> then creates the visual component in the <a href="http://joelhooks.com/examples/pipemachine/srcview/source/com/joelhooks/pipingthemachine/modules/doodad/controller/CreateDoodadCommand.as.html">CreateDoodadCommand</a> and sends it back to the shell via a <a href="http://joelhooks.com/examples/pipemachine/srcview/source/com/joelhooks/pipingthemachine/common/model/message/UIQueryMessage.as.html">UIQueryMessage</a> of type SET. The shell then adds the component to the stage. When the Doodad's 'kill' button is pressed, the <a href="http://joelhooks.com/examples/pipemachine/srcview/source/com/joelhooks/pipingthemachine/modules/doodad/view/DoodadJunctionMediator.as.html">DoodadJunctionMediator</a> is ordered to send out another <a href="http://joelhooks.com/examples/pipemachine/srcview/source/com/joelhooks/pipingthemachine/common/model/message/UIQueryMessage.as.html">UIQueryMessage</a>, this time of type DESTROY which lets the shell know that it needs to unplug the module.</p>
<h2>Conclusion</h2>
<p>There is a lot going on here, and it is complex on many levels. There are huge advantages to engineering a complex application this way. It provides flexibility in terms of development allowing for growth and expansion of the system. This particular example is kept relatively simple, and in a real world application I would strive to make the modules more generic, abstracting out the Doodad-specific bits in the shell so that any module added would share common functionality in terms of memory management and basic mechanisms related to the visual components. Hopefully it provides a helpful overview for people looking to understand multicore applications with PureMVC and make use of some of the handy utilities the community has made available.</p>
<p>Let me know if you have any questions and I will do my best to answer them. If you have anything to add, or find any errors, please don't hesitate to let me know.</p>
]]></content:encoded>
			<wfw:commentRss>http://joelhooks.com/2009/05/18/piping-the-machine-puremvc-multicore-with-pipes-and-the-finite-state-machine-fsm/feed/</wfw:commentRss>
		<slash:comments>21</slash:comments>
	<creativeCommons:license>http://creativecommons.org/licenses/by/3.0/us/</creativeCommons:license>
	</item>
		<item>
		<title>Mockups with Balsamiq</title>
		<link>http://joelhooks.com/2009/04/18/mockups-with-balsamiq/</link>
		<comments>http://joelhooks.com/2009/04/18/mockups-with-balsamiq/#comments</comments>
		<pubDate>Sun, 19 Apr 2009 02:48:04 +0000</pubDate>
		<dc:creator>Joel</dc:creator>
				<category><![CDATA[components]]></category>
		<category><![CDATA[python]]></category>
		<category><![CDATA[ui/ux]]></category>

		<guid isPermaLink="false">http://joelhooks.com/?p=166</guid>
		<description><![CDATA[<style type="text/css">
#leftcontainerBox {
float:left;
position: fixed;
top: 60%;
left: 5px;
}

#leftcontainerBox .buttons {
float:left;
clear:both;
margin:4px 4px 4px 4px;

padding-bottom:2px;
}


#bottomcontainerBox {
height: 30px;
width:50%;
padding-top:1px;
}

#bottomcontainerBox .buttons {
float:left;
height: 30px;
margin:4px 4px 4px 4px;
}

</style>
We need mockups. They allow us to communicate with developers, clients, users and everybody in between in a common language. I'm a big fan of the Sharpie and a pad of paper. Balsamiq Mockups has created a really great piece of software to speed up the mockup process. I'm also a big fan of mind [...]]]></description>
			<content:encoded><![CDATA[<style type="text/css">
#leftcontainerBox {
float:left;
position: fixed;
top: 60%;
left: 5px;
}

#leftcontainerBox .buttons {
float:left;
clear:both;
margin:4px 4px 4px 4px;

padding-bottom:2px;
}


#bottomcontainerBox {
height: 30px;
width:50%;
padding-top:1px;
}

#bottomcontainerBox .buttons {
float:left;
height: 30px;
margin:4px 4px 4px 4px;
}

</style>
<p>We need mockups. They allow us to communicate with developers, clients, users and everybody in between in a common language. I'm a big fan of the Sharpie and a pad of paper. <a href="http://www.balsamiq.com/products/mockups">Balsamiq Mockups</a> has created a really great piece of software to speed up the mockup process.</p>
<p><img class="aligncenter size-full wp-image-168" title="balsamiq_desktop" src="http://69.164.207.135/wp-content/uploads/2009/04/balsamiq_desktop.png" alt="" width="475" height="412" /><br />
<span id="more-166"></span><br />
I'm also a big fan of mind maps. Using Balsamiq feels a lot like mind mapping, but with UI structures. It opens the door for new workflows. For me a new project will now consist of the mind map -&gt; Balsamiq generated mockups -&gt; refined wireframes -&gt; implementation.</p>
<p>Balsamiq allows you to save your mockups, both in an application specific XML format (BMML) and as png images. The png files are great for printing scratch sheets from templates that you have mocked up. These are extremely useful for meetings and annotation with the trusty pen.</p>
<p>One thing I really hope they consider for future versions is some sort of API for extending the available widgets. it would be great to build on the <a href="http://www.mockupstogo.net/">mockupstogo community</a> with lower-level user generated components. The ability to share fully mocked components is awesome, but I always want more control.</p>
<p>(edit) I thought that I would add that after playing a bit more I found that you can import your own 'widgets' using the Image object. It also lets you sketch an image on the fly, effectively allowing unlimited custom objects. Sweet.</p>
<p><img class="aligncenter size-full wp-image-167" title="balsamiq_iphone" src="http://69.164.207.135/wp-content/uploads/2009/04/balsamiq_iphone.png" alt="" width="475" height="284" /></p>
]]></content:encoded>
			<wfw:commentRss>http://joelhooks.com/2009/04/18/mockups-with-balsamiq/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
	<creativeCommons:license>http://creativecommons.org/licenses/by/3.0/us/</creativeCommons:license>
	</item>
		<item>
		<title>Installing PyAMF 0.4.0rc1 on Windows XP</title>
		<link>http://joelhooks.com/2008/12/31/installing-pyamf-040rc1-on-windows-xp/</link>
		<comments>http://joelhooks.com/2008/12/31/installing-pyamf-040rc1-on-windows-xp/#comments</comments>
		<pubDate>Wed, 31 Dec 2008 16:32:58 +0000</pubDate>
		<dc:creator>Joel</dc:creator>
				<category><![CDATA[pyAMF]]></category>
		<category><![CDATA[python]]></category>

		<guid isPermaLink="false">http://joelhooks.com/?p=127</guid>
		<description><![CDATA[<style type="text/css">
#leftcontainerBox {
float:left;
position: fixed;
top: 60%;
left: 5px;
}

#leftcontainerBox .buttons {
float:left;
clear:both;
margin:4px 4px 4px 4px;

padding-bottom:2px;
}


#bottomcontainerBox {
height: 30px;
width:50%;
padding-top:1px;
}

#bottomcontainerBox .buttons {
float:left;
height: 30px;
margin:4px 4px 4px 4px;
}

</style>
I wanted to give the latest pyamf a go, but when I used the standard 'setup.py install', the following ominous warning was presented: error: Python was built with Visual Studio 2003; extensions must be built with a compiler than can generate compatible binaries. Visual Studio 2003 was not found on this system. If you have [...]]]></description>
			<content:encoded><![CDATA[<style type="text/css">
#leftcontainerBox {
float:left;
position: fixed;
top: 60%;
left: 5px;
}

#leftcontainerBox .buttons {
float:left;
clear:both;
margin:4px 4px 4px 4px;

padding-bottom:2px;
}


#bottomcontainerBox {
height: 30px;
width:50%;
padding-top:1px;
}

#bottomcontainerBox .buttons {
float:left;
height: 30px;
margin:4px 4px 4px 4px;
}

</style>
<p>I wanted to give the latest pyamf a go, but when I used the standard 'setup.py install', the following ominous warning was presented:</p>
<blockquote><p>error: Python was built with Visual Studio 2003;<br />
extensions must be built with a compiler than can generate compatible binaries.<br />
Visual Studio 2003 was not found on this system. If you have Cygwin installed,<br />
you can try compiling with MingW32, by passing "-c mingw32" to setup.py.</p></blockquote>
<p>Uh oh! I actually <strong>DO</strong> have Cygwin installed, but unfortunately this message is a default and not entirely helpful. It did put me on the right path to actually getting it to go.</p>
<p><a href="http://boodebr.org/main/python/build-windows-extensions">This webpage</a> has a lot of good information on the subject, and it is where I pulled out these steps:</p>
<p>1. Grab the <a href="http://sourceforge.net/project/showfiles.php?group_id=2435&#038;package_id=240780">MingW32 Automated Installer</a> and get it installed. I selected all of the available options as I figured it wouldn't hurt (it didn't)</p>
<p>2. Add the mingw32 binaries to your system path environmental variable (ie <em>c:\mingw32\bin</em>)</p>
<p>3. Tell Python to use mingw32 when it needs to compile a distribution by adding a file called distutils.cfg in this folder: <em>{PYTHON_INSTALL}\lib\distutils\distutils.cfg</em>. The file should contain:</p>
<p><em>[build]<br />
compiler = mingw32</em></p>
<p>4. Version number parsing was throwing errors, so you actually have to edit <em>{PYTHON_INSTALL}\lib\distutils\version.py</em> to get it compiled. At line 100 make the following change:</p>
<p>from:</p>

<div class="wp_codebox"><table><tr id="p1275"><td class="line_numbers"><pre>1
2
</pre></td><td class="code" id="p127code5"><pre class="python" style="font-family:monospace;">    version_re = <span style="color: #dc143c;">re</span>.<span style="color: #008000;">compile</span><span style="color: black;">&#40;</span>r<span style="color: #483d8b;">'^(<span style="color: #000099; font-weight: bold;">\d</span>+) <span style="color: #000099; font-weight: bold;">\.</span> (<span style="color: #000099; font-weight: bold;">\d</span>+) (<span style="color: #000099; font-weight: bold;">\.</span> (<span style="color: #000099; font-weight: bold;">\d</span>+))? ([ab](<span style="color: #000099; font-weight: bold;">\d</span>+))?$'</span>,
                        <span style="color: #dc143c;">re</span>.<span style="color: black;">VERBOSE</span><span style="color: black;">&#41;</span></pre></td></tr></table></div>

<p>to:</p>

<div class="wp_codebox"><table><tr id="p1276"><td class="line_numbers"><pre>1
2
</pre></td><td class="code" id="p127code6"><pre class="python" style="font-family:monospace;">    version_re = <span style="color: #dc143c;">re</span>.<span style="color: #008000;">compile</span><span style="color: black;">&#40;</span>r<span style="color: #483d8b;">'^(<span style="color: #000099; font-weight: bold;">\d</span>+) <span style="color: #000099; font-weight: bold;">\.</span> (<span style="color: #000099; font-weight: bold;">\d</span>+) (<span style="color: #000099; font-weight: bold;">\.</span> (<span style="color: #000099; font-weight: bold;">\d</span>+))? (<span style="color: #000099; font-weight: bold;">\.</span> (<span style="color: #000099; font-weight: bold;">\d</span>+))?$'</span>,
                            <span style="color: #dc143c;">re</span>.<span style="color: black;">VERBOSE</span><span style="color: black;">&#41;</span></pre></td></tr></table></div>

<p>now with all that done, just run 'setup.py install' and it should compile as expected. Easy as... I dunno, it is actually kind of confusing, but it works and now I can give pyamf a whirl with the c-ext enabled.</p>
]]></content:encoded>
			<wfw:commentRss>http://joelhooks.com/2008/12/31/installing-pyamf-040rc1-on-windows-xp/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
	<creativeCommons:license>http://creativecommons.org/licenses/by/3.0/us/</creativeCommons:license>
	</item>
		<item>
		<title>Django Authorization from Flex/AIR via PyAMF</title>
		<link>http://joelhooks.com/2008/09/21/django-authorization-from-flex-air-actionscript-via-pyamf/</link>
		<comments>http://joelhooks.com/2008/09/21/django-authorization-from-flex-air-actionscript-via-pyamf/#comments</comments>
		<pubDate>Mon, 22 Sep 2008 01:41:57 +0000</pubDate>
		<dc:creator>Joel</dc:creator>
				<category><![CDATA[actionscript]]></category>
		<category><![CDATA[AIR]]></category>
		<category><![CDATA[django]]></category>
		<category><![CDATA[flex]]></category>
		<category><![CDATA[pyAMF]]></category>
		<category><![CDATA[python]]></category>

		<guid isPermaLink="false">http://joelhooks.com/?p=88</guid>
		<description><![CDATA[<style type="text/css">
#leftcontainerBox {
float:left;
position: fixed;
top: 60%;
left: 5px;
}

#leftcontainerBox .buttons {
float:left;
clear:both;
margin:4px 4px 4px 4px;

padding-bottom:2px;
}


#bottomcontainerBox {
height: 30px;
width:50%;
padding-top:1px;
}

#bottomcontainerBox .buttons {
float:left;
height: 30px;
margin:4px 4px 4px 4px;
}

</style>
Django views serve nicely as service end-points for Flex applications. Here are some notes on maintaining authenticated sessions between a Flex/Air/Flash application and your Django backend. gateway.py 1 2 3 4 5 6 7 8 from pyamf.remoting.gateway.django import DjangoGateway &#160; import myproject.myapp.views as views &#160; gw = DjangoGateway&#40;&#123; 'login' : views.login_user, 'logout' : views.logout_user, &#125;&#41; [...]]]></description>
			<content:encoded><![CDATA[<style type="text/css">
#leftcontainerBox {
float:left;
position: fixed;
top: 60%;
left: 5px;
}

#leftcontainerBox .buttons {
float:left;
clear:both;
margin:4px 4px 4px 4px;

padding-bottom:2px;
}


#bottomcontainerBox {
height: 30px;
width:50%;
padding-top:1px;
}

#bottomcontainerBox .buttons {
float:left;
height: 30px;
margin:4px 4px 4px 4px;
}

</style>
<p><img src="http://69.164.207.135/wp-content/uploads/2008/09/pyamf-to-django.jpg" alt="" title="pyamf-to-django" width="500" height="121" class="aligncenter size-full wp-image-91" /></p>
<p>Django views serve nicely as service end-points for Flex applications. Here are some notes on maintaining authenticated sessions between a Flex/Air/Flash application and your Django backend.</p>
<p><strong>gateway.py</strong></p>

<div class="wp_codebox"><table><tr id="p8810"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
</pre></td><td class="code" id="p88code10"><pre class="python" style="font-family:monospace;"><span style="color: #ff7700;font-weight:bold;">from</span> pyamf.<span style="color: black;">remoting</span>.<span style="color: black;">gateway</span>.<span style="color: black;">django</span> <span style="color: #ff7700;font-weight:bold;">import</span> DjangoGateway
&nbsp;
<span style="color: #ff7700;font-weight:bold;">import</span> myproject.<span style="color: black;">myapp</span>.<span style="color: black;">views</span> <span style="color: #ff7700;font-weight:bold;">as</span> views
&nbsp;
gw = DjangoGateway<span style="color: black;">&#40;</span><span style="color: black;">&#123;</span>
    <span style="color: #483d8b;">'login'</span>                       : views.<span style="color: black;">login_user</span>,
    <span style="color: #483d8b;">'logout'</span>                     : views.<span style="color: black;">logout_user</span>,
<span style="color: black;">&#125;</span><span style="color: black;">&#41;</span></pre></td></tr></table></div>

<p><strong>views.py</strong></p>

<div class="wp_codebox"><table><tr id="p8811"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
</pre></td><td class="code" id="p88code11"><pre class="python" style="font-family:monospace;"><span style="color: #ff7700;font-weight:bold;">import</span> pyamf
<span style="color: #ff7700;font-weight:bold;">from</span> django.<span style="color: black;">contrib</span> <span style="color: #ff7700;font-weight:bold;">import</span> auth
<span style="color: #ff7700;font-weight:bold;">from</span> django.<span style="color: black;">contrib</span>.<span style="color: black;">auth</span> <span style="color: #ff7700;font-weight:bold;">import</span> authenticate, login, logout
<span style="color: #ff7700;font-weight:bold;">from</span> django.<span style="color: black;">contrib</span>.<span style="color: black;">auth</span>.<span style="color: black;">decorators</span> <span style="color: #ff7700;font-weight:bold;">import</span> login_required
<span style="color: #ff7700;font-weight:bold;">from</span> django.<span style="color: black;">contrib</span>.<span style="color: black;">auth</span>.<span style="color: black;">models</span> <span style="color: #ff7700;font-weight:bold;">import</span> User
&nbsp;
<span style="color: #ff7700;font-weight:bold;">try</span>:
    pyamf.<span style="color: black;">register_class</span><span style="color: black;">&#40;</span> User,  <span style="color: #483d8b;">'django.contrib.auth.models.User'</span><span style="color: black;">&#41;</span>
<span style="color: #ff7700;font-weight:bold;">except</span> <span style="color: #008000;">ValueError</span>:
    <span style="color: #ff7700;font-weight:bold;">print</span> <span style="color: #483d8b;">&quot;Classes already registered&quot;</span>
&nbsp;
<span style="color: #ff7700;font-weight:bold;">def</span> logout_user<span style="color: black;">&#40;</span>http_request<span style="color: black;">&#41;</span>:
    logout<span style="color: black;">&#40;</span>http_request<span style="color: black;">&#41;</span>
&nbsp;
<span style="color: #ff7700;font-weight:bold;">def</span> login_user<span style="color: black;">&#40;</span>http_request, username, password<span style="color: black;">&#41;</span>:
    <span style="color: #dc143c;">user</span> = authenticate<span style="color: black;">&#40;</span>username=username, password=password<span style="color: black;">&#41;</span>
    <span style="color: #ff7700;font-weight:bold;">if</span> <span style="color: #dc143c;">user</span> <span style="color: #ff7700;font-weight:bold;">is</span> <span style="color: #ff7700;font-weight:bold;">not</span> <span style="color: #008000;">None</span>:
        login<span style="color: black;">&#40;</span>http_request, <span style="color: #dc143c;">user</span><span style="color: black;">&#41;</span>
        <span style="color: #ff7700;font-weight:bold;">return</span> <span style="color: #dc143c;">user</span>
    <span style="color: #ff7700;font-weight:bold;">return</span> <span style="color: #008000;">None</span>
&nbsp;
@login_required
<span style="color: #ff7700;font-weight:bold;">def</span> registered_user_protected_function<span style="color: black;">&#40;</span>http_request<span style="color: black;">&#41;</span>:
    <span style="color: #ff7700;font-weight:bold;">return</span> <span style="color: #483d8b;">&quot;You are a registered user.&quot;</span>
&nbsp;
@login_required
<span style="color: #ff7700;font-weight:bold;">def</span> staff_protected_function<span style="color: black;">&#40;</span>http_request<span style="color: black;">&#41;</span>:
    <span style="color: #ff7700;font-weight:bold;">if</span> http_request.<span style="color: #dc143c;">user</span>.<span style="color: black;">is_staff</span> <span style="color: #66cc66;">!</span>= <span style="color: #008000;">True</span>: <span style="color: #ff7700;font-weight:bold;">return</span> <span style="color: #008000;">None</span>
    <span style="color: #ff7700;font-weight:bold;">return</span> <span style="color: #483d8b;">&quot;You are staff.&quot;</span></pre></td></tr></table></div>

<p><strong>from flex</strong></p>

<div class="wp_codebox"><table><tr id="p8812"><td class="line_numbers"><pre>1
2
3
4
</pre></td><td class="code" id="p88code12"><pre class="actionscript" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">var</span> <span style="color: #0066CC;">netConnection</span>:<span style="color: #0066CC;">NetConnection</span> = <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #0066CC;">NetConnection</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
<span style="color: #0066CC;">netConnection</span>.<span style="color: #0066CC;">connect</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;http://mysite.com/gateway&quot;</span><span style="color: #66cc66;">&#41;</span>;
<span style="color: #000000; font-weight: bold;">var</span> responder:Responder = <span style="color: #000000; font-weight: bold;">new</span> Responder<span style="color: #66cc66;">&#40;</span>loginResult, handleFault<span style="color: #66cc66;">&#41;</span>;
<span style="color: #0066CC;">netConnection</span>.<span style="color: #0066CC;">call</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;login&quot;</span>, responder, <span style="color: #ff0000;">&quot;username&quot;</span>, <span style="color: #ff0000;">&quot;password&quot;</span><span style="color: #66cc66;">&#41;</span></pre></td></tr></table></div>

<p>The http_request carries a reference to the currently authenticated user throughout the session. This works for web based Flex application as well as AIR applications on the desktop. Note that I am using a try/except on the pyamf class registration calls. Because this is session based, the classes only need to be registered once. Without the trap, it throws a TypeError letting you know the registration has already taken place.</p>
<p><a href="http://docs.djangoproject.com/en/dev/topics/auth/">Django User Authentication Documentation</a><br />
All of the various things you can do with authentication in Django. It is, of course, based mostly on the use of the very nice Django HTML template system. While those bits aren't handy to the likes of us, it is a good read either way.</p>
<p><a href="http://pyamf.org/wiki/ByteArrayExample">pyAMF ByteArray example</a><br />
This example shows the basic structure for setting up Django/Flex communication. It doesn't cover authentication, but covers a good bit of territory with examples in Flash and Flex.</p>
]]></content:encoded>
			<wfw:commentRss>http://joelhooks.com/2008/09/21/django-authorization-from-flex-air-actionscript-via-pyamf/feed/</wfw:commentRss>
		<slash:comments>11</slash:comments>
	<creativeCommons:license>http://creativecommons.org/licenses/by/3.0/us/</creativeCommons:license>
	</item>
		<item>
		<title>Dynamic upload paths in Django</title>
		<link>http://joelhooks.com/2008/09/12/dynamic-upload-paths-in-django/</link>
		<comments>http://joelhooks.com/2008/09/12/dynamic-upload-paths-in-django/#comments</comments>
		<pubDate>Fri, 12 Sep 2008 07:25:33 +0000</pubDate>
		<dc:creator>Joel</dc:creator>
				<category><![CDATA[django]]></category>
		<category><![CDATA[python]]></category>

		<guid isPermaLink="false">http://joelhooks.com/?p=82</guid>
		<description><![CDATA[<style type="text/css">
#leftcontainerBox {
float:left;
position: fixed;
top: 60%;
left: 5px;
}

#leftcontainerBox .buttons {
float:left;
clear:both;
margin:4px 4px 4px 4px;

padding-bottom:2px;
}


#bottomcontainerBox {
height: 30px;
width:50%;
padding-top:1px;
}

#bottomcontainerBox .buttons {
float:left;
height: 30px;
margin:4px 4px 4px 4px;
}

</style>
I'm refactoring my VE:Session application a bit to the recently released Django 1.0. They have made some outstanding progress with the project overall, but there are enough things that are radically different to cause me to lose sleep searching for answers to small problems. I'd simply overlooked their NewForms branch when I was building the [...]]]></description>
			<content:encoded><![CDATA[<style type="text/css">
#leftcontainerBox {
float:left;
position: fixed;
top: 60%;
left: 5px;
}

#leftcontainerBox .buttons {
float:left;
clear:both;
margin:4px 4px 4px 4px;

padding-bottom:2px;
}


#bottomcontainerBox {
height: 30px;
width:50%;
padding-top:1px;
}

#bottomcontainerBox .buttons {
float:left;
height: 30px;
margin:4px 4px 4px 4px;
}

</style>
<p>I'm refactoring my <a href="http://vesession.com">VE:Session</a> application a bit to the recently released <a href="http://www.djangoproject.com/">Django 1.0</a>. They have made some outstanding progress with the project overall, but there are enough things that are radically different to cause me to lose sleep searching for answers to small problems. I'd simply overlooked their NewForms branch when I was building the application, and now I am paying for it by standing well behind the curve. It is fun to learn new things though, so that is the upside I suppose.</p>
<p>Anyway, back to the refactoring. In addition to updating the project to the current Django trunk, I want to unify the application under Django. I am currently using SlideshowPro for my image CMS functionality. It is a fine product, but it obsfusicates the application and certainly makes it harder to deploy. This is compounded by the fact that I am using an older version of SSP. Django has some out of the box options for filing your uploads in a data structure. I really need something more customizable for the application though, and I was feverishly searching for a solution. The previous examples were <a href="http://scottbarnham.com/blog/2007/07/31/uploading-images-to-a-dynamic-path-with-django/">complex hacks</a> to get the job done. Which is fine, but they are now broken with the update to 1.0. D'oh. As luck would have it they are not neccesary any longer, and the same functionality can be added with a few simple lines that <a href="http://scottbarnham.com/blog/2008/08/25/dynamic-upload-paths-in-django/">Scott Barnham was kind enough to demonstrate</a>:</p>

<div class="wp_codebox"><table><tr id="p8214"><td class="line_numbers"><pre>1
2
3
4
5
6
7
</pre></td><td class="code" id="p82code14"><pre class="python" style="font-family:monospace;"><span style="color: #ff7700;font-weight:bold;">from</span> django.<span style="color: black;">db</span> <span style="color: #ff7700;font-weight:bold;">import</span> models
&nbsp;
<span style="color: #ff7700;font-weight:bold;">def</span> get_image_path<span style="color: black;">&#40;</span>instance, filename<span style="color: black;">&#41;</span>:
    <span style="color: #ff7700;font-weight:bold;">return</span> <span style="color: #483d8b;">'photos/%s/%s'</span> <span style="color: #66cc66;">%</span> <span style="color: black;">&#40;</span>instance.<span style="color: #008000;">id</span>, filename<span style="color: black;">&#41;</span>
&nbsp;
<span style="color: #ff7700;font-weight:bold;">class</span> Photo<span style="color: black;">&#40;</span>models.<span style="color: black;">Model</span><span style="color: black;">&#41;</span>:
    image = models.<span style="color: black;">ImageField</span><span style="color: black;">&#40;</span>upload_to=get_image_path<span style="color: black;">&#41;</span></pre></td></tr></table></div>

<p>Awesome.</p>
<p>I've been knee deep in Java for the past few months, so it is <strong>really</strong> nice to get back into Python for a bit. With Django reaching a comfortable level of maturity, I see many more sleepless nights in my future.</p>
]]></content:encoded>
			<wfw:commentRss>http://joelhooks.com/2008/09/12/dynamic-upload-paths-in-django/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	<creativeCommons:license>http://creativecommons.org/licenses/by/3.0/us/</creativeCommons:license>
	</item>
		<item>
		<title>Continuous scrolling image thumbnail component for Flex.</title>
		<link>http://joelhooks.com/2008/04/21/continuous-scrolling-image-thumbnail-component-for-flex/</link>
		<comments>http://joelhooks.com/2008/04/21/continuous-scrolling-image-thumbnail-component-for-flex/#comments</comments>
		<pubDate>Mon, 21 Apr 2008 07:40:12 +0000</pubDate>
		<dc:creator>Joel</dc:creator>
				<category><![CDATA[actionscript]]></category>
		<category><![CDATA[components]]></category>
		<category><![CDATA[flex]]></category>
		<category><![CDATA[object oriented concepts]]></category>
		<category><![CDATA[puremvc]]></category>
		<category><![CDATA[python]]></category>

		<guid isPermaLink="false">http://joelhooks.com/2008/04/21/continuous-scrolling-image-thumbnail-component-for-flex/</guid>
		<description><![CDATA[<style type="text/css">
#leftcontainerBox {
float:left;
position: fixed;
top: 60%;
left: 5px;
}

#leftcontainerBox .buttons {
float:left;
clear:both;
margin:4px 4px 4px 4px;

padding-bottom:2px;
}


#bottomcontainerBox {
height: 30px;
width:50%;
padding-top:1px;
}

#bottomcontainerBox .buttons {
float:left;
height: 30px;
margin:4px 4px 4px 4px;
}

</style>
I've updated this to a proper component implementation that can be found here. Here is the beginnings of a full featured open-source continuous scroll thumbnail component for Flex. It is rough right now, but I plan to polish it and make it something useful. This format is really appealing, as it gives the user a [...]]]></description>
			<content:encoded><![CDATA[<style type="text/css">
#leftcontainerBox {
float:left;
position: fixed;
top: 60%;
left: 5px;
}

#leftcontainerBox .buttons {
float:left;
clear:both;
margin:4px 4px 4px 4px;

padding-bottom:2px;
}


#bottomcontainerBox {
height: 30px;
width:50%;
padding-top:1px;
}

#bottomcontainerBox .buttons {
float:left;
height: 30px;
margin:4px 4px 4px 4px;
}

</style>
<div class="note-block">I've updated this to a proper component implementation that can be found <a href="http://joelhooks.com/2009/12/24/continuous-scrolling-thumbnail-component-for-flex/">here</a>.</div>
<p>Here is the beginnings of a full featured open-source continuous scroll thumbnail component for Flex. It is rough right now, but I plan to polish it and make it something useful. This format is really appealing, as it gives the user a seamless view of a gallery, without any jumps or aggravating scroll bars. Up until now I have been using H and V Lists in flex for my thumbnailing, but they are ugly and don't provide as rich of an experience.</p>
<p>The <a href="http://www.afcomponents.com/components/scroll_panel_as3/">Scroll Panel from AFComponents</a> was my first choice. It is a very nice component, well priced, and would be just what I need, if not for the fact that <a href="http://vesession.com/">my project is open-source</a> and using a commercial component sorta kills the whole thing. After scouring the internet I finally stumbled upon the work <a href="http://www.f-90.co.uk/blog/?p=7">Peter Wright has put in on a perpetual scrolling list</a>.</p>
<p>I've modified it to accept an XML list of image objects, as well as perform horizontally. It is also functioning as a slideshow, and I want to allow it to go either H or V depending on the need. It should shape up to be a nice reusable component. Much thanks to Peter for supplying the code to get me started.</p>

<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
			id="fm_ImageScroll_616916557"
			class="flashmovie"
			width="490"
			height="165">
	<param name="movie" value="http://joelhooks.com/examples/slideScroll/ImageScroll.swf" />
	<!--[if !IE]>-->
	<object	type="application/x-shockwave-flash"
			data="http://joelhooks.com/examples/slideScroll/ImageScroll.swf"
			name="fm_ImageScroll_616916557"
			width="490"
			height="165">
	<!--<![endif]-->
		
	<!--[if !IE]>-->
	</object>
	<!--<![endif]-->
</object>
<p><a href="http://joelhooks.com/examples/slideScroll/ImageScroll.swf">Source Enabled </a></p>
]]></content:encoded>
			<wfw:commentRss>http://joelhooks.com/2008/04/21/continuous-scrolling-image-thumbnail-component-for-flex/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
	<creativeCommons:license>http://creativecommons.org/licenses/by/3.0/us/</creativeCommons:license>
	</item>
		<item>
		<title>PureMVC Python port has been released</title>
		<link>http://joelhooks.com/2008/03/18/puremvc-python-port-has-been-released/</link>
		<comments>http://joelhooks.com/2008/03/18/puremvc-python-port-has-been-released/#comments</comments>
		<pubDate>Tue, 18 Mar 2008 15:27:26 +0000</pubDate>
		<dc:creator>Joel</dc:creator>
				<category><![CDATA[puremvc]]></category>
		<category><![CDATA[python]]></category>

		<guid isPermaLink="false">http://joelhooks.com/2008/03/18/puremvc-python-port-has-been-released/</guid>
		<description><![CDATA[<style type="text/css">
#leftcontainerBox {
float:left;
position: fixed;
top: 60%;
left: 5px;
}

#leftcontainerBox .buttons {
float:left;
clear:both;
margin:4px 4px 4px 4px;

padding-bottom:2px;
}


#bottomcontainerBox {
height: 30px;
width:50%;
padding-top:1px;
}

#bottomcontainerBox .buttons {
float:left;
height: 30px;
margin:4px 4px 4px 4px;
}

</style>
[PureMVC - Python] I am very excited about the potential of this port. As far as I can tell, there isn't a whole lot out there for MVC and Python. There are a handful of server/web MVC frameworks. Django is the one that I have experience with, and it is a fantastic framework. As is [...]]]></description>
			<content:encoded><![CDATA[<style type="text/css">
#leftcontainerBox {
float:left;
position: fixed;
top: 60%;
left: 5px;
}

#leftcontainerBox .buttons {
float:left;
clear:both;
margin:4px 4px 4px 4px;

padding-bottom:2px;
}


#bottomcontainerBox {
height: 30px;
width:50%;
padding-top:1px;
}

#bottomcontainerBox .buttons {
float:left;
height: 30px;
margin:4px 4px 4px 4px;
}

</style>
<p>[<a href="http://trac.puremvc.org/PureMVC_Python/">PureMVC - Python</a>]</p>
<p>I am very excited about the potential of this port. As far as I can tell, there isn't a whole lot out there for MVC and Python. There are a handful of server/web MVC frameworks. Django is the one that I have experience with, and it is a fantastic framework. As is true when comparing PureMVC to most frameworks, however, the PureMVC for Python is dead simple. It is a straight port, implementing PureMVC in the same fashion as we see in the original AS3 version. Structurally it differs from Actionscript - it is Python after all - but fundamentally it is the same.</p>
<p>Many thanks to <a href="http://www.tobydehavilland.com/">Toby de Havilland</a> for overcoming some of the initial issues with the port, and getting it up and running. Thanks also to <a href="http://www.nathanlevesque.com/">Nathan Levesque</a> for running point on the project and getting the ball rolling with the port</p>
<p>Here it is running the Employee Admin demo on XP and OSX:</p>
<p align="center"><a href="http://69.164.207.135/wp-content/uploads/2008/03/pmvc_python.jpg" title="pmvc_python.jpg"><img src="http://69.164.207.135/wp-content/uploads/2008/03/pmvc_python.jpg" alt="pmvc_python.jpg" /> </a><a href="http://69.164.207.135/wp-content/uploads/2008/03/pmvc_py_mac.jpg" title="pmvc_py_mac.jpg"><img src="http://69.164.207.135/wp-content/uploads/2008/03/pmvc_py_mac.jpg" alt="pmvc_py_mac.jpg" /></a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://joelhooks.com/2008/03/18/puremvc-python-port-has-been-released/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	<creativeCommons:license>http://creativecommons.org/licenses/by/3.0/us/</creativeCommons:license>
	</item>
	</channel>
</rss>

