Blog of Rob Galanakis (@robgalanakis)

Global Glob

I am cleaning out my drafts and found this two year old post titled “Globals Glob” with no content. The story is worth telling so here we go.

There was a class the EVE client used to control how missiles behaved. We needed to start using it in our tools for authoring missiles with their effects and audio. The class and module was definitely only designed (I used the term loosely) to run with a full client, and not inside of our tools, which are vanilla Python with a handful of modules available.

My solution was the GlobalsGlob base class, which was just a bag of every singleton or piece of data used by the client that was unavailable to our tools. So instead of:

serviceManager.GetService('someservice').DoThing(self.id)

it’d be:

self.globalsGlob.DoThing(self.id)

The ClientGlobalsGlob called the service, but FakeGlobalsGlob did nothing. The GlobalsGlob allowed us to use the missile code without having to rewrite it. A rewrite was out of the question, as it had just been rewritten, except using the same code. (sigh)

Unsurprisingly, GlobalsGlob was super-fragile. So we added a test to make sure the interface between the client and fake globs were the same, using the inspect module. This helped, but of course things kept breaking.

This all continued until the inevitable and total breakdown of the code. Trying to use the missile code in tools was abandoned (I think it was, I have no idea what state it’s in). This was okay though, as we weren’t using the missile tools much after those few months. GlobalsGlob served its purpose, but I will never be able to decide if it was a success or failure.

2 thoughts on “Global Glob

  1. Jon Lauridsen says:

    globalsglob still lives, missile mocking survives.

    origGlob = missile._globalsGlob
    missile._globalsGlob = glob
    try:
    msl = missile.Missile()
    finally:
    missile._globalsGlob = origGlob

    noserunner.py test_missilemock.py::TestGlobInterface
    Testing started at 8:47 PM …
    ..
    ———————————————————————-
    Ran 1 test in 12.248s
    OK

    Its status as a success or failure remains complicated.

    1. I don’t know if that makes me happy or sad…

Leave a Reply