<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/rss2full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><rss 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/" version="2.0">

<channel>
	<title>DevChix » Python</title>
	
	<link>http://www.devchix.com</link>
	<description>Boys can't have all the fun</description>
	<pubDate>Sun, 22 Nov 2009 01:48:11 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.7.1</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" href="http://feeds.feedburner.com/devchix/mNrv" type="application/rss+xml" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com" /><item>
		<title>PyArkansas: Small town, big tech!</title>
		<link>http://www.devchix.com/2009/11/21/pyarkansas-the-big-bang-in-a-small-town/</link>
		<comments>http://www.devchix.com/2009/11/21/pyarkansas-the-big-bang-in-a-small-town/#comments</comments>
		<pubDate>Sun, 22 Nov 2009 00:54:40 +0000</pubDate>
		<dc:creator>gloriajw</dc:creator>
		
		<category><![CDATA[Django]]></category>

		<category><![CDATA[Events]]></category>

		<category><![CDATA[People]]></category>

		<category><![CDATA[Python]]></category>

		<guid isPermaLink="false">http://www.devchix.com/?p=413</guid>
		<description><![CDATA[Last weekend I flew out to to Little Rock, Arkansas, took a two hour crawl through a snarl of traffic, and arrived just in time for my Friday night pre-PyArkansas tutorial in Conway. Held on the stunning campus of Hendrix College, I wended my way around buildings, a massive fountain, inspiring structures, until I found [...]]]></description>
			<content:encoded><![CDATA[<p>Last weekend I flew out to to Little Rock, Arkansas, took a two hour crawl through a snarl of traffic, and arrived just in time for my Friday night pre-PyArkansas tutorial in Conway. Held on the stunning campus of Hendrix College, I wended my way around buildings, a massive fountain, inspiring structures, until I found the building where my tutorial was about to happen. Standing in the foyer with the beautiful Foucault pendulum, I could not help but to stop for a moment, exclaiming &#8220;Oooo!!!!&#8221; aloud, wishing I had gotten there thirty minutes earlier. </p>
<p>My tutorial was intended to encourage women in computer science by serving two purposes: discussing the source code and functionality of a particular project, and openly discussing some of the issues they faced in their current programs and surroundings. I was pleasantly surprised to discover that these women needed no technical or social encouragement. They are already enthused, technically and socially well prepared, and on their way to a very bright future in engineering or computer science. I was pleasantly surprised that they were very comfortable in the bash shell, and as comfortable in their current college curriculum. Like children at play, they picked up the moderate-levelled tutorial code quickly, made great strides in such a short time, and had a lot of fun doing it. </p>
<p>It was profoundly encouraging to see such a small computer science program achieve diversity as well as such a high level of skill. It made me wonder why larger colleges and universities cannot accomplish the same on bigger budgets, with larger staff, and a more diverse mix of students. It touched me to hear and see the enthusiasm, eagerness, and skill of the students in this program. Their learning experience under the Department Chair, Dr. Burch, comes as close to perfect as I have ever seen. </p>
<p>The next day&#8217;s events at PyArkansas were held at the also-very-nice campus of University of Central Arkansas, where an entire day&#8217;s worth of tutorials took place. Two Python 101 tracks were held: one for programmers and one for non programmers (a great concept). An all-day Django Track was given, where the advanced course was taught by <a href="http://jacobian.org/">Jacob</a> himself. I held an afternoon tutorial addressing advanced Python concepts, with downloadable example code, where we compared and contrasted build and deployment tools, played with regex, and showed examples of some internal Python oddities involving static variables. I unfortunately missed the Python Blender tutorial, held at the same time as mine, and I heard it went quite well. </p>
<p>The campus facilities were very accomodating. Everything was well organized,and  up and running for us when we arrived. This is a very welcome surprise to anyone who has travelled a bit to do tutorials. I was specifically told by Dr. Chenyi Hu, the Department Chair of UCA, that he really does care about diversity, and it is something they strive to achieve. This was truly touching, quite impressive, and a pleasant surprise from such a small town. </p>
<p>Kudos to Greg Lindstrom, Dr. Carl Burch of Hendrix College, Dr. Chenyi Hu of UCA, and everyone else involved. You induced a big technical &#8220;tremor&#8221; through your small town, which echoed far and wide. It is yet another example of the great people drawn to the Python community, and the amount of quality effort they are willing to give back. I feel honoured to have been part of this event, and I hope to be involved in many more to come. </p>
<p>Gloria</p>
]]></content:encoded>
			<wfw:commentRss>http://www.devchix.com/2009/11/21/pyarkansas-the-big-bang-in-a-small-town/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Job posting!</title>
		<link>http://www.devchix.com/2009/09/18/job-posting/</link>
		<comments>http://www.devchix.com/2009/09/18/job-posting/#comments</comments>
		<pubDate>Fri, 18 Sep 2009 17:53:14 +0000</pubDate>
		<dc:creator>gloriajw</dc:creator>
		
		<category><![CDATA[Business]]></category>

		<category><![CDATA[Jobs]]></category>

		<category><![CDATA[Python]]></category>

		<category><![CDATA[Thoughts]]></category>

		<guid isPermaLink="false">http://www.devchix.com/?p=366</guid>
		<description><![CDATA[A large, successful bakery in NYC wants to grow their online presence in the social app space, blogosphere, and related web sites. They need a person (who does not have to be a NYC resident, but will visit occasionally) who knows how to:
(1) Find related web sites and drop relevant strategic links on those sites [...]]]></description>
			<content:encoded><![CDATA[<p>A large, successful bakery in NYC wants to grow their online presence in the social app space, blogosphere, and related web sites. They need a person (who does not have to be a NYC resident, but will visit occasionally) who knows how to:</p>
<p>(1) Find related web sites and drop relevant strategic links on those sites without &#8220;spamming&#8221;.<br />
(2) Create an online social app/blog presence for this company, announcing new products, philanthropic events, etc. for this company.<br />
(3) Follow accounts at Facebook, MySpace, product blogs, etc. Help set up the look and feel of these sites (working alongside a writer, a designer, and a software developer).<br />
(4) Help us build this presence in creative ways: event photo slideshows, podcasting interviews of the owners, the technical aspects of the company, etc.</p>
<p>Please submit a resume and some examples of your work online. Also give me an example of how you would promote such a situation. Creativity is definitely encouraged:</p>
<p>I am handling the system admin and software design/development. Over the next few months, I&#8217;ll be taking it in new directions, by bringing in a free Python apprenticeship training group, and using this site as training ground for people new to Python. This will bring it some social exposure from the tecchie direction. How and where would you discuss this unique approach of growing a business while providing a public service?</p>
<p>Please send email to gloriajw_66, at the address yahoo dot com </p>
<p>Thank you, and good luck!<br />
Gloria </p>
<p>PS: Working alongside me means this job _always_ has the opportunity to morph in a more technical direction, if you so choose. This straddles many disciplines, and can turn out to be quite fun if you wish to expand your current knowledge. </p>
]]></content:encoded>
			<wfw:commentRss>http://www.devchix.com/2009/09/18/job-posting/feed/</wfw:commentRss>
		</item>
		<item>
		<title>I Love Python: ReSTful DB CRUD dispatching using CherryPy</title>
		<link>http://www.devchix.com/2009/04/19/i-love-python-restful-db-crud-dispatching-using-cherrypy/</link>
		<comments>http://www.devchix.com/2009/04/19/i-love-python-restful-db-crud-dispatching-using-cherrypy/#comments</comments>
		<pubDate>Sun, 19 Apr 2009 15:57:49 +0000</pubDate>
		<dc:creator>gloriajw</dc:creator>
		
		<category><![CDATA[Book]]></category>

		<category><![CDATA[Database]]></category>

		<category><![CDATA[Python]]></category>

		<category><![CDATA[Servers]]></category>

		<category><![CDATA[Thoughts]]></category>

		<guid isPermaLink="false">http://www.devchix.com/?p=230</guid>
		<description><![CDATA[CherryPy has been one of my favorite Python tools for several years. It should be mentioned here that a ReSTful dispatcher could easily be written in web.py, or pylons as well, and even comes for free in the latest TurboGears implementation. 
But if you&#8217;re looking for a small, easily manageable and extremely dynamic ReST dispatching [...]]]></description>
			<content:encoded><![CDATA[<p>CherryPy has been one of my favorite Python tools for several years. It should be mentioned here that a ReSTful dispatcher could easily be written in web.py, or pylons as well, and even comes for free in the latest TurboGears implementation. </p>
<p>But if you&#8217;re looking for a small, easily manageable and extremely dynamic ReST dispatching solution without the heft of an entire web framework, I&#8217;m about to show you how CherryPy can help you in three different ways, depending on your model.</p>
<p>Assuming this mapping:</p>
<p>HTTP GET or HEAD = DB Read<br />
HTTP POST = DB update<br />
HTTP PUT = DB insert<br />
HTTP DELETE = DB delete</p>
<p>Let&#8217;s also standardize on one common method across all examples, for determining the HTTP request type, and matching it to the function of the same name. Here is the full code snippet for accomplishing this task:</p>
<pre>
methods = ('OPTIONS','GET','HEAD','POST',
'PUT','DELETE','TRACE','CONNECT')

if cherrypy.request.method not in self.methods:
    raise cherrypy.HTTPError(400,'Bad Request')

# If request method is HEAD, return the page handler
# for GET, and let CherryPy take care of dropping
# the response body
method = cherrypy.request.method

if cherrypy.request.method == "HEAD":
    method = "GET"

http_method = getattr(self,method)

#print "HTTP Method: %s" % method

result=(http_method)(args,kwargs)
</pre>
<p>In our examples, we&#8217;re going to shorten this to:</p>
<pre>
http_method = getattr(self.m,cherrypy.request.method)
return (http_method)(args,kwargs)
</pre>
<p>All of this essentially determines how HTTP was called (GET/PUT/POST/DELETE), and calls the method in a class which exactly matches this name (self.GET(), self.PUT(), etc)<br />
When you see this code, know that it&#8217;s just the HTTP method resolving code. </p>
<p>Now for the fun. Let&#8217;s look at the dispatcher options we have. </p>
<h3>Way 1: A hard-coded URL pointing to fixed resources: </h3>
<p>CherryPy can be used in a manner similar to this to establish a fixed URL, and corresponding resources, driven from predefined classes instantiated in the &#8216;root&#8217; hierarchy:</p>
<pre>
import cherrypy

class ReSTPaths1:
	@cherrypy.expose
	def index(self):
		http_method = getattr(self,cherrypy.request.method)
		return (http_method)()

	def GET(self):
		return "In GET 1.."

class ReSTPaths2:
	@cherrypy.expose
	def index(self):
		http_method = getattr(self,cherrypy.request.method)
		return (http_method)()

	def GET(self):
		return "In GET 2.."

class ReSTPaths3:
	@cherrypy.expose
	def index(self,client_id=None):
		http_method = getattr(self,cherrypy.request.method)
		return (http_method)(client_id)

	def GET(self,client_id=None):
		return "IN Get 3, your client_id is %s\n" % (client_id)

cherrypy.server.socket_port=8081

root=ReSTPaths1()
root.client = ReSTPaths2()
root.client.address = ReSTPaths3()
cherrypy.quickstart(root)
</pre>
<p>Once this is running, the URL to invoke it looks like this:<br />
http://localhost:8081/<br />
http://localhost:8081/client/<br />
http://localhost:8081/client/address/<br />
http://localhost:8081/client/address/?client_id=34567<br />
http://localhost:8081/client/address/34567</p>
<p>Output looks something like this:</p>
<pre>
In GET 1..
In GET 2..
IN Get 3, your client_id is None
</pre>
<p>If you&#8217;re new to CherryPy or Python in general, I&#8217;ll reiterate for you how we are calling the GET method in our class. </p>
<p>When we issue this request, we&#8217;re issuing what HTTP calls a GET request:</p>
<p>http://localhost:8081/</p>
<p>The CherryPy service above, listening on port 8081, calls the index() method on the root class. The root class was set to:</p>
<p>root=ReSTPaths1()</p>
<p>at the bottom of that file. The index() method from the ReSTPaths1 Class looks like this, at the top of that file:</p>
<pre>
	def index(self):
		http_method = getattr(self,cherrypy.request.method)
		return (http_method)()
</pre>
<p>If we were to insert a print cherrypy.request.method statement before the return, we would see it set to &#8220;GET&#8221;. </p>
<p>getattr simply says: &#8220;get me the function name in self, matching the string &#8220;GET&#8221;.<br />
it returns a reference to self.GET(), which is set directly below the index:</p>
<pre>
	def GET(self):
		return "In GET 1.."
</pre>
<p>Notice that the index() method has a <strong>@cherrrypy.expose</strong> decorator above it. This makes the index method callable by the public. The GET method does not have it, which means we could never invoke the GET method by typing:</p>
<p>http://localhost:8081/GET</p>
<p>If you try this, you&#8217;ll get a 404 Not Found error, because it&#8217;s not visible through the CherryPy interface.</p>
<p>GET() has to be invoked through index(), which means GET can only be called if an HTTP GET request is issued. If we posted form data to this same URL from, say, a form entry asking people for data input, we would need to add a POST method to this ReSTPaths1() class, to receive the POST data entered in the form fields.</p>
<p>Now back to our example:</p>
<p>In this example, no part of the URL or associated resources are dynamic, in either initialization or run time. This is fine, and suits the needs of most ReSTful CRUD interfaces. </p>
<h3>Way 2: URL paths and associated components dynamically set once, upon dispatcher init/startup: </h3>
<p>Now let&#8217;s say we want to determine the contents of the root, and therefore the URLs and associated resources for our ReSTful interface, dynamically during initialization/startup. </p>
<p>We can assign the root setting by using a Python metaclass to generate classes in our CherryPy startup code, and set the root components to each generated class. This goes beyond the average needs for CRUD access, but it&#8217;s such a nice implementation that I must show it off:</p>
<pre>
import cherrypy

class MetaCRUD(type):
	@cherrypy.expose
	def index(cls):
		http_method = getattr(cls,cherrypy.request.method)
		return (http_method)()

	def GET(cls): return "In class ", cls.__name__, ', received a GET request.'

	def PUT(cls): return "In class ", cls.__name__, ', received a PUT request.'

	def POST(cls): return "In class ", cls.__name__, ', received a POST request.'

	def DELETE(cls): return "In class ", cls.__name__, ', received a DELETE request.'

baseCRUD = MetaCRUD('baseCRUD',(),{})
root = baseCRUD

dynamic_class = {}

for d in ['legacy_dbi','new_dbi','some_other_dbi']:
	dynamic_class[d] = MetaCRUD(d,(),{})
	setattr(root,d,dynamic_class[d])

cherrypy.server.socket_port=8081
cherrypy.quickstart(root)
</pre>
<p>Here we&#8217;re using a metaclass, with CherryPy exposed methods, to generate a dictionary of dynamic classes. We set the root.classname = the_new_class by using the setattr() method. </p>
<p>After initialization, URL components and resources are fixed in this model. But wow, the awesome power we have during initialization, in 28 lines really rocks. I wrote this in 30 minutes, and realized again why I am so head-over-heels in love with this language. </p>
<p>When we hit these URLs:</p>
<pre>
http://localhost:8081/
http://localhost:8081/legacy_dbi/
http://localhost:8081/new_dbi/
http://localhost:8081/some_other_dbi/
</pre>
<p>We see this output:</p>
<pre>
In class baseCRUD, received a GET request.
In class legacy_dbi, received a GET request.
In class new_dbi, received a GET request.
In class some_other_dbi, received a GET request.
</pre>
<p>Let&#8217;s issue a POST request via curl, on the command line. The response is returned:</p>
<pre>
[gloriajw@g-monster ~]$ curl http://localhost:8081/some_other_dbi/ -d ""
In class some_other_dbi, received a POST request.
</pre>
<p>This model could be used for, say, reading the contents of the Postgres template1 databases list or the mysql &#8217;show databases&#8217; command, and auto-generating a ReSTful CRUD interface for each. Access of each resources can be controlled via HTTP Auth methods. This is a great solution to providing, and restricting, legacy database access for new processes through a standard interface. </p>
<h3>Way 3: Live, ever-dynamic determination of URL and associated component: </h3>
<p>Some ReSTful URL models may need to be &#8216;run-time dynamic&#8217;, especially in the case where databases are dynamically created, and the associated resources per new database could vary. There is a simple example of a dynamic URL and resource model:</p>
<pre>
import cherrypy
import pprint

class ReSTPaths:
	@cherrypy.expose
	def __init__(self):
		pass

	@cherrypy.expose
	def client(self,*args,**kwargs):
		return "Your HTTP method was %s. Your args are: %s and your kwargs are: %s\n" \
		% (cherrypy.request.method, pprint.pformat(args), pprint.pformat(kwargs))

	@cherrypy.expose
	def address(self,*args,**kwargs):
		return "Your HTTP method was %s. Your args are: %s and your kwargs are: %s\n" \
		% (cherrypy.request.method, pprint.pformat(args), pprint.pformat(kwargs))

cherrypy.quickstart(ReSTPaths())
</pre>
<p>This allows for dynamic URLs such as:<br />
http://localhost:8080/client/address/34567<br />
http://localhost:8080/client/address?client_id=34567<br />
http://localhost:8080/address/client?client_id=34567<br />
http://localhost:8080/address/client/34567<br />
http://localhost:8080/address/anything/anything_else</p>
<p>The output from this code looks like this:</p>
<pre>
Your HTTP method was GET. Your args are: ('address', '34567') and your kwargs are: {}
Your HTTP method was GET. Your args are: ('address',) and your kwargs are: {'client_id': '34567'}
Your HTTP method was GET. Your args are: ('client',) and your kwargs are: {'client_id': '34567'}
Your HTTP method was GET. Your args are: ('client', '34567') and your kwargs are: {}
Your HTTP method was GET. Your args are: ('anything', 'anything_else') and your kwargs are: {}
</pre>
<p>Notice that we only have keyword args (kwargs) when we pass a named parameter, such as client_id=34567</p>
<p>Let&#8217;s try a POST request from curl, on the command line:</p>
<pre>
[gloriajw@g-monster ~]$ curl -d "something_else=whatever_i_want" http://localhost:8080/address/anything/anything_else
Your HTTP method was POST. Your args are: ('anything', 'anything_else') and your kwargs are: {'something_else': 'whatever_i_want'}
</pre>
<p>In this code, the sky is the limit. You can place whatever code you like in these methods, dynamically creating classes and resources as needed, letting them only persist until the result is returned. This may add some inefficiency, but in exchange offer more secure network resources.</p>
<p>Code is attached, Enjoy!</p>
<p>Gloria</p>
<p><a href="http://www.devchix.com/wp-content/uploads/2009/04/restfixedargs.py">http://www.devchix.com/wp-content/uploads/2009/04/restfixedargs.py</a></p>
<p><a href="http://www.devchix.com/wp-content/uploads/2009/04/restmeta.py">http://www.devchix.com/wp-content/uploads/2009/04/restmeta.py</a></p>
<p><a href="http://www.devchix.com/wp-content/uploads/2009/04/restvarargs.py">http://www.devchix.com/wp-content/uploads/2009/04/restvarargs.py</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.devchix.com/2009/04/19/i-love-python-restful-db-crud-dispatching-using-cherrypy/feed/</wfw:commentRss>
		</item>
		<item>
		<title>I Love Python: Twitter Feed/Content Auth and Scrape in One HTTP Request</title>
		<link>http://www.devchix.com/2009/02/21/i-love-python-twitter-feedcontent-auth-and-scrape-in-one-http-request/</link>
		<comments>http://www.devchix.com/2009/02/21/i-love-python-twitter-feedcontent-auth-and-scrape-in-one-http-request/#comments</comments>
		<pubDate>Sat, 21 Feb 2009 18:03:04 +0000</pubDate>
		<dc:creator>gloriajw</dc:creator>
		
		<category><![CDATA[Python]]></category>

		<category><![CDATA[Thoughts]]></category>

		<guid isPermaLink="false">http://www.devchix.com/?p=202</guid>
		<description><![CDATA[This is some lingering code from a GrrlCamp project, written by Gaba. It is such a handy, great little nugget of code.  It logs into a Twitter account and scrapes either the content or the RSS feed (your choice), in one fell swoop, using Base64 encoding of the login and password in the HTTP [...]]]></description>
			<content:encoded><![CDATA[<p>This is some lingering code from a GrrlCamp project, written by Gaba. It is such a handy, great little nugget of code.  It logs into a Twitter account and scrapes either the content or the RSS feed (your choice), in one fell swoop, using Base64 encoding of the login and password in the HTTP request header. Very clever:</p>
<pre>
import urllib2, base64
import sys
import feedparser
#import configuration

class Page:

    def __init__(self):
        self.data = {}
        self.data["url"] = 'http://www.twitter.com/gloriajw'
        self.data["username"] = 'gloriajw'
        self.data["password"] = 'XXXXXXXXXX'

        self.data["urlrss"] = 'http://twitter.com/statuses/user_timeline/18107956.rss'

    def __getitem__(self, key):
        return self.data[key]

    def __setitem__(self,key, value):
        self.data[key] = value

    def getContent(self):
        base64string = base64.encodestring('%s:%s' % (self.data['username'], self.data['password']))[:-1]
        authheader =  "Basic %s" % base64string

        req = urllib2.Request(self.data["url"])
        req.add_header("Authorization", authheader)
        try:
            handle = urllib2.urlopen(req)
        except IOError, e:                  # here we shouldn't fail if the username/password is right
            print "It looks like the username or password is wrong."
            sys.exit(1)

        return handle.read()

    def getRSS(self):
        base64string = base64.encodestring('%s:%s' % (self.data['username'], self.data['password']))[:-1]
        authheader =  "Basic %s" % base64string

        req = urllib2.Request(self.data["urlrss"])
        req.add_header("Authorization", authheader)
        try:
            handle = urllib2.urlopen(req)
        except IOError, e:                  # here we shouldn't fail if the username/password is right
            print "It looks like the username or password is wrong."
            sys.exit(1)

        return handle.read()

    def getData(self):
        """auth = urllib2.HTTPBasicAuthHandler()
        auth.add_password('BasicTest', 'twitter.com', self.data['username'], self.data['password'])

        return feedparser.parse('http://www.twitter.com/statuses/user_timeline/18107956.rss', handlers=[auth])
        """

        return feedparser.parse('http://%s:%s@twitter.com/statuses/user_timeline/18107956.rss' % (self.data['username'], self.data['password']))
</pre>
<p>To invoke it:</p>
<pre>
class Data:
    def __init__(self, entries):
        self.entries = entries

    def save(self):
        pass

    def parse(self):
        pass

    def imprimir(self):
        for item in self.entries:
            print item.title
</pre>
<p>And this:</p>
<pre>
def main():
    page = Page()    

    statuses = page.getData().entries

    data = Data(statuses)
    data.save()

    data.imprimir()    

if __name__ == "__main__":
    main()
</pre>
<p>This code will also be attached, in case of copy/paste mangling.</p>
<p>In both getContent() and getData(), Gaba constructs the HTTP response header so that the encoded username and password are passed in the Authorization section of the header. This is easier and more secure than making two requests, and maintaining session cookies. Very nice indeed. This can be used to sign into any web site which accepts HTTP Basic authentication headers (there are different types of HTTP authentication (BASIC, DIGEST, FORM, and CLIENT-CERT).</p>
<p>It is left as an exercise for you to get the content (not the feed) and use BeautifulSoup to extract the data portions. If you want to try this, and need help, post questions here. </p>
<p>Enjoy,<br />
Gloria</p>
]]></content:encoded>
			<wfw:commentRss>http://www.devchix.com/2009/02/21/i-love-python-twitter-feedcontent-auth-and-scrape-in-one-http-request/feed/</wfw:commentRss>
		</item>
		<item>
		<title>PyCon is coming soon, watch for us!</title>
		<link>http://www.devchix.com/2009/01/27/pycon-is-coming-soon-watch-for-us/</link>
		<comments>http://www.devchix.com/2009/01/27/pycon-is-coming-soon-watch-for-us/#comments</comments>
		<pubDate>Tue, 27 Jan 2009 18:08:53 +0000</pubDate>
		<dc:creator>gloriajw</dc:creator>
		
		<category><![CDATA[Python]]></category>

		<guid isPermaLink="false">http://www.devchix.com/?p=197</guid>
		<description><![CDATA[I&#8217;ll be doing a tutorial on Kamaelia on Wednesday, March 25:
http://us.pycon.org/2009/tutorials/schedule/1AM7/
Alex McFerron is my assistant. 
The fee which I would normally collect to teach this tutorial at PyCon (something like $750) will be donated to Alex&#8217;s Math Circle Outreach for kids.
All tutorials will be videotaped and put somewhere on the net. Exciting, eh?  Watch [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ll be doing a tutorial on Kamaelia on Wednesday, March 25:</p>
<p>http://us.pycon.org/2009/tutorials/schedule/1AM7/</p>
<p>Alex McFerron is my assistant. </p>
<p>The fee which I would normally collect to teach this tutorial at PyCon (something like $750) will be donated to Alex&#8217;s Math Circle Outreach for kids.</p>
<p>All tutorials will be videotaped and put somewhere on the net. Exciting, eh?  Watch for us. We&#8217;re going to rock this out. </p>
<p>If you&#8217;re at PyCon, feel free to say hi and take me out for a beer, to which I&#8217;ll gladly reciprocate. I&#8217;m staying for all of the tutorials and code sprints. Woot! I can&#8217;t wait!</p>
<p>My email addy: gloriajw_66 at yahoo dot com</p>
<p>Gloria</p>
]]></content:encoded>
			<wfw:commentRss>http://www.devchix.com/2009/01/27/pycon-is-coming-soon-watch-for-us/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Hadoop Streaming and Python: No Jython necessary!</title>
		<link>http://www.devchix.com/2008/12/25/hadoop-streaming-and-python-no-jython-necessary/</link>
		<comments>http://www.devchix.com/2008/12/25/hadoop-streaming-and-python-no-jython-necessary/#comments</comments>
		<pubDate>Thu, 25 Dec 2008 23:25:27 +0000</pubDate>
		<dc:creator>gloriajw</dc:creator>
		
		<category><![CDATA[Design]]></category>

		<category><![CDATA[MySQL]]></category>

		<category><![CDATA[Python]]></category>

		<category><![CDATA[Thoughts]]></category>

		<guid isPermaLink="false">http://www.devchix.com/?p=192</guid>
		<description><![CDATA[Here is another jewel of an article, written by Michael Noll:
http://www.michael-noll.com/wiki/Writing_An_Hadoop_MapReduce_Program_In_Python
As hardware costs plummet and greater bandwidth becomes more affordable, cloud computing becomes even more alluring and feasible for the hobbyist. Working with large data sets is an interesting problem set, now attainable by the average developer with a free LINUX hard drive partition and [...]]]></description>
			<content:encoded><![CDATA[<p>Here is another jewel of an article, written by Michael Noll:<br />
<a href="http://www.michael-noll.com/wiki/Writing_An_Hadoop_MapReduce_Program_In_Python">http://www.michael-noll.com/wiki/Writing_An_Hadoop_MapReduce_Program_In_Python</a></p>
<p>As hardware costs plummet and greater bandwidth becomes more affordable, cloud computing becomes even more alluring and feasible for the hobbyist. Working with large data sets is an interesting problem set, now attainable by the average developer with a free LINUX hard drive partition and some spare time. </p>
<p>Hadoop is essentially a framework, written in Java, for accessing large data sets. For the average developer, it&#8217;s usually used in conjunction with HDFS which is a custom file system designed for stroing large data sets on cheaper hardware. HDFS data is usually stored in units of entire web pages written to disk &#8220;as-is&#8221;. Once stored, this large data set is accessible for parsing and analysis. </p>
<p>Indexing of this data is done via what is called a map-reduce algorithm. The easiest map-reduce algorithm to envision is the word count algorithm. Each word on a page is assigned the value &#8220;1&#8243; in the map portion, then all words are counted by sorting the words and adding their values. The result is a frequency count of each word in a page. This is the simplest of ten well known map-reduce algorithms, found in this white paper:</p>
<p><a href="http://www.cs.stanford.edu/people/ang//papers/nips06-mapreducemulticore.pdf">http://www.cs.stanford.edu/people/ang//papers/nips06-mapreducemulticore.pdf</a></p>
<p>The magic of Michael&#8217;s article is in how to prevent the stringent, often painful Jython interface to Hadoop. This trick is by streaming this data on the command line from his simpler, more Pythonic map-reduce algorithm directly to Hadoop, thereby avoiding the complex Jython interface. Very clever indeed! It would be wonderful to see all of the relatively standard map-reduce algorithms written in Python.</p>
<p>He has a couple of other great articles on exactly how to install and configure Hadoop on Ubuntu here:<br />
<a href="http://www.michael-noll.com/wiki/Running_Hadoop_On_Ubuntu_Linux_(Single-Node_Cluster)">http://www.michael-noll.com/wiki/Running_Hadoop_On_Ubuntu_Linux_(Single-Node_Cluster)</a></p>
<p>and here:</p>
<p><a href="http://www.michael-noll.com/wiki/Running_Hadoop_On_Ubuntu_Linux_(Multi-Node_Cluster)">http://www.michael-noll.com/wiki/Running_Hadoop_On_Ubuntu_Linux_(Multi-Node_Cluster)</a></p>
<p>On top of Hadoop is usually a metdata store, holding high level information about which page sets or data &#8220;chunks&#8221; can be found on which volumes, for efficiency. After attending a cloud computing conference in November, I realized that many companies have chosen to write their own metadata layer using <a href="http://www.hivedb.org/">HiveDB</a>, or custom metadata tools, and many distributed MySQL databases, rather than settling for the expensive commercial solutions. This great work is the primary cause of the proliferation of easily accessible Open Source cloud computing tools. </p>
<p>Another project to watch is called <a href="http://lucene.apache.org/mahout/">Mahout</a>, which is an attempt to make all of the well known map-reduce algorithms generally accessible across multicore Hadoop systems. </p>
<p>I run Fedora 10, and have a bit more work to do, but it is outstanding to see such an easily accessible installation for such a relatively complex set of tools. So many software tools and toys, so little time! </p>
<p>Gloria</p>
]]></content:encoded>
			<wfw:commentRss>http://www.devchix.com/2008/12/25/hadoop-streaming-and-python-no-jython-necessary/feed/</wfw:commentRss>
		</item>
		<item>
		<title>The Creative Commons license, and change.gov: Our new president gets it!</title>
		<link>http://www.devchix.com/2008/12/02/the-creative-commons-license-and-changegov-our-new-president-gets-it/</link>
		<comments>http://www.devchix.com/2008/12/02/the-creative-commons-license-and-changegov-our-new-president-gets-it/#comments</comments>
		<pubDate>Tue, 02 Dec 2008 20:23:58 +0000</pubDate>
		<dc:creator>gloriajw</dc:creator>
		
		<category><![CDATA[Book]]></category>

		<category><![CDATA[Introductions]]></category>

		<category><![CDATA[Python]]></category>

		<category><![CDATA[Thoughts]]></category>

		<guid isPermaLink="false">http://www.devchix.com/?p=189</guid>
		<description><![CDATA[I was really excited and moved to see this:
http://change.gov/newsroom/entry/towards_a_21st_century_government/
This copyright license affects most content on the website change.gov, guaranteeing transparency and the feedom to redistribute and discuss it&#8217;s content. 
All I can say is, wow. This president not only believes in transparency, but understands how to implement it using existing tools and conventions. He understands [...]]]></description>
			<content:encoded><![CDATA[<p>I was really excited and moved to see this:</p>
<p><a href="http://change.gov/newsroom/entry/towards_a_21st_century_government/">http://change.gov/newsroom/entry/towards_a_21st_century_government/</a></p>
<p>This copyright license affects most content on the website change.gov, guaranteeing transparency and the feedom to redistribute and discuss it&#8217;s content. </p>
<p>All I can say is, wow. This president not only believes in transparency, but understands how to implement it using existing tools and conventions. He understands the spirit of Open Source software development, and everything that has come about since this movement began. Imagine an &#8220;Open Government&#8221;, genuinely implemented and influenced by the people, and it&#8217;s hard not to want to get involved.</p>
<p>The change.gov web site has a very nice, simple form, requesting your ideas and suggestions. They already have proposals for nationwide fiber optic broadband, automation and transparency in the patent process, and automation of health insurance data to bring healthcare costs down. There are many more places where technology can automate away inefficient and error prone processes. </p>
<p>We here on DevChix all know how technology has changed our lives. Let them know how it can change a nation. Submit your ideas and suggestions, and let&#8217;s help educate and influence this new administration.</p>
<p>Gloria</p>
]]></content:encoded>
			<wfw:commentRss>http://www.devchix.com/2008/12/02/the-creative-commons-license-and-changegov-our-new-president-gets-it/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Shameless plug</title>
		<link>http://www.devchix.com/2008/11/24/shameless-plug/</link>
		<comments>http://www.devchix.com/2008/11/24/shameless-plug/#comments</comments>
		<pubDate>Mon, 24 Nov 2008 17:01:29 +0000</pubDate>
		<dc:creator>gloriajw</dc:creator>
		
		<category><![CDATA[Python]]></category>

		<category><![CDATA[Thoughts]]></category>

		<guid isPermaLink="false">http://www.devchix.com/?p=188</guid>
		<description><![CDATA[My article appears in this month&#8217;s Python Magazine.
This article was written months ago, and a few small utilities have been created since then, which would have made this article shorter. With the current 8.3 Postgresql distribution comes a new external db creation tool, which eliminates some of the documented weirdness of isolation level 0 DB [...]]]></description>
			<content:encoded><![CDATA[<p>My article appears in this month&#8217;s <a href=" http://www.pythonmagazine.com">Python Magazine</a>.<br />
This article was written months ago, and a few small utilities have been created since then, which would have made this article shorter. With the current 8.3 Postgresql distribution comes a new external db creation tool, which eliminates some of the documented weirdness of isolation level 0 DB creation and access. But other than that, the code associated with this article still serves as a great example of database agnostic ORM methodology in Python. </p>
<p>Please give the sample code a try, and feel free to ask any questions, etc.</p>
<p>Gloria </p>
]]></content:encoded>
			<wfw:commentRss>http://www.devchix.com/2008/11/24/shameless-plug/feed/</wfw:commentRss>
		</item>
		<item>
		<title>From Python 2.6 to PHP 5.2: A circuitous journey</title>
		<link>http://www.devchix.com/2008/11/20/from-python-26-to-php-52-a-circuitous-journey/</link>
		<comments>http://www.devchix.com/2008/11/20/from-python-26-to-php-52-a-circuitous-journey/#comments</comments>
		<pubDate>Thu, 20 Nov 2008 20:02:08 +0000</pubDate>
		<dc:creator>gloriajw</dc:creator>
		
		<category><![CDATA[Book]]></category>

		<category><![CDATA[Introductions]]></category>

		<category><![CDATA[PHP]]></category>

		<category><![CDATA[People]]></category>

		<category><![CDATA[Python]]></category>

		<category><![CDATA[Thoughts]]></category>

		<guid isPermaLink="false">http://www.devchix.com/?p=187</guid>
		<description><![CDATA[When I started heavily using PHP 5.2 (not by choice, I&#8217;ll admit), I was impressed, but I suffered from some incorrect assumptions about what PHP5 is and is not capable of doing. The good news is that it is more object oriented than it&#8217;s predecessor, but has some caveats to consider. Here are some things [...]]]></description>
			<content:encoded><![CDATA[<p>When I started heavily using PHP 5.2 (not by choice, I&#8217;ll admit), I was impressed, but I suffered from some incorrect assumptions about what PHP5 is and is not capable of doing. The good news is that it is more object oriented than it&#8217;s predecessor, but has some caveats to consider. Here are some things to be aware of when switching from a pure OO language to PHP5:</p>
<p>1: A nonexistent PHP array key generates no error or warning. When trying to iterate over a nonexistent array key, a warning occurs. In other languages, both of these conditions throw an exception.</p>
<p>Try this code for example:</p>
<pre>
&lt;?
$dictionary=array('one'=>'got one','two'=>'have two','four'=>'missing three?');
foreach (array_keys($dictionary) as $key)
{
	print "Key is:".$key.", value is:".$dictionary[$key]."\n";
}
print "Try undefined key three, no warning occurs:".$dictionary['three']."\n";
foreach ($dictionary['three'] as $value)
{
	print "Now we're iterating over a nonexistent key:";
	print "Key is: three, value is:".$dictionary['three']."\n";
}
?>
</pre>
<p>Running it results in this output:</p>
<pre>
php test.php
Key is:one, value is:got one
Key is:two, value is:have two
Key is:four, value is:missing three?
Try undefined key three, no warning occurs:

Warning: Invalid argument supplied for foreach() in /root/test.php on line 8
</pre>
<p>If it is vital to me to make sure I am aware of missing keys, I only have two choices. If I need a proactive solution, I have to use the array_key_exists() function to do existence checking before use. If I want a reactive solution, I  write a log scanner, to pick up on these warnings. In every other OO language I have used, an exception was thrown for this condition, and my exception handling determined if the error was vital enough to have to exit immediately or not. This seems like a more efficient way to handle this condition. I would imaging PHP5 does not do this because of it&#8217;s need to be backward compatible with PHP4, but this is a guess. </p>
<p>It would be wonderful to have a -OO flag for PHP, which gives you the option to run PHP and expect more standard, stricter OO behavior in these instances. </p>
<p>2: Warnings cannot be &#8220;caught&#8221; like exceptions. Exceptions and warnings are distinctly separate beasts, and never the twain shall meet. Fine, I thought, maybe I could detect warnings similar to how we detect errors. But it seems like warnings cannot be detected when they happen. There is no PHP code I know of which can check if a warning had occurred in runtime. I tried to detect it using array error_get_last() but to no avail. if you know how, post your trick here.</p>
<p>3: In PHP, &#8216;true&#8217; evaluates to an integer &#8216;1&#8242;. To get the boolean &#8216;true&#8217; value from a &#8216;true&#8217; statement, one needs to var_export() a true statement. Similarly, or maybe not, &#8216;false&#8217; evaluates to no output. Here is an example:</p>
<pre>
&lt;?
print "\nThe raw value of a true statement in PHP:".true;
print "\nThe raw value of a false statement in PHP:".false;
print "\nThe exported value of a true statement in PHP:".var_export(true,true);
print "\nThe exported value of a false statement in PHP:".var_export(false,true);
print "\n";
?>
</pre>
<p>And the output:</p>
<pre>
The raw value of a true statement in PHP:1
The raw value of a false statement in PHP:
The exported value of a true statement in PHP:true
The exported value of a false statement in PHP:false
</pre>
<p>This may not be noticeable to you in a standard expression. But if you&#8217;re doing funky stuff, like using the evaluated expression values as key references into the dictionary of a decision tree, for example, 1 does not equal &#8216;true&#8217;, and the difference matters quite a bit. </p>
<p>4: Long running processes with recursive circular references (such as Doctrine code) run out of memory. This is documented in many places, and the free() function works sometimes. A fix is coming in PHP 5.3. The foolproof solution for my code in production today (youch!) is to periodically restart the daemon. If you&#8217;re cringing right now, know that you&#8217;re not cringing alone. </p>
<p>There may be a part II to this article. Feel free to add your own PHP5 observations. </p>
<p>Gloria</p>
]]></content:encoded>
			<wfw:commentRss>http://www.devchix.com/2008/11/20/from-python-26-to-php-52-a-circuitous-journey/feed/</wfw:commentRss>
		</item>
		<item>
		<title>GEOPY: Rockin’ out geocoding for Python</title>
		<link>http://www.devchix.com/2008/11/12/geopy-rockin-out-geocoding-for-python/</link>
		<comments>http://www.devchix.com/2008/11/12/geopy-rockin-out-geocoding-for-python/#comments</comments>
		<pubDate>Thu, 13 Nov 2008 04:12:09 +0000</pubDate>
		<dc:creator>gloriajw</dc:creator>
		
		<category><![CDATA[Python]]></category>

		<category><![CDATA[python geocoding]]></category>

		<guid isPermaLink="false">http://www.devchix.com/?p=185</guid>
		<description><![CDATA[*waving*
I have a bit of a breather between contracts, so I&#8217;m back from a writing hiatus to show you more nifty Python tools and juicy goodness.
This is yet another great example of Python&#8217;s elegance and ease of use:
http://exogen.case.edu/projects/geopy/
It doesn&#8217;t just geocode. It gives you a common API to just about all of the publicly accessible [...]]]></description>
			<content:encoded><![CDATA[<p>*waving*</p>
<p>I have a bit of a breather between contracts, so I&#8217;m back from a writing hiatus to show you more nifty Python tools and juicy goodness.</p>
<p>This is yet another great example of Python&#8217;s elegance and ease of use:</p>
<p><a href="http://exogen.case.edu/projects/geopy/">http://exogen.case.edu/projects/geopy/</a></p>
<p>It doesn&#8217;t just geocode. It gives you a common API to just about all of the publicly accessible URL-based geocode services. The web page labels which ones require a key for access, and which ones do not. Beautiful!</p>
<p>The library is also able to calculate distances using several different distance approximation formulae, as well as parse out and reformat geographical data. Now this is some nifty <strong>py-candy</strong>, eh?</p>
<p>Nice Job <a href="http://blog.brianbeck.com/">Brian</a>, you rocked this out. </p>
<p>My only gripes are not with this tool at all, but with geocoding in general:</p>
<p>1: Where to get accurate, free IP address geocoding?</p>
<p>2: Why isn&#8217;t this data free for download, damn it? What if I want to use a cross section of it, and store it in my own database, without paying a fortune for it? One day, will Open Street Map be the source for Open Source geocode data which is freely downloadable, thus eliminating the 1000 queries per day limit? </p>
<p>Maybe we should all join forces, and store the results from 1000 queries per day per person, and build this database ourselves? Hmmm&#8230;</p>
<p>Gloria</p>
<p>PS: The geopy project has a code sprint scheduled for this Sunday, Nov. 16. Join in!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.devchix.com/2008/11/12/geopy-rockin-out-geocoding-for-python/feed/</wfw:commentRss>
		</item>
	</channel>
</rss>
