Categories: ,
Posted by: bjb

Both before and after upgrading byteflow to use django 1.2, one thing that wasn’t working is postimage. The most recent problem was the link to post an image (in the admin page for creating or editing a blog post) was completely missing (whereas before it was present but malfunctioned).

The reason it was missing was that the javascript to create that link, in static/js/postimage.js, failed on line 42, in the showLinkFor function. It failed on

elem.previousSibling.appendChild(document.createElement('br'));.

I fixed it by inserting the link before the blog text instead of after the previous node’s contents:

    //  showLinkFor: function(elem) {
    //      elem.previousSibling.appendChild(document.createElement('br'));
    //      elem.previousSibling.appendChild(this.getLink(elem.id));
    //  },

    showLinkFor: function(elem) {
        var parent = elem.parentNode;
        var mybr = document.createElement('br');
        var myid = this.getLink(elem.id);
        parent.insertBefore (myid, elem);
        parent.insertBefore (mybr, elem);
    },

I have a non-standard URL_PREFIX of bjb/ and postimage didn’t play nice with that. I hard-coded my URL_PREFIX into the postimage.js file:

    getLink: function(id) {
        var link = document.createElement('a');
        link.setAttribute('href', '/bjb/admin/postimage/attach/?for=' + id);
        ...

Not elegant, but it got me past that problem. The next problem was that the list of files was empty. I set the POSTIMAGE_ROOT to point to a directory on the server machine with pictures in it, and then the list was not empty.

But it wasn’t full of all the pictures in that hierarchy either … that was just a file permission problem (web server couldn’t read some of them).

So now I can use postimage. It doesn’t do quite what I expected. What it does is allow you to choose among pictures on your server for inclusion into your blog. It doesn’t let you preview them. All it does is give you a list of files, and then put a link to the most recently chosen file in your blog text. You can call it over and over and it will add more image links. It looks like it can take the render method into account — there is a choice of markdown, html, rst. But, that choice was in the source code … not sure if it will detect your render method automatically.

I expected to be able to upload pictures to the blog … oh well. I guess the way postimage works is safer. It doesn’t put files up there for you — it assumes you have put them up already — into a “POSTIMAGE_ROOT” directory — and just accesses what is already there.

Posted by: bjb

I’m trying out byteflow under django 1.2, and I finally have it working. There were only a few changes to make.

First off, the databases are specified differently in django 1.2 — there is the option to connect to multiple databases now. Strangely however, django did not force me to change my database settings … I guess there is some backward compabitility stuff for now.

old settings_local.py

    DATABASE_ENGINE = 'postgresql_psycopg2'
    DATABASE_NAME = 'byteflow'
    DATABASE_USER = 'db_user'
    DATABASE_PASSWORD = 'sekrit'

new settings_local.py

    DATABASES = { 'default' :
        {
            'ENGINE' : 'postgresql_psycopg2',
            'NAME'   : 'byteflow',
            'USER'   : 'db_user',
            'PASSWORD' : 'sekrit',
        }
    }

There are also some deprecation warnings in the logs about admin.site.root, in urls.py (I may have added all those ‘settings.BLOG_URLCONF_ROOT’ in when using ‘bjb’ as my URL_PREFIX):

old:
    url(r'^%sadmin/(.*)' % settings.BLOG_URLCONF_ROOT,
        admin.site.root, name='admin'),

new:
    url(r'^%sadmin/(.*)' % settings.BLOG_URLCONF_ROOT,
        include(admin.site.urls)),

But this didn’t work for me so I went back to the old way. The problem was that when I asked to edit a blog post, it brought me to the main admin page. When I clicked on the Change link, it stayed on the main admin page. I’ll have to look into that another time.

An update was required to apps/tagging/managers, in usage_for_queryset, to update the database query for the django 1.2 database scheme (multiple databases). I found this hint.

Also, in order to run django 1.2 on my stable machine, I set up a virtualenv (with --no-site-packages) in which to run it. Had to install all the site-packages into the virtualenv:

  • BeautifulSoup-3.1.0.1
  • Django-1.2.1
  • PIL
  • mx
  • openid
  • psycopg2-2.0.7

That’s about it except for infrastructure:

  • easy-install
  • pip-0.8
  • setuptools-0.6c8

Well I suppose I should have started by upgrading byteflow, I’ll have to try that another time. Maybe some of my changes have been fixed in upstream already. However I did quickly note that the byteflow install page still says it requires django 1.0.

Posted by: bjb

Using my blog for it’s intended purpose: notes to self.

django on my server is an older version, my apps developed on my desktop need a newer version of django. I need to deploy virtualenv on my server so I can run a newer version of django for some apps. Like ipaddr and byteflow.

byteflow in particular, needs jquery.js (for attaching an image to a post, via postimage app and TAGGING_AUTOCOMPLETE_JS_BASE_URL setting) and that is not included in django 1.0.2.

But I’m out of time for today, so this is a task for another day.

Categories: , ,
Posted by: bjb

Not surprisingly, the blog spam commenters found my blog. Now I am investigating ways to ensure that only people comment on my blog.

With a little searching, I found that recaptcha is the recommended method these days. However, since Google has bought the recaptcha organization, you have to agree to a large legal agreement between yourself and Google to use it.

I’m not really up for that. It’s too bad as I might have liked to contribute to the “digitize old books” effort. So now I’m looking into regular captchas.

Categories:
Posted by: bjb

The byteflow community has a user mailing list and a hacker mailing list:

  1. users mailing list
  2. hackers mailing list

There is more info on the byteflow wiki and in the docs directory of the sources.

Also they talk on jabber: byteflow@conference.jabber.ru (logs)

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).

UPDATE:

byteflow ticket 152

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"
class="tag-2"
rel="tag">android</a>

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

...

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