Articles in the How It Works category

SQLAlchemy Cascade Delete: Clarity through Examples

By Eric — 10 minute read

Since there is overlapping "cascade delete" functionality supported by SQLAlchemy -- with the ORM handling some deletes and the database itself handling others -- it can be hard to know the right way to set it up. Here are some examples to help clarify how it all works.

Starting Example

Here we …

Read more...

Public Key Cryptography Made Easy

By Eric — 2 minute read

Learning about cryptography can be discouraging. You get so bombarded by "don't invent your own", "you're doing it wrong", and "even really smart people screw this up" that you wonder why you even bother to try. For me, the answer is because if you don't learn it, someone who knows …

Read more...

SQLAlchemy with Python 64-bit on Windows

By Eric — 2 minute read

While hooking up SQLAlchemy for a web project, I kept running into attribute errors for 'session_registry'. I figured I was doing something wrong, so I thought I'd just walk through the tutorial as a sanity check.

I was, apparently, insane.

>>> u = session.query(User).filter_by(name='ed').first()
Traceback (most …

Read more...

Python Packaging (2013 Edition)

By Eric

About a year ago, I set out to get a solid working understanding of Python packaging, resulting in a lengthy blog post of what I learned. There have been some significant course changes over that year such that my original post is wrong in several regards.

Here's a summary of …

Read more...

Python Packaging Demystified

By Eric — 6 minute read

IMPORTANT: Some of the information in this post is now obsolete. Please see here.

Randomly take a couple of words from the following list, put them together, and there's a decent chance you'll come up with something real involving Python packaging.

  • setup
  • install
  • dist
  • distribute
  • tools
  • utils
  • easy
  • py

The …

Read more...

MessageBox: Just Say Nein

By Eric — 1 minute read

The Windows MessageBox is really convenient to use. A single line of code gets you a dialog box with a caption, a message, an icon and a set of available buttons that cover a lot of possible input scenarios. Unfortunately, the text on the buttons is supplied by the system …

Read more...

.NET Color Struct Equality

By Eric

When is white not white? When one is Color.White and the other is Color.FromArgb(0xff, 0xff, 0xff, 0xff).

I was trying to data bind a list of colors to a ComboBox and have the SelectedValue property bound to a particular color. The frustrating thing was that even though …

Read more...

.NET Cold Startup Performance: More

By Eric — 2 minute read

A few months ago I wrote about an approach to improving .NET cold startup performance. Here's a little more information that I've learned since then.

Another useful tool for optimizing cold startup is Microsoft's free CLR Profiler 2.0. While this tool has the aesthetics of a wadded-up paper sack …

Read more...

Corrupt docx File After Adding Custom Properties Part

By Eric — 4 minute read

I spent a few days implementing a component that adds some custom properties to Office 2007 files. Using the System.IO.Packaging namespace from .NET 3.0, and looking at some sample code in some Visual Studio snippets, things went pretty smoothly. Just when I thought I was done, though …

Read more...

.NET Cold Startup Performance: An Example

By Eric — 6 minute read

When running a .NET application for the first time after rebooting or hibernating the computer, you might find that it takes a long time to start up. I've been trying to address this problem in a few situations recently. In spite of having read several articles on the subject, I …

Read more...