Tao of the Machine

Programming, Python, my projects, card games, books, music, Zoids, bettas, manga, cool stuff, and whatever comes to mind.

Dude, where's my archives?

Right here:
This code is really simple:
for name, entrylist in shared.archives:
    print name
How could it be otherwise? :-) Now I can add a list of archive pages to my template... Also new in 0.5:
  • Creation of archives and front pages rolled into one, allowing for the code above. (Front page knows about archives.)
  • It is now possible to delete entries.
  • Archive method can now be set in the "blog properties" dialog; if it's empty, no archives are created.
  • Added file config_actions.py, where customs buttons and key bindings can be defined.
(Note: config_actions.py will be present in future Kaa installations too, so once you have a file with your favorite buttons and key bindings, make sure to make a backup when installing a new Kaa version. The version in the Kaa zip file will overwrite yours. Put your backup back afterwards.)

0.5 (or something better) will be available for download as soon as I've figured out a suitable license.

Posted by Hans Nowak on 2002-08-08 23:46:04   {link}
Categories: (unclassified)

Two problems

1. Kaa is now capable of generating archives. It also generates a "front page" with the N most recent entries. So far, so good. Now, it would be nice if there was a link to the archives from that first page. However, these two sections (front vs archive) are currently generated separately, and have no notion of each other. How can I make such a link?

One possible solution could be, generating archives and first page as one process. "Post" then simply means, create archives and the first page. This kind of makes sense; it would be illogical to produce the pages for one but not for the other. If the archives are created before the front page, then the blog object has a list of archive file names, which can be used for linking etc.

2. I am trying to make the second button bar (which now only contains a "bold" button) customizable. My first thought was doing this like Fafnir, having Python files that can be edited. My second thought was that that may be too user-unfriendly (where user != Pythonista), so I tried a very simple text file, like this:

bold: self.wrap_bold
italic: self.wrap_italic
tt: self.wrap_teletype
The part before the : is the text on the button, the part after it is the function that will be invoked when the button is pressed. The self here refers to an instance of the Kaa class.
The above works for the first two buttons, but fails for the third, for the simple reason that the wrap_teletype method doesn't exist. Now, it's kind of pointless to make customizable buttons if users cannot at least have them enter their favorite HTML tags. (If I use <foo> a lot, then I want a button that inserts that.) However, the current file structure doesn't allow for that.

Making the file format more complex kind of defeats the purpose, so I'm back at the first idea again. A Python file should do this; people that know Python can edit the file like any other module, adding their own functions, variables, etc. Now, if I want that <foo> tag, I can do something like

def wrap_teletype():
    kaa.replace_selected(htmltools.wrap, "", ""


buttons = [
    ("bold", kaa.wrap_bold),
    ("tt", wrap_teletype),
...or something like that. Sophisticated users should be able to add other kinds of buttons as well, not just HTML tag wrappers.

OK, back to my hacking I go...

Posted by Hans Nowak on 2002-08-08 22:09:48   {link}
Categories: (unclassified)

An experiment

The following doesn't work yet in the current version (0.4.5), but should soon.

Python 2.3.4 (#53, May 25 2004, 21:17:02) [MSC v.1200 32 bit (Intel)]
on win32
The embedded code snippet is:
import sys
print "Python", sys.version, "on", sys.platform
Let's see what happens...

[9:27 PM] Correction: it already works. It does even more than I thought... :-)

Posted by Hans Nowak on 2002-08-08 19:47:39   {link}
Categories: (unclassified)

An important yet invisible change...

The dialogs for editing blog and FTP info are now linked to configuration files, rather than to database tables. Only the blog entries are stored in a database table now, and that will remain so.

Posted by Hans Nowak on 2002-08-08 19:32:05   {link}
Categories: (unclassified)

Not really a new version, but...

...a step in the right direction. I added a Configuration object, and two subclasses, BlogInfo and FTPInfo. These will replace the configuration tables in the database and are much more flexible. (Although not suitable for everything; multiline strings are not possible right now, for example.)

Configuration objects can be loaded from and saved to file. Files have lines with the simple form name = value, as said before. When loading, the names are bound to the object with the given value; for example, a file like this

  foo = 42
  bar = "Joho en een fles prik"
will, when it's loaded into an object, cause that object to have two new (?) attributes, foo and bar. Simple but effective.

The benefit is that I can now add new attributes (configuration options) to the objects, without breaking existing Kaa installations.

Next up: linking these objects to the GUI input screens... but that should not be difficult.

Posted by Hans Nowak on 2002-08-08 01:03:05   {link}
Categories: (unclassified)

Configuration files

I got a mail yesterday from somebody who tried Kaa... he wrote his own blogging tool as well, using Tcl/Tk. That program uses a configuration file for FTP server, some blog settings, etc. I think this is a much better solution that what I'm doing right now, viz. using database tables... those are great for storing the actual blog entries, but not for all the preferences, settings, etc.

Maybe I'll do that too. If Kaa every gets to the point that people start using it, I cannot add a field to the tables anymore or existing blogs will break. With a configuration file, that's different. Users can install the new Kaa files over the old ones, and if a value is missing in a config file, a default value is assumed; when editing and saving, the new value is written. No problem at all.

I plan to use a dictionary layout or maybe something with lines like name = value. Something simple.

On a not entirely unrelated note, maybe future versions of Kaa will allow users to configure their own buttons... so they can include what they think is useful. Same for keyboard shortcuts (macros), and maybe even menu options.

Posted by Hans Nowak on 2002-08-06 22:48:08   {link}
Categories: (unclassified)


Version 0.4.4 essentially supports archives. Essentially, because there's no way yet to store the way of archiving in the database.

For several reasons, I use simple indicators for archive methods (as opposed to using more user-friendly but also more restrictive radio buttons & friends). They are of the form "x:y", where x is a letter and y is a number. For example, "d:7" means that an archive page spans 7 days of entries. "d:1" archives every day. "e:10" makes pages with 10 entries each. "e:1" makes a page per entry. "m:1" archives monthly (the number is ignored for the 'm' indicator).

At this point, archives only work "internally"; there is no place to enter or choose the archive method. That will be something for the next version, 0.4.5 or so.

The blog object that can be accessed from the embedded code, now supports current_page, next_page and previous_page entries, so you can link to them. That is done, for example, like this:

if hasattr(blog, "current_page"):   # is this an archive?
    if blog.next_page:
        print '<a href="%s">Next</a> ' % (blog.next_page)
    if blog.previous_page:
        print '<a href="%s">Previous</a> ' % (blog.previous_page)
It also supports an arch_page_names attribute in case you want to display a list of all archive page names.

Posted by Hans Nowak on 2002-08-05 00:26:34   {link}
Categories: (unclassified)

Documentation and download

OK, version 0.4.3 will be released to the public. It can be downloaded here.

Please bear in mind that this is a pre-pre-alpha version, that it probably has quite a few bugs I haven't discovered yet, not to mention missing features that people may consider "basic". (Like archiving, for example.) So I repeat what I say in the introduction: please don't use this for any serious purposes yet. If you're interested, use it for testing; but it's really not suitable yet for anything else.

And yet I write this blog in it, but like the header says, it may change or disappear at will...

Posted by Hans Nowak on 2002-08-04 16:59:13   {link}
Categories: (unclassified)

FTP stuff

Just added a dialog for entering FTP server info, and methods for loading and saving these data. Again, this is all basic stuff; slowly but surely Kaa becomes useable.

Maybe I'll make an announcement on c.l.py.announce soon. Release early and often, they say... but maybe I need to write some documentation first. The program isn't difficult to use, but some pointers are always nice.

Posted by Hans Nowak on 2002-08-04 15:36:05   {link}
Categories: (unclassified)

Some progress

Just added several editing features. You can now select text and make it bold, or italic, or underlined, etc. Nothing fancy really, just minor conveniences.

You can also enter URLs. For example, here's one to all things Python. Kaa currently uses the tkSimpleDialog module for this, but I want to replace it later with some more flexible (and using custom fonts as a bonus).

My (very simple) HTML page template currently looks like this:

<h1><% blog.title %></h1>
<i><% blog.description %></i>
<% blog.messages() %>
Generated by Kaa 
import resource
#> on <#
import date
print date.Date().isodate()
Pasting HTML is simple too: just paste it verbatim, select it, and choose Edit|Quote HTML. Characters like > and < will be converted to their &quote; equivalents.

Posted by Hans Nowak on 2002-08-04 14:47:36   {link}
Categories: (unclassified)

Test test...

Lots of people put the results of silly tests in their blogs/forums/etc, so why not me? :-)

I am 36% Geek

You probably work in computers, or a history deptartment at a college. You never really fit in with the "normal" crowd. But you have friends, and this is a good thing.

Take the Geek Test at fuali.com

Of course, whether I really have any noteworthy social skills is arguable...

Posted by Hans Nowak on 2002-08-04 12:23:21   {link}
Categories: (unclassified)

Blogging tools

There sure are a lot of blogging tools available...

So why write another? Ah, just for the hell of it. As said before, Kaa isn't meant to be the be-all, end-all of blogging tools. I was fed up with Blogger and decided to write my own. Most likely one of those existing tools would have been satisfactory, but I chose to walk the difficult route and write my own. Even if nobody else uses it (and they cannot right now, it's not even available for download yet :-) it will be useful to me, both as a tool and as a programming project.

No additions to Kaa in the last few days, BTW... I've been busy doing other stuff. High on my to-do list are archiving (IOW, generating archive pages) and adding nifty little edit helpers. (You know, quote/unquote, insert a link, apply a tag, etc...)

Posted by Hans Nowak on 2002-08-04 11:49:43   {link}
Categories: (unclassified)

Generated by Firedrop2.