GatewayNode

Missing Documentation

Ahem. This should probably be titled with a numeric identifier since I run into the rough edges of the open source world all the time. Sigh.

Cement Framework Hooks

If you are trying to use the Cement framework hooks and you can't seem to get the pre_setup or post_setup hooks to work, it is likely due to there being almost no documentation indicating that these hooks must be registered in the class.meta like so:

class Meta:
        label = 'myapp'

        hooks = [
                    ('pre_setup', home_config_init, 5),
                    ('pre_setup', pre_check, 0)
                ]

Also note that there are three parameters I am using instead of the documented 2 in each hook entry. The first parameter is the hook you want to execute in, in this case the pre_setup framework hook (it's the earliest you can do anything in the framework). The second is the name of the function you want to execute. That third parameter is the weight for determining hook execution order inside pre_setup.

The functions you want to run in the hooks seem like they need to be defined above the main class in the base scope. So

def home_config_init():
    # Do something when hooked here
    pass

class MyApp(App):
    class Meta:
        label = 'myapp'

Overall the documentation for the Cement framework is great, and there were definitely a few little hints at what was wrong about the documented hook registration, but like any open source documentation there are gaps. Hopefully this helps someone, I'll try to upstream this advice with a pull request on the API or website documentation.

Python SQLite3 Write Operations

This one is kind of crazy considering how widely used SQLite is, but for write operations using Python sqlite3 the required commit() method call needed to write seems to have disappeared from many of the 3rd party documentation sites. The official documentation is correct, but some of the 3rd party sites showing how to use the sqlite3 library are just plain broken. And of course the 3rd party sites have much better SEO than the official site so they are far more likely to show up in searches. Here is a working example taken from the official documentation as I'm not going to do anything to propagate the incorrect advice:

import sqlite3
conn = sqlite3.connect('example.db')
c = conn.cursor()
c.execute('''CREATE TABLE stocks
       (date text, trans text, symbol text, qty real, price real)''')
c.execute("INSERT INTO stocks VALUES ('2006-01-05','BUY','RHAT',100,35.14)")
conn.commit()
conn.close()

That next to last call to conn.commit() is absolutely required, omitting it won't throw any errors but it also won't write your SQL back to the db file. That's just like a perfect beginners trap, it doesn't do anything and doesn't indicate that something is wrong. To make matters worse the library will stub out the database file if it doesn't exist without commit so it looks like it is doing something.

Also I noticed that there is 3rd party documentation about using the command line SQLite client that constantly references calling sqlite db_filename in the terminal when it should be sqlite3 db_filename. That would lead to a lot of errors like this -bash: sqlite: command not found even though you have the client installed.

Ouroboros, you know the snake that eats itself...