Top Linux Links You Must Click On
Readers react to phpBB & spyce series
Our hero reexamines features of phpBB and spyce, changes some of his assumptions and offers some spycey Python tips
Nov. 25, 2002 12:00 AM
(LinuxWorld) — I heard it through the grapevine that some phpBB fans were less than enthusiastic with the cursory overview I gave it a few weeks ago. I thought my appraisal was quite positive, but I do appreciate the criticism I found in various threads, including the LinuxWorld forums. It brought my attention to two errors in the article — an omission and a misunderstanding — and gave me a reason to incite more flames.
First, I incorrectly asserted that phpBB does not support avatars. I had actually seen phpBB-based bulletin boards with avatars before, but since I saw no way to set an avatar in the user profile, I incorrectly assumed that these bulletin boards made use of some add-on or modification. As it turns out, there is a setting in the administrator control panel that turns on the avatar features. The setting is two levels deep, so while it's not totally buried, it's not obvious to someone who needs neon lights and arrows pointing to a feature.
Some folks took exception to my complaint that there is no "reply" button for each message. To paraphrase one of their comments, the "quote" button is for quoting what an individual said, and the "reply" button is for replying to the entire thread. That remark caught me by surprise until I realized I had overlooked another aspect of phpBB: every discussion is chronological and single-threaded. There's no point in replying to someone's post because there's no way to view the thread with branches to see who replied to whom. The only way someone will know you're replying to a specific post is if you quote the post.
This limitation doesn't happen to bother me in the least, because I actually despise forum views where you can only see threaded lists of subject lines. I do happen to like seeing multiple threads in a discussion, but I prefer to see them as nested messages that are indented according to the response threading. However, I haven't come across any PHP- and MySQL-based forum software that supports this. I haven't looked very hard, either, so if you happen to know of any open-source package that does this, please share the wealth and clue me in.
I also noticed phpBB fans tend to gloat about the number of "mods" available for phpBB. I confess I had thought the term was short for "plug-in modules", and I was shocked to find the mods consisted of things like "how to change the default icon in the upper left corner of the page" (gosh, that must have taken weeks to code... and they let these extras go for free?).
In this case, the term "mods" is short for "modifications," so my disappointment was self-inflicted. Once I realized my error, I also realized why some folks like the available mods. One can find phpBB mods from different sources, and some can be pretty handy. Most of the mods I looked at are also fairly well-documented.
But the more I looked into mods, the less I felt they were something about which I would boast. Many of them seem more like "patches" than "mods", and they leave you wondering why these features aren't supported by default.
There doesn't seem to be a way to apply mods automatically, although this may be another one of those features that simply eluded me. It doesn't help that the phpBB Web site documentation is blank under the topics of mods (and other places). The discussion board on the phpBB site explains how to apply mods manually, though. Finally, it struck me as odd there are separate lists of mods for phpBB version 2.0.0 and for version 2.0.3.
Yes, I know the mods are source-code changes, and when the source code changes, the mods have to change. But I'm spoiled on the way FUDForum handles updates to its code. You can update any version of FUDForum from 1.9.8 all the way to 2.3.5 using a single update file. The update process is automatic, and it detects and adjusts to whichever version you happen to run. Naturally, version updates are not the same thing as mods, but I noticed I haven't felt the desire for mods with FUDForum because it already contains every feature I need.
Nevertheless, I still like phpBB very much. It is very speedy, and it does just about everything one asks of a forum. Yet it is simple enough I may actually choose to lift some of its code for use in a forum-blog project rather than lift FUDForum code for the same purpose. But that's the best I can say; if phpBB fans aren't satisfied because I'm not zealous about phpBB or because I strongly prefer FUDForum, there's not much I can say to appease them.
The folks who work on spyce gave me a more-positive holler about one of the issues I raised in my series. I pointed out that when you include a spyce file dynamically, the main file does not "see" the public variables and functions in the included file. This can confuse PHP programmers who make the switch to Python and spyce, since PHP does not behave the same way.
PHP has what is called a "flat name space." When you dynamically include a file, the included code is treated almost as if it was hard-coded into the original source. I say "almost" because I seem to recall exceptions. Unfortunately, I cannot recall at the moment what the precise exceptions are.
The spyce folks have since changed spyce to meet the problem halfway. One could always pass parameters to a dynamically included file in the past, but it was a one-way transaction. As of spyce version 1.2.8, you can now pass information both ways. This means you can send values to a dynamically included program, change the values of the passed parameters and return the changed values. For example:
You can pass arrays (tuples) back and forth as well, so there's not much to prevent you from doing with spyce what you used to do with PHP. It's not quite the same as PHP, since this doesn't give spyce a flat name space.
If, for some reason, you really want to emulate the flat name space behavior of PHP, it is possible to get there with a little Python magic (thanks to "Mr. spyce" himself, spyce inventor Rimon Barr, for a sample snippet of code on how to do this). Personally, I strongly prefer the practice of storing the data in a database table wherever possible and then issuing a SQL query instead of using a dynamic include (see my previous article for an example). But the sample code Rimon sent to me is an excellent example of Python flexibility, so I've concocted a slightly simpler sample from Rimon's e-mail for your benefit.
The following example sets the variables "first" and "second" to the value 100. Then it includes a file called "mess.spi" which also sets variables "first" and "second", this time to the values 1 and 2, respectively. It constructs a dictionary with the keys 'first' and 'second' with the values 50 for each. It prints out the values just to show they are set properly. Then it changes the values to 1 and 2 (because those are the values we set earlier for the variables with the same names as the dictionary keys) and returns the dictionary to the calling program.
[[.import name=include]] [[\ first=100 second=100 new_mess_o_data() = include.spyce('mess.spi', mess_o_data() ) for i in new_mess_o_data.keys(): exec '%s = new_mess_o_data[%s]' % (i, repr(i)) del new_mess_o_data print first print second ]]
The most-interesting line is the one in the calling program starting with "exec". This evaluates strings from the dictionary keys and executes them. It replaces the "%"s with the key name, so this line creates and execute the statements:
In terms of the actual data stored in the dictionary, it is essentially performing these statements:
Then the program frees up some memory by deleting the dictionary.
Obviously, the above is an awful lot of convoluted work just to pass a couple simple variable names and values, and I don't think I'll find myself using this technique very often. But it does demonstrate you can make Python — and therefore spyce — do just about anything short of washing your socks. And you never know what will come in handy when you're in the middle of a programming brainstorm.
Reader Feedback: Page 1 of 1
Subscribe to the World's Most Powerful Newsletters