Problems with comments.py
Nathaniel Gray <[email protected]>
| Newsgroups | gmane.comp.web.pyblosxom.user |
|---|---|
| Message-ID | <[email protected]> |
Hi,
I'm upgrading from pb 1.0 to 1.2.1 and I've noticed some problems
with comments.py. Some are old, some are new, but I wanted to bring
them up. I've got patches for some, as well.
1. There doesn't seem to be any consistent philosophy about what
errors should be reported to the user and what should go to logs. If
a comment couldn't be saved because the comments file couldn't be
opened, there's no message to the user, just a log message, despite
the fact that the user's comment will be lost. OTOH, when I submit a
comment and e-mail isn't set up correctly I see this message:
Error sending mail: SMTP instance has no attribute 'sock'Comment
submitted. Thanks!
Some random user commenting on my blog shouldn't be told about
problems with my e-mail configuration.
Basically, if a comment is rejected or fails to be saved, the user
should be told so. If it's due to an internal error, the user should
be told so, but not get detailed info -- maybe a numerical or
symbolic code to indicate which line the error came from.
2. The new way of having story.html displayed for comments makes it
impossible to put status/error messages at the top of the page where
they're easiest to see. So the user has to scroll down beyond the
story to even know that there was a problem with a comment. It was
also annoying that this behavior changed without notice between 1.0
and 1.2.1.
3. It's hard to style status/error messages. If a message is
output, $comment_message should expand to a <div
style="commenterrormsg">...</div> block. If no message is output it
should expand to an empty string. That makes it easy to incorporate
the error message output in your flavour files without having them
take up space, and it makes them easier to style as well.
4. Actually, the whole "status message" approach to error handling
is bogus. It's annoying to have to try to weave error handling into
flavour files that are also supposed to handle non-error cases. It
would make more sense to have a comment-error.html file where you can
handle errors properly.
5. If a comment is entered without an e-mail address then crashes
happen. Even worse, they corrupted my comments database. The plugin
needs to transform and validate its input *before* attempting to
write it to the database. Code like:
cfile.write(makeXMLField('title',comment))
cfile.write(makeXMLField('author',comment))
cfile.write(makeXMLField('link',comment))
is dangerous because if the second makeXMLField call fails then the
file has been partially written! All transformations should be done
before the file is written to. Incidentally, the fix for this crash
is simple. In the cb_prepare function you need to add these lines
after the "if form.has_key('email')" statement:
else:
cdict['email'] = ''
6. I've added a "magic word" feature to comments.py that requires
the user to type some magic word to validate that they're not a
spammer. It's really simple, not dynamic, not industrial-strength,
but if everybody out there chose a different word and a different way
of *asking for* the word it would make comment spamming much harder.
Is this something you'd be interested in integrating?
Ok, I guess that's it for now. I'm sorry if I came off as sounding
negative. I actually like pb a lot and I'm grateful for the time you
guys spend on it. If you agree with the things I've said above but
don't have the time to fix them then I can put together patches.
Cheers,
-n8
PS. Please CC me with replies.
--
>>>-- Nathaniel Gray -- Caltech Computer Science ------>
>>>-- Mojave Project -- http://mojave.cs.caltech.edu -->
-------------------------------------------------------
This SF.Net email is sponsored by: NEC IT Guy Games. How far can you shotput
a projector? How fast can you ride your desk chair down the office luge track?
If you want to score the big prize, get to know the little guy.
Play to win an NEC 61" plasma display: http://www.necitguy.com/?r=20