Cantrip Django Imported From Epistula

Djingle Django Scarecrow

One of the concepts you may run into if you read into Python and its fans in great depth (and here I mean Python of the programming type rather than the Monty type) is that of “Guido’s Time Machine”, the number of times when you are thinking “Would it be nice if Python did this…” and you suddenly find that yes, that’s exactly how Python does it, to the point where the only way Guido could have possibly considered all this would be if he already knew.

I’m having the same kind of thing with Django. Frameworks for validation, existing user system, that kind of thing. Stuff like “Do you know what would be nice? If I could do something so that my Logged in User’s Profile appeared in the default scope of a template, so I didn’t have to pass it in every time, and keep throwing it around the program.” and suddenly, there are Context Processors.

The annoying bits are where stuff is under development, or half documented. For example, Having spent a while creating a User Profile system to associate information specific to this system (Authentication code, invite code, email me alerts, for example) and joined it one-to-one with the user system, I then find a tiny little bit of text in the User Auth system docs which says:

get_profile() -- Returns a site-specific profile for this user. Raises django.contrib.auth.models.SiteProfileNotAvailable if the current site doesn't allow profiles.

This sound really close to what I’ve spend a while doing myself, but that is the first, last and only reference to it in the docs that I can find.

OTOH, I’ve now got a system you can log into and register for, and I’ve got a deeper understanding of how Django works. Yay.

Cantrip Imported From Epistula


Dear Futureme, and anyone else who cares the least bit:

Today is the day I started redeveloping Cantrip in Django.

Cantrip fell over a couple of years ago, mostly because I loaded up the specification with so many things I didn’t understand (yet), that just getting a single result from a few hours work was absolutely impossible. There was no low hanging fruit, and before I got something I could use I was going to need to do three weeks solid work with no payoff.

Time to take a couple of steps back.

Cantrip Imported From Epistula programming Python

Cantrip Diary – ZopeTastic

Okay, so my new workplace use Zope, so it’s probably a good idea for me to use that as a framework. I mean, enough people use it for it not to be too bad, right?

Dear god does it suck. I mean, Whales though really thin gauze, it sucks that badly. I got it working on my local network after swearing at it quite loudly. It’s own personal religion of “Not Invented Here” is going to really annoy me, I can tell.

Lets start with the web server. It doesn’t run though Apache without a tremendous amount of futzing around. I like Apache, and run everything else off Apache, so the fact that all my Zope applications will run off a non-standard port (There are fixes for this, yes, but they also require a tremendous amount of futzing around). This is annoying.

Then there is the user system. I have a user account on this machine, you could even talk to it though LDAP. Requiring your own little world to run in – let alone where you don’t tell me the initial username & password, or where the access file is, or anything – is really annoying. Also, it should be noted that in every SINGLE guide I found on how to reset the password manually it missed the fairly basic piece of information that once you have reset the password, you must restart the Zope server otherwise you will spend half an hour working out why it doesn’t take the data. This, admittedly, is partly a Debian Package problem, but since delving has lead me to believe that it used to ask you for a default username and password on configure, and now doesn’t, I’m leaping to the conclusion that whining isn’t going to fix this any.

It should be a default requirement that every Debian package contains a file in /usr/share/docs explaining a) Which configure options were used, b) What you’re going to have to do next to make the package work, and c) Common pitfalls of the above.

Three, the interface. In the last six months or so, the bar for a web-based interface has gone from a minor hurdle to a max-height pole-vault, mostly due to GMail. However, I can state with no fear of derision that <textarea /> is the single most fucking awful method of inputting code since I used a C64 with a broken delete key, and the fact that the physical location of the source files is shielded from me (and will, I suspect, be chowned something silly anyway) means the best way I can see to develop with this pile of shit is to copy/paste from my default text editor, which is just retarded (And yes, that is exactly how I compose blog entries, but I don’t normally need to keep blog entries in CVS). I suspect there is a better way to do this. In fact, I’m sure there must be, or else Zope would be deader than a very dead thing, which brings me to my next point.

The Docs

My first problem with the docs is the inline commenting system. When I’m trying to digest a reasonably complex idea it is of no use whatsoever for the flow of the text to be interrupted constantly by inane slashdotesque comment. On the other hand, without the inline commenting I’d not have known that the introduction to Zope tutorial – which is far better than the one included in the distro – existed, also, I’d have read the chapter on DTML before the chapter on the more advanced, easier to use, designer friendly and new paradigm of Zope Page Templates, which starts off by pointing out how crap everything you read in the previous chapter was. ARGH

Nevertheless, I shall persevere with this Evil, because I’ve got no choice but to know it, in the hope that I will learn my way around it.

Okay, so “find / -iname ZopeZoo” has failed to find any of the files that are part of the tutorial. Where the hell is Zope putting the bloody files? *ARGH*

aqcom aqWiki Cantrip computing epistula escape forever Imported From Epistula quoth web development

Mod Rewrite as a virtual hosting environment

So, I’ve now got control of is going to have a number of subdomains, and I don’t really want to muck around with apache every time I want to add one, or get my Friendly Neighbourhood Sysadmin to do so.

Instead, I want mod_rewrite to do it, which it does. I have a virtualhost that handles *, and passes it on to the following .htaccess file:

RewriteEngine on
RewriteRule     ^.**$        -       [L]
RewriteRule   (.*) %{HTTP_HOST}/$1

Which redirects “” to ”~/sites/istic/”, which is what I want.

That shouldn’t have taken as many hours as it did, so I’m writing it down.

Secondly, I’ve moved my braindump – – to a temporary new home whilst the DNS resolves. By the wonders of my new domain name, it’s temporarily housed at which is possibly the best subdomain ever 🙂

So, my personal “hire me” site could go to “”, I could move all my open source projects to “”, set up a site about religion at ritual.istic, head of into the futur.istic and be all m.istic about it and whenever I got fed up with the whole blogging thing and needed to move, I can always go ball.istic.

This isn’t actually far from the plan, which is to move the far flung tin-pot empires of AqCom that are getting lost under five years of journal archives & articles, and move them to their own domains – or subdomains, or sub-subdomains – where they can live happily ever after.

Cantrip epistula Imported From Epistula

Diary of Cantrip – Episode 4, A New Hope

I’m back on Cantrip, after a month and a half of it being on Hiatus while I attempted to find and get back into the swing of the whole employment thing.

The story so far

Okay, so in case you missed it, that which was known as “PFd4” is now known as “Cantrip” because PFd4 is a heck of a mouthful for a small project.

Small project. Hah.

Today’s job has been structural. I tried to install mod_python and the MySQL bindings onto my local server, but it segfaulted every time, so I’m back to developing live, always fun.

I’m still wavering between using XML/XSLT as a templating engine or something like SimpleTAL. On the plus side, XML/XSLT is another tick on my list of “Things to learn”, on the minus side, this project is *already* crossing Python off that list (Whilst trying to learn mod_python at the same time) and it’s a little too much to do at once. I could drop off Cantrip for a while and get up to speed on XSLT, but to be honest I don’t want to go off on a tangent because I want to actually _use_ the fricken system sometime this millennium. OTOH, I don’t _think_ the XSLT in Cantrip would be really very complicated, and I’d have to learn TAL anyway to use the other templatinglanguage.

Other main job today has been learning how to talk to apache from python. Getting the thing running was done a while ago, but joining the dots proved difficult. I’ve stopped using mod_rewrite, working like this:

RewriteEngine on

RewriteRule     ^python.*$        -       [L]
RewriteRule     ^static.*$        -       [L]
RewriteRule     ^assets.*$        -       [L]

RewriteCond %{REQUEST_URI} !="*"
RewriteRule (.*) python/$1

AddHandler python-program .py
PythonHandler mod_python.publisher
PythonDebug On
PythonPath "sys.path+['/home/webusers/aquarion/sites/character.istic/web/pylibs/']"

(Note, the handler file is in ./python/

and moved to this:

PythonDebug On
PythonPath "sys.path+['/home/webusers/aquarion/sites/character.istic/web/pylibs/']"

PythonHandler mod_python.publisher
SetHandler mod_python

(Note, the handler file is now ./

which is far less work, though I haven’t yet worked out how to stop it from handing /static (where css/image files are) too.

Finally, I discovered how to get the path information from inside the object, so I can find out what the user asked for, which is handy. Actually, mod_python.publisher‘s methodology is very similer to Epistula’s, though significantly better designed, in that it hands control over to the top level request, whcih then deals with everything underneath (For example, launches Epistula.php (for the top level) which hands control over to ““, which explodes the remaining path (“/2004/03/23”) and does whatever it needs to (in this case, grab all the entries across public, date based ‘chapters’ for that date). This is basically what I intend Cantrip to do. I’ll explode the path, and serve up information based on whatever they ask for.

First step, ability to add users to the database…

aqWiki Cantrip Imported From Epistula Personal Projects


It’s been a productive weekend.

LoneCat has done tidying, and I have assisted. I have made Pie (of all of Easter, Apple, and Chocolate derivations), read books, reformatted and reinstalled my Windows XP install, and even completed a project (The largely ignored Mockingbird’s Wish, below).

I’ve abstracted the data layer from the logic layer in AqWiki, and fixed all the bugs I could find that this caused, I’ve finished the SQL version of the Cantrip (Previously “PFD4-II”) data structure (more on that when I’ve actually used it). I’ve installed a Playstation Emulator, played Final Fantasy 8 for a while, and then dumped both on the grounds that playing a 60 hour game is bad enough, but having to play each second twice because the emulator crashes is beyond the pale. Especially if you have a working PlayStation downstairs.

I’ve archived four years of projects, sites and ideas into a new structure, cleared four entries off my “Long Term Tedium” todo list, fixed a number of logic bugs in my mail setup, written the outline for the second major section of the Novel Known As Final Frontier and named some of the the ships within it.

I’ve even worked out the motive for the protagonist of Toffia, and that’s been bugging me for years.

I’ve half written a LotR parody in which the ringwraiths visit a lost property office.

But mostly this weekend I have been obsessively compulsively worrying about how I did in the interview on Friday, and checking my mail every three to five seconds to see if an offer got lost in the post.

But that was just displacement activity, obviously.

aqcom Cantrip epistula Imported From Epistula Projects Work

Yeah, I know

Yes, I know about the blogroll. It’s a CSS argument I haven’t won yet.

“That which is also” archives are now integrated with the rest of the archives. That day’s blinks are under the posts for that day. It’s a fugly hack, but it’s fixed the fugly hack that was doing the date headers, so it’s only the same number of fugly hacks, rather than more or less. Plus it means I can do cool things later without more fugly hacks.

aqWiki has authentication support (including the ability to add users without mucking around in the SQL) and cookie authentication that actually works. Only collision detection and docs to go before version one…

The Cantrip (The project formally known as PFd4-II) Diary will continue when I’ve finished transcribing the document into SQL. Currently, all my “learning” resource is being spent on devouring the cubic foot of hard-back books (that I’ve never read) on Windows 2k server administration in preparation for the interview on Thursday. (Actually, this is an excuse, since turning the design doc into SQL isn’t learning, it’s just dull, which is why I’m working on aqWiki instead. Besides which since aqWiki is my default brain-dump location I get an instant productivity bonus when it’s actually working properly.

So the “eat your own dog food” theory goes, anyway).

Cantrip Imported From Epistula

PFd4-II – Database Design

(! - Generated; * - Mandatory; ? - Optional; & foreign key)


! ID - An identification number. (int)
* Title - Title of the game (Text-128 Unicode) (Unique to Campaign)
* ShortTitle - Short Title of the game for URLs. Autodefaulted from title  (Text-64 Ascii)
& Campaign - A link to the parent campaign. (int)
		0 - no campaign
* Description - Text description of the game. (medium unicode text)
& Owner - id of user who created - or otherwise owns - this game.
? World - Name of the world the universe/world is being played in (text-128, Unicode)
! Date_created (datetime)
! date_modified (datetime)
* status
	10 construction - game hasn't started yet
	20 active - Game is in play
	30 paused - Game is temporarily stopped
	40 ended - Game is over.
* view-permissions
	10 - Only the owner can see the game
	20 - Only the GMs can see the game
	30 - Only the players can see the game
	40 - Only logged in users can see the game
	50 - anyone can see the game.

That’s an extract from today’s document. Going though this for every table gives me a good idea of where I’ve mucked up the data relationships, or put in circuler dependancies and maps fairly easily into SQL. Also it provides a reference which I can paste into a comment in the handling code (either this or the SQL itself) to give me a heads-up on the desired formats. Next Up: SQL

Cantrip Imported From Epistula RPG

PFd4-II – The Perils of Supporting Rulesets

On not using licensed stuff

I’ve been asked if PFd4-II is going use any rulesets. The answer is no. Up until today, that was because I don’t really want to make it specific to any ruleset, because it means storing specific information about specific characters – INT, STR, DEX etc – and their equipment and what’s being worn and everything, and all of this has to be rewritten completely for every different ruleset.

Sod that for a game of tactical warfare.

My other stated reason for this was that I doubted that the various producers of rulesets would be terribly happy about an application that allowed you to play without the core rules books. I was then reminded that the D20 system is released under the OGL which might allow me to do this.

I checked the FAQs – it’s too early in the decade to wade though legal documents – and discovered:

Q: So what kinds of programs can I make with the OGL?
A: Anything. Character generators are popular, as are programs that help GMs keep track of their adventure. Random treasure generators are also fun.

Q: So I could make a game?
A: Sure. Remember though, you cannot use any Product Identity with the OGL or claim compatibility with anything. So you can’t say your game is a d20 System game or uses D&D rules or call it ‘Elminster’s Undermountain Crawl’.

Yay cool, I can use the rules to make a game. Except, hang on a second:

Q: Why can’t I use those things in my program?
A: No d20 System Product can include rules for character creation or applying experience. In exchange for using the d20 logo you are prohibited from making a product that replaces the core rulebooks. Covered Products supplement the core rulebooks; they may not replace them. That is why all Covered Products must state that they require the use of the core rules.

So, I can make a game with the D20 ruleset, but I can’t actually use the phrase “D20” to describe it. Therefore I’m not allowed to say “PFd4-II supports D20!” even if it does.

In fact, on top of this:

Q: What is different if I use the d20 System License?
A: […] This includes the obvious examples of attacking in combat, saving throws, and skill checks, but also includes dice rolling for character ability scores and hit points and rolling for damage. Why? Because in the d20 System a higher number is almost always better. Rolling an 18 for strength is obviously a preferable outcome to rolling a 3. In any circumstance where one outcome is quantifiably better than another is considered by Wizards to be an indication of success or failure; the software cannot perform these kinds of operations without breaching the license.

This means if I want to use the D20 name, I can’t actually say “You: 19, Enemy: 5, You hit” unless I pay the license fee because that’s how D20 works, but if I didn’t say it was D20, I could show the working.

So that’s the other reason I’m staying clear of labeled rulesets, they make my brane hurtz.

Cantrip Imported From Epistula Python web development webRPG

PFd4-II Design Diary – Part One: Start of a Brand New World

In the first part of a brand new series, I’m going to document the entire process of getting a web-app working.

I’ve been promising a new version of PFd4 for a while now. I have also been meaning to learn Python properly, so I’ve decided to combine these two projects into one handy package.

PFd4 was originally concieved when 2d10 – which my girlfriend and a number of my other friends were playing an RPG on – went AWOL for two weeks. At the time I was staying with one of the players and her (now) husband, who hosts both this site and my main site Aquarionics. So, Girlfriend, Provider of Free Hosting (both real and virtual), and small number of other friends need a web site. At the time I was unemployed, homeless and about to slide into the dark pit of depression, so I took on the project.

I coded the original version of PFd4 in three days flat, including one day designing the data structures, and as such it isn’t the greatest piece of coding I’ve ever done. The interface for the messaging was messy, and it only barely did what they wanted it to do well. Nevertheless it existed until the game ended a couple of months later, and during that time I consistantly promised myself that I would rewrite it. Now I’m unemployed again, although not homeless this time, and I want to learn a new language and skillset, so I’m using this.

The original structure for v1 is here.

These are the design principles for PFd4-II:


A new name.

I’ve never really liked the name PFd4, partly because my brain wants to parse it as PDF4. It stands for “Point First d4” (A d4 being a four sided dice) which is a play on 2D10 – the system it replaced – and the fact that it’s quick, painful, and RPGish. (d4s are pyramid shaped, if you stand on them it hurts).


It’ll be written in python, built on mod_python, backending onto a mysql database – as the last one did. This is the tricky bit. I am a PHP programmer by trade – though I did both C++ and Java at University – and am just getting into this python lark. Most of the reason I’m doing this now is to learn python.


The python will generate XML, which will be fed though an XSLT stylesheet and passed to the user (Actually, I may not even do this to start with and leave the XSLT client-side, it’s slightly quicker)

In fact, even quicker would be to generate XHTML by default – rather than an arbitary XML form – and transform from that.


The XSLT stylesheet will generate XHTML/CSS3 code that degrades gracefully to older browsers (If it isn’t already, see above). It may also produce PDF versions of logs etc.

External Access

Allow XML-RPC interface, NNTP, SMTP access etc. Possibly



Games will belong to campaigns. Any number of active games can be in a campaigns. This may involve subcampaigns, though that might be a little too far.

Characters will belong to Games too, rather than campaign, meaning a character can’t be in two games at once. I’m open to negotiation on this bit, because whilst I can see that having three characters for “Bob the Avenger” is duplication of effort, having Bob level up in one game and suddenly be levelled up in the other two is silly. This is also an interface problem, since I don’t want duplicate names, but if they’re in the same campaign – though different games – and they are the same person (Say, Bob The Avenger aged 16 and Bob the Avenger aged 25) that should be allowed (Yes, I do like the idea of Bob the Avenger, why do you ask?)


When a character makes a “play” they can do it as a ‘voice’. So a thief pretending to be the lady of the person whose house she’s robbing would be “Bobette the Thief as Lady Fitzdamnation”, with Fitzdamnation as the ‘voice’. This concept was popular with those who understood it, but complicated to explain. It remains (I like the idea, and it’s my system, damnit) but may end up being on some kind of “advanced” system. Plus, I want to be able to use it so that GMs can use it without the players being aware of it, so instead of “GM as Lord Fitzdamnation” you just see “Lord Fitzdamnation”. In fact, it’s possible that all GM plays would be made this way, and make the GM register a character for any persistant avatars same as anyone else.

Other Players

At an option for the GM, no player should be able to see what other PCs are playing, or even whether a given play is made by a PC, NPC or GM. NPC is the tricky one of those, because PCs and GM characters can – and will – have profiles, whereas small NPCs probably won’t.

Artifacts & Encyclopaedia

Every campaign will get an Enyclopaedia where they can put articles (Text (& Images?)) relating to the campaign. GMs will also be able to upload “Artifacts”, a file – any type – which groups can view. (Needs to be worked on to avoid becoming arbitary gallery space)


Characters can be lassoed into groups, which can then be given permissions. For example, if the GM wanted the group to find an article in Elvish, s/he’d upload the file as an Artifact with the group of “Characters who understand Elvish” being the only group allowed access. Inside this group s/he’d put all the characters who – duh – understood Elvish, and only they would be able to read it.

‘Play’s can also be restricted to a group, or some groups, or a list of people (For example, all those didn’t fail an observation roll might see that the carpet by the bookshelf is trapped, nobody else would see that message), though the list of people might be better off as a message. A message then just becomes a play that only the other person can see, which neatly stops me having to write another bloody e-mail replacement.


  • Implement the database
  • Login system
  • first-cut templating
  • User add/admin
  • Campaigns
  • Message Events
  • Games
  • Characters
  • Plays
  • [1]
  • Groups
  • Plays Mk2 (With groups)
  • Character Profiles
  • Encylopaedia
  • Artifacts
  • Design Cut 2
  • Bugfixen
  • Release.

[1] is the point where the system is usable for testing.