<?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:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>Giggy's Stream on Nonsense &#187; model</title>
	<atom:link href="http://jmlawlor.wordpress.com/tag/model/feed/" rel="self" type="application/rss+xml" />
	<link>http://jmlawlor.wordpress.com</link>
	<description>Everything else is just a blog.... lol</description>
	<lastBuildDate>Sun, 27 Dec 2009 01:56:58 +0000</lastBuildDate>
	<generator>http://wordpress.com/</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<cloud domain='jmlawlor.wordpress.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://www.gravatar.com/blavatar/212a6537ea07699dd422e011af2d20ba?s=96&#038;d=http://s.wordpress.com/i/buttonw-com.png</url>
		<title>Giggy's Stream on Nonsense &#187; model</title>
		<link>http://jmlawlor.wordpress.com</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://jmlawlor.wordpress.com/osd.xml" title="Giggy&#8217;s Stream on Nonsense" />
		<item>
		<title>GAE Q/A Externalizing Model Class Def to file</title>
		<link>http://jmlawlor.wordpress.com/2009/05/18/gae-qa-externalizing-model-class-def-to-file/</link>
		<comments>http://jmlawlor.wordpress.com/2009/05/18/gae-qa-externalizing-model-class-def-to-file/#comments</comments>
		<pubDate>Mon, 18 May 2009 09:31:53 +0000</pubDate>
		<dc:creator>jmlawlor</dc:creator>
				<category><![CDATA[Google App Engine]]></category>
		<category><![CDATA[Datastore]]></category>
		<category><![CDATA[External]]></category>
		<category><![CDATA[gae]]></category>
		<category><![CDATA[model]]></category>
		<category><![CDATA[models]]></category>

		<guid isPermaLink="false">http://jmlawlor.wordpress.com/?p=59</guid>
		<description><![CDATA[Problem:
I was tired of having all of my data models for my project in the same doc as the rest of my functional code.  I wanted to move it all to a models.py file.
Resolution:
Simply create a new file and then copy/paste the datamodels into it.  Remember to include the import for the google [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=jmlawlor.wordpress.com&blog=1445624&post=59&subd=jmlawlor&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>Problem:<br />
I was tired of having all of my data models for my project in the same doc as the rest of my functional code.  I wanted to move it all to a models.py file.</p>
<p>Resolution:<br />
Simply create a new file and then copy/paste the datamodels into it.  Remember to include the import for the google app engine data model library.<br />
Models.py<br />
<code><br />
from google.appengine.ext import db</code></p>
<p>class Thing(db.Model):<br />
Text = db.StringProperty(multiline=True)<br />
Author = db.UserProperty()<br />
Created = db.DateProperty()<br />
Ratings = db.ListProperty(db.Rating)<br />
Tags = db.ListProperty(db.Category)<br />
&#8230;</p>
<p>worker.py<br />
<code><br />
from models import *<br />
</code></p>
<p>Further, I thought it would be sweet to actually have my models in a separate folder under my project.  This fits my C# based view of the world and how i was brought up declaring classes in their own document.  So New Problem.</p>
<p>Same as original but in a sub folder.</p>
<p>I found a great stackoverflow.com question/answer for this. At http://stackoverflow.com/questions/279237/python-import-a-module-from-a-folder</p>
<p>Briefly, It says to use do the same as above with the models but with 2 additional pieces.</p>
<p>First, create the folder and create a new file __init__.py.  This file can remain empty but will tell python that this folder is essentially and external package and that the name should be treated similarly to a name space.</p>
<p>Second, Update the import statement in worker.py to<br />
<code><br />
from datamodels.models import *<br />
</code></p>
<p>This works like a charm.  Thanks to the stack overflow guys that worked this out.  follow the link and up the question/answer pair if you found this article useful.</p>
<p>Thanks,</p>
<p>John.</p>
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/jmlawlor.wordpress.com/59/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/jmlawlor.wordpress.com/59/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/jmlawlor.wordpress.com/59/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/jmlawlor.wordpress.com/59/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/jmlawlor.wordpress.com/59/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/jmlawlor.wordpress.com/59/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/jmlawlor.wordpress.com/59/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/jmlawlor.wordpress.com/59/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/jmlawlor.wordpress.com/59/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/jmlawlor.wordpress.com/59/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=jmlawlor.wordpress.com&blog=1445624&post=59&subd=jmlawlor&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://jmlawlor.wordpress.com/2009/05/18/gae-qa-externalizing-model-class-def-to-file/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/85fe7fa9d54881dcec5f5bb7d7196a0a?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">jmlawlor</media:title>
		</media:content>
	</item>
	</channel>
</rss>