Categories: ,
Posted by: bjb

The first two steps in fixing the html on my page have been taken. I’ve decided that no, I’m not going to fix it the easy way (by getting rid of the category cloud). And I upgraded my byteflow to the latest development version.

I looked at mercurial, and decided I didn’t want to learn yet another revision control system, so created a local git repository for my copy of byteflow, and checked the latest byteflow into it. Then created a branch for my changes and put my customizations into it. I have a separate sandbox where I can check out the latest from hg, test it, and check in to the main git repo. That’ll be fun.

Next, will be to report the problem to the byteflow people, and possibly try to fix it myself (if they don’t do it first).


byteflow ticket 152

Categories: ,
Posted by: bjb

The Redhat-ish way to start and stop daemons is to use the service command. I just learned the Debian-ish way to do that is with the invoke-rc.d command. For example:

$ sudo invoke-rc.d apache2 reload

04/7: byteflow

Categories: , ,
Posted by: bjb

I tried validating (see below) the html on my new(ish) blog — it didn’t validate. It seems the category cloud is non-compliant. But I fixed up the CSS and that validates now.

I will check into the category cloud later.

<a href="/bjb/tag/android/"
title="Click to filter by android"
alt="count: 2"

<a href="/bjb/tag/apache/"
title="Click to filter by apache"
alt="count: 1"


The validator doesn’t like “alt” tags on the “a” elements, for starters. The question is, why is it there? Of course it could be commented out (it’s in templates/tagging/tag_cloud.html) but what would break? … Stay tuned.

 continue reading
Posted by: bjb

I just learned how to do a couple of things in emacs:

  1. put the line that has point in it at the top of the window: M-0 C-l (meta-zero control-ell)
  2. toggle the buffer to read-only or writeable ( M-x view-mode )
Posted by: bjb

I was trying to integrate django’s user model with my application. I had extended the user with extra data in a UserProfile class, and had made a view require login. The web page was successfully redirected to the login page when visited for the first time, but upon logging in the user was not redirected to the original page. The user was redirected to the /accounts/profile page.

It was because I had not noticed that you had to add something to the login template — you need to add a hidden field called “next” to your login form. Once I added that, and changed the form action to “./?next={{ next }}” it started working correctly.

 continue reading
Categories: , ,
Posted by: bjb

Running django under wsgi wasn’t hard … You make a script called xxx.wsgi, and it has a function called ‘application’ that is the entry point to your application. Django supplies an entry point called @django.core.handlers.wsgi.WSGIHandler()@, so you just have to:

application = django.core.handlers.wsgi.WSGIHandler()

(with a little setup beforehand)

You also should configure Apache to handle the appropriate URL location with mod wsgi:

    WSGIScriptAlias /cp /home/bjb/work/credil-bjb/clientportal/wsgi/clientportal.wsgi

There was a little more stuff so that apache would serve some files statically (what django calls the “media” files and “static” files), but that was standard apache config. The other thing is to enable the wsgi module, and (because I’m using django auth) ensure that all the right modules are loaded and all the wrongs ones are disabled.

I started with this documentation (found a pointer to a parent page in the django docs):

Categories: ,
Posted by: bjb

To get rid of all the data in your database (but keep the tables):

./ flush

That is pretty much equivalent to:

sudo -u postgres dropdb appdb
sudo -u postgres createdb -O me appdb
./ syncdb

I even got asked the questions about creating the superuser after running the ./ flush command.

Categories: ,
Posted by: bjb

Another error made at the same time as the previous one was to call the model constructors with positional args:

mm = MyModel ('name', 'description')

This resulted in creating a MyModel instance like this: = 'name' = 'description'
mm.description = None

I should have called them with keyword args so the passed values would be assigned to the right attributes:

mm = MyModel (name = 'name', description = 'description')
Categories: , ,
Posted by: bjb

I made a new django app. First I made a few models, then some unit tests for the models. I could not save newly created model instances in the database, the error was something about there not being an attribute id.

It turned out that although I inherited the models.Model class into each of my models, I was overriding the __init__ function. I should have called super from the derived class’s __init__ method … This is what the model class should have looked like:

from django.db import models

class MyModel (models.Model):

    name = CharField (max_length = 64)
    description = CharField (max_length = 512)

    def __unicode__ (self):

and if i was going to declare an __init__ method, it should have looked like this:

    def __init__(self, *args, **kwargs):
        super(MyClass, self).__init__(self, *args, **kwargs)
        # my own customization code goes here
Categories: , ,
Posted by: bjb

I was learning about repo, and noted that repo can use a “list of projects” to narrow down the scope of its actions. It will operate on the list of projects you give it, and not the others. But, as a newish member of the team, I didn’t know what the list of projects was. I knew there was a manifest file. It is in xml format.

I was never very successful with xml. However, I thought that time has passed, and maybe there is a newer easier to use tool out there. I looked again and found xmlstarlet. Maybe my previous attempts at xml have softened me up so I can understand xmlstarlet, or maybe it really is easier than previous xml tools.

I wanted an xmlgrep:

xmlstarlet sel -t -m "//project" -v "@path" -n default.xml
 continue reading