Creating an easy-use framework for Python applications

Recently I have been working on a framework for database driven Python applications.

Current code can be found here.

The idea here is to abstract the database work from the programming of the application.  Instead of writing a series of complex SQL commands to modify and migrate database tables, you can simply edit a single row in the `ApplicationData` or `DocumentDictionary` tables, and accomplish the work of a whole database migration with a simple `update` statement.

Data

All data is stored as JSON values, so if, for example, you would traditionally have a table like this:

point2d
id x-value y-value
1 0 0
2 1 1

With this framework, you would simple create an entry in the `DocumentDictionary` table for each of the columns, specifying the DocType, FieldName, and a few other things. Then, when creating a new Document of type `point2d`, the framework would create an entry in the `DocumentData` table, with the JSONData looking something like `{‘x-value’: 0, ‘y-value’: 0}`.

One of the downsides to using this system is that it adds computational overhead to database and data access. I believe that the ease-of-use justifies this, and the abstraction allows for more readable code overall.

Classes

Currently the framework provides a set of 4 classes to be used when programming.

  • framework.Framework(db = ‘/DB/application.sqlite’)
    • You’d instantiate this at the start of your application, optionally specifying your database location if it is different than the standard.
    • Stores all your important stuff in Memory, such as your current DocumentTypes, and currently open Docs
  • framework.Document()
    • Can be created anytime, by any object. Stores data in JSON, as seen in the DB structure.
    • Calling Document.commit() will write your Document to the database.  You should avoid doing this directly, because if Document().__dict__[“id”] already exists, you are going to overwrite it and lose your data.
  • framework.DocumentType()
    • Has two instance variables, one containing a string stating the DocType, the other being a list of framework.Field() s.
    • These are loaded from the database by Framework().loadDocTypes() , but you can create them yourself and write them to the database at will.  Please make sure that you do not overwrite anything important.
  • framework.Field()
    • Simply specifies a Field for use in a DocType
    • Corresponds to a typical Column in a database structure
    • Can be manually created and added to a DocType to create new “columns” in the database

Simple AltCoin written in Python

In this day and age, nearly everyone has had some kind of exposure to cryptocurrencies.  Bitcoin has been massively popular over the past couple of years, and has sparked the creation of thousands of so called “Alt-Coins”.   Alt-Coins are essentially bitcoin clones that add new features, algorithms, etc to their codebase to allow for a broad spectrum of capabilities.

To the average coder though, the Bitcoin codebase is all but inaccessible.  The code behind Bitcoin is incredibly complex, and requires maintainers and contributors to be very familiar with the way that Bitcoin works and how the network operates.

This is where BasicCoin came in.  BasicCoin was created by Zack-bitcoin to simplify the code behind crypto-currencies.  BasicCoin uses a simple sha-256  hashing algorithm, and consists of just a few Python files.

From BasicCoin, I am developing MyCoin (the name is a work in progress.  I haven’t decided on a final name yet.).   The plan is to use the x11 mining algorithm for coin production, and the primary goal is just to keep the coin simple.  Progress can be tracked at the project github page.  Currently, only OSX is supported, due to syntax differences between OSX, Linux, and Windows.  For any suggestions, just submit an issue to the issue tracker, or submit a pull request!

How to make your own iPod

Nearly 4 years ago, I built an ipod out of spare parts from ebay.  I wrote most of the tutorial on how to do so at that time, but I never got around to finishing it or publishing it.  As of yesterday, the tutorial can be seen for free online on Instructables.  It is a pretty easy build, and I learned quite a bit from it.  Good luck!

Apps

I have been developing a couple of iPhone apps for the past few weeks, and one is turning out really well.  It is a GPS based app that alerts you of any nearby historical markers, and allows you to view information about that historical place/monument without ever having to type anything in.  I am making this app mainly for my dad, who has been looking for an app like this for years, but I will probably publish it to the app store as well.

Currently in Progress:

  • obtaining and processing a government database of the NRHP(National Register of Historic Places)
  • coding the App
  • figuring out a name for it.

If you have a suggestion for a name, email me at mailto:jperoutek@gmail.com

TroopPress WordPress plugin

This wordpress plugin was made to allow troops to build wordpress websites, and have a clearly defined hierarchy of user roles.  Each role has its own permissions set, and (eventually) the permissions will be adjustable through the settings page.  Attached is an excel file with a list of the current permissions set.  There is no current release available, but there will be soon.  Current unreleased beta version is 0.2.4.

 

perms