Log on:

Blog :: All

You can filter this page to certain types of posts:

December 04, 2008

Howdy Folks,

The ElementTree library is an excellent way to allow your Python apps to read and manipulate XML files in a Pythonic manner.  But what do you do if you want to create XML from a Python object with arbitrary dictionaries and lists?

To tackle this task, I have created the recursive xmlObjectCreator.  Its code is noted below.  When you pass it an arbitrary Python object and a few other parameters, it will give you back an ElementTree representing the Python object.  You can then dump or write the tree to your heart's content.

There is one caveat, however.  To avoid unneeded complexity, I did not provide any method by which you can describe metadata.  This basically means that for lists, the actual items will have element names set to the list name plus a static string.  So, you might have myList['One', 'Two'], and it would generate XML like this:

<myList><myList_item>One</myList_item><myList_item>Two</myList_item></myList>

To run the method, you do this:

xmlObject = xmlObjectCreator
(inputObject, topLevelTag, etreeRootObj, structType, etreeRootObj, True)

The input parameters are as follows:

  1. inputObject.  This your arbitrary Python structure.
  2. topLevelTag.  This is the tag that you want your root level object to have.
  3. etreeRootObj (parameters 3 and 5).  This is a valid ElementTree tree object.  It should not have any elements.
  4. structType: an empty string.  This is used internally during recursion.
  5. True.  This is always set to True.

The extra string parameter, root object paremeter and the tailing True are needed because the method is recursive, and it will pass different values for these paremeters depending on the depth of recursion and the current object it's working on.  Some folks have suggested alternate, cleaner ways to handle this - and those ways will be implemented in future revisions of the library.

xmlObjectCreator.py

UPDATE:  I've updated the code to use introspection instead of try/catch exception blocks.

xoc.py

Keywords: generator, object, python, recursion, recursive, xml

Posted by Joshua Kramer | 0 comment(s)

August 10, 2008

It had to happen sooner or later.  I'm pleasantly shocked, however, that it happened here in Ohio.

"Brunner is seeking punitive damages from Diebold, now Premier Election Solutions, after she said an investigation showed that votes in at least 11 counties were "dropped" in recent elections when memory cards were uploaded to computer servers."

D'OH!  I hate when that happens, when votes are dropped.  But you know, it wasn't Diebold's fault.  Really.  It was the fault of the anti-virus software...

"But he said a conflict was identified involving the company's software and virus-protection software. A product advisory was issued in May, but Brunner said her office still is reviewing that explanation."

Errr... they need to run anti-virus software on computers that are a) supposed to be certified, and b) not even on a network?  Come on, folks.  You know it's incompetence when a company designs one of the machines most critical to our democracy, using the technological equivalent of Lincon Logs.  Given the platform, I'd expect there to be problems, and Diebold ought to pay for it.

Keywords: accuvote, brunner, diebold, lawsuit, ohio, premier election systems, voting

Posted by Vote 2008! - Joshua Kramer | 0 comment(s)

August 02, 2008

Here, I present the Public Service Announcement for poll workers in Knox County.

Please download and distribute!

WeWantYou-Knox-2.pdf

Keywords: election, knox county, poll worker, PSA

Posted by Vote 2008! - Joshua Kramer | 0 comment(s)

Howdy Folks,

Here, I present the Public Service Announcement for poll workers in Franklin County.

Working the polls is a great easy way to serve your country.  Poll workers will be in demand in the coming years, as many of them are older and retiring.  As an added bonus, poll workers are paid!

Please download and distribute!

WeWantYou-Franklin-2-rev2.pdf

Keywords: election, franklin county, ohio, poll workers, voting

Posted by Vote 2008! - Joshua Kramer | 0 comment(s)

...take one down, pass it around, and brace yourself for 97 more days of campaigning!

Welcome to GlobalHerald.NET, The Smarter Social Network (tm).  This is our coverage of Election 2008.  Check back on this space for up-to-the-minute coverage!

Here are a few important numbers for our viewers in Central Ohio to keep in mind:

Franklin County Board of Elections, covering Bexley, Columbus, and Westerville (OSU, Capital, Otterbein): 614-462-3100

Knox County Board of Elections, covering Gambier and Mount Vernon (Kenyon College, Mount Vernon Nazarene University): 740-393-6716.

Keywords: capital, election, introduction, kenyon, otterbein

Posted by Vote 2008! - Joshua Kramer | 0 comment(s)

July 27, 2008

Is the power that corporations have today to write laws in their favor due to a clerical error made in the 1800's?

In this paper,  I will describe how the warnings given by Adam Smith about merchantilists in his book "The Wealth of Nations" apply to today's corporations.  It is popular to cite Smith when discussing the power of the free market in a favorable light.  In The Wealth Of Nations, Smith described what occurred when commercial interests - in his day, the merchantilists - and the government became too entwined in their actions and relationships.  A clerical error committed in the 1800's by a Supreme Court clerk allows today's commercial interests and governments to be similarly entwined with a substantially larger effect.

While Smith is normally quoted when defending the actions of corporate culture, I surmise that Smith would actually give us the same warnings today about our corporations that he did the citizens of his day about merchantilists.  This paper describes why.

 Showcase-July08-Kramer.pdf

Keywords: adam smith, constitution, corporatism, liberty, merchantilists, supreme court, the wealth of nations

Posted by GlobalHerald.NET Showcase - Joshua Kramer | 0 comment(s)

July 15, 2008

"Never let the future disturb you. You will meet it, if you have to, with the same weapons of reason which today arm you against the present." --Marcus Aurelius Antoninus (Meditations)


Energy prices.  The disjuxtaposition of the mortgage system in the U.S.  The decline of fish stocks near the coasts.

So what's with the future, anyway?  Some things, such as the mortgage mess and resulting economic turmoil, are a result of the need for instant gratification of a large number of our brothers and sisters.  These things are but a blip in the geohistorical radar, much like the Great Depression.  They may be a large disrupting effect on human systems of exchange, but can be recovered from.

However, as citizens of the Earth, we seem to have reached a few geological  "hard limits".  Indeed, we seem to have created some of them ourselves.  The two biggest hard limits I am speaking of are climate change and the end of cheap oil.  Regardless of the root causes of these problems - whether human events are the cause of global warming, or it is a geological cycle; and whether we have reached "peak oil" or still have a few years to go - the symptoms created by these problems present some unique challenges for our species in the coming decades.  Will we run out of oil and reach a point where we don't have enough energy or raw materials to continue even the most basic scientific research?  Or will we 'power through' the next few decades and become an interstellar species?

"Take hold of the future or the future will take hold of you - be futurewise." -- Patrick Dixon - Futurist and author Futurewise 1998/2005

There are a number of interesting resources to start a brainstorm about the future.  Some of these have a basis in reality, and some are intended to be pure science fiction.

http://www.btplc.com/Innovation/News/timeline/TechnologyTimeline.pdf

http://www.btplc.com/innovation/news/timeline/

http://www.trekmania.net/conference/chronology.htm 

Keywords: future, futurist, timeline

Posted by Joshua Kramer | 0 comment(s)

May 26, 2008

Howdy Folks,

I have an article up on Packt Publishing's Article Network here:

Click Here

This article shows how to secure your web-based Python applications with mod_wsgi and SELinux on RHEL5 (or CentOS 5 for that matter).

More blog posts to come shortly!

Cheers,

-J

 

Keywords: linux centos rhel selinux python mod_wsgi security secure

Posted by Joshua Kramer | 0 comment(s)

November 18, 2007

For a while now, I've been a fan of the CBS show Numb3rs.  Like many CBS shows, it exhibits a tad bit more depth than most prime-time shows.  The bits of math thrown in to the plot tickle my  neurons in an interesting way, and the action balances it out.  For the most part, at least up until this 4th season, it seemed as if the producers made a concerted effort to integrate the math into the plots and explain it in some detail.  However, this last season seems to be a bit 'off' in this regard - to appeal to a more mainstream audience, it seems they're relegating the math to the background.

I had intended to create a blog section on the math aspects of the show, but the folks at Wolfram publishing beat me to it.  Here's the link: http://numb3rs.wolfram.com/

The show used to do a very good job of avoding "T.V. Science", that bad habit of show producers to invent whatever science happens to be handy for solving their plot.  However, this last episode (aired on November 16) delivered a couple of doozies.

For the record, here is what a real DTMF decoder looks like:

DTMF Decoder

It's not the size of a PC's motherboard, with heatsinks and all that.  Decoding the DTMF tones won't tell you anything except what numbers were dialed - it surely won't pull up the location of the phon on Google Maps.  And who solders circuits without cutting the power, anyway?

 

Posted by Joshua Kramer | 0 comment(s)

November 11, 2007

I have a book called Vectors and Smoothable Curves by William Bronk.  Upon entering the title in Google, I get the following suggestion:

 

Posted by Joshua Kramer | 0 comment(s)

<< Back