<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array">
    <added>
      <filename>.gitignore</filename>
    </added>
  </added>
  <modified type="array">
    <modified>
      <diff>@@ -15,7 +15,9 @@
 			instance.initialState = arguments.initialState;
 						
 			configureState();
-			setInitialState(instance.initialState);
+			if(getState() eq '') {
+				setInitialState(instance.initialState);
+			}
 						
 			return this;
 		&lt;/cfscript&gt;
@@ -65,13 +67,13 @@
 		&lt;cfreturn invokeMethod(&quot;get#instance.stateMethod#&quot;) /&gt;
 	&lt;/cffunction&gt;
 	
-	&lt;cffunction name=&quot;setState&quot; access=&quot;public&quot; output=&quot;false&quot;&gt;
+	&lt;cffunction name=&quot;setInternalState&quot; access=&quot;public&quot; output=&quot;false&quot;&gt;
 		&lt;cfargument name=&quot;state&quot; type=&quot;string&quot; required=&quot;true&quot; /&gt;	
 		&lt;cfset var local = structNew() /&gt;
 		&lt;cfset local.state = arguments.state /&gt;
 		&lt;cfset invokeMethod(&quot;set#instance.stateMethod#&quot;, local) /&gt;
 	&lt;/cffunction&gt;
-
+	
 	&lt;!--- Accessors ---&gt;
 	
 	&lt;cffunction name=&quot;getInitialState&quot; access=&quot;public&quot; returntype=&quot;string&quot; output=&quot;false&quot;&gt;
@@ -85,7 +87,7 @@
 		&lt;cfscript&gt;
 			var state = instance.states[arguments.stateName];
 			state.before(this);
-			setState(arguments.stateName);
+			setInternalState(arguments.stateName);
 			state.after(this);
 		&lt;/cfscript&gt;
 	&lt;/cffunction&gt;	
@@ -137,16 +139,22 @@
 	
 		1. To defined the state query handlers, i.e. isClosed()
 		2. To define the event firing shortcuts, i.e. close()
-		3. To pass any unknown method on to the decorated object to handle
-				
+		3. To pass any unknown method on to the decorated object to handle				
 	---&gt;	
 	&lt;cffunction name=&quot;onMissingMethod&quot; output=&quot;false&quot; access=&quot;public&quot;&gt;
     &lt;cfargument name=&quot;missingMethodName&quot; type=&quot;string&quot; /&gt;
     &lt;cfargument name=&quot;missingMethodArguments&quot; type=&quot;struct&quot; /&gt;
 		
-		&lt;!--- 
-		Shortcut to wire up event methods, so basically if you have a 
-		'trash' event, you can call obj.trash() rather than the longer obj.fireEvent('trash') ---&gt;
+		&lt;!--- This is to highly discourage the manual setting of state. 
+					It can still be done by getting the original object and 
+					setting it directly. BAD. ---&gt;
+		&lt;cfif arguments.missingMethodName is &quot;set#getStateMethod()#&quot; &gt;
+			&lt;cfthrow type=&quot;shade.InvalidStateChange&quot; message=&quot;You cannot set the state directly. Please call an event instead to change the state.&quot; /&gt;
+		&lt;/cfif&gt;
+		
+		&lt;!--- Shortcut to wire up event methods, so basically if you have a 
+					'trash' event, you can call obj.trash() rather than the longer 
+					obj.fireEvent('trash') ---&gt;
 		&lt;cfif structKeyExists(instance.eventTable, arguments.missingMethodName)&gt;
 			&lt;cfreturn fireEvent(arguments.missingMethodName) /&gt;		
 		&lt;/cfif&gt;</diff>
      <filename>StateMachine.cfc</filename>
    </modified>
    <modified>
      <diff>@@ -50,7 +50,7 @@
 			
 			if(not local.isLoopback) {
 				if(local.nextState.before(obj)) {	
-					obj.setState(getToState());
+					obj.setInternalState(getToState());
 					local.nextState.after(obj);	
 					local.oldState.exit(obj);	
 				} else {</diff>
      <filename>StateTransition.cfc</filename>
    </modified>
    <modified>
      <diff>@@ -2,6 +2,7 @@
 	&lt;cfset instance = structNew() /&gt;
 
 	&lt;cffunction name=&quot;init&quot; access=&quot;public&quot; returntype=&quot;any&quot; output=&quot;false&quot; hint=&quot;&quot;&gt;
+		&lt;cfset instance.state = '' /&gt;
 		&lt;cfreturn this /&gt;
 	&lt;/cffunction&gt;
 		</diff>
      <filename>test/Conversation.cfc</filename>
    </modified>
    <modified>
      <diff>@@ -210,6 +210,15 @@
 		&lt;/cfscript&gt;
 	&lt;/cffunction&gt;
 
-
+	&lt;cffunction name=&quot;testCannotSetStateDirectly&quot; returntype=&quot;void&quot; access=&quot;public&quot; output=&quot;false&quot;&gt;
+		&lt;cfscript&gt;
+			try {
+				conversation.setMyState('new');
+				fail('Should not be able to set state directly.');
+			} catch( any e ) {
+				assertEquals( 'shade.InvalidStateChange', e.type );
+			}
+		&lt;/cfscript&gt;
+	&lt;/cffunction&gt;
 	
 &lt;/cfcomponent&gt;
\ No newline at end of file</diff>
      <filename>test/StateMachineTest.cfc</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>4245d4bde90bb8ef808702716d99aedae1409387</id>
    </parent>
  </parents>
  <author>
    <name>Ryan Wood</name>
    <email>ryan.wood@gmail.com</email>
  </author>
  <url>http://github.com/ryanwood/shade/commit/a0424f7ec70c1d1f8a0d8c1d83097ef9b5b92d1c</url>
  <id>a0424f7ec70c1d1f8a0d8c1d83097ef9b5b92d1c</id>
  <committed-date>2008-08-08T12:16:52-07:00</committed-date>
  <authored-date>2008-08-08T12:16:52-07:00</authored-date>
  <message>Prevented manually state change.</message>
  <tree>05209adc66da6a01cd3990e24855d512a8bc8a78</tree>
  <committer>
    <name>Ryan Wood</name>
    <email>ryan.wood@gmail.com</email>
  </committer>
</commit>
