Re: Thoughts on comments package
Wari Wahab <[email protected]>
| Newsgroups | gmane.comp.web.pyblosxom.user |
|---|---|
| Message-ID | <1076643931.6584.5.camel@minisync> |
On Thu, Feb 12, 2004 at 02:28:48PM -0800, Ted Leung wrote:
> To do things like trackback, pingback, comments, blogger, metaweblog,
> and Atom, I agree that we should move to a model where there are entry
> points in the core (actually probably methods on Pyblosxom) the can be
> called to implement functionality like creating and deleting entries
> and so forth. To do this in a completely general way will probably
> mean pushing some functionality all the way into classes like
> FileEntry so that we could do DBEntry at some later date.
Right now, pyblosxom is a viewer, the comments system pushes it further
by being a writer. The XMLRPC portion, which is pretty much a seperate
entity for now, is also capable of deletion, modification and addition
of entries.
There's also a blosxom plugin, that produces a form that will aloow you
to modify entries as well.
But these are pretty much hacks that work with the plugin system, and
pyblosxom still is just a viewer.
If you need to do more than that it really means moving things around a
lot, heck, even a start-from-scratch. But you get some sort of code
reuse will the other plugins.
> As you do this, keep in mind that we'll need a way to produce error
> replies as well.
I thought errors are as easy as:
renderer.addHeader('Status', '404 Not Found')
renderer.setContent( {'title': 'The page you are looking for is not
available','body': 'Somehow I cannot find the page you want.'+
'Go Back to <a href="%s">%s</a>?' %
(config["base_url"],
config["blog_title"])})
# Log it as failure
tools.run_callback("logrequest", {'filename':config.get('logfile',''),
'return_code': '404',
'request': self._request})
renderer.render()
Can be made easier by putting these three lines in a method of a
BasicRenderer I guess.
> Another thing about the current architecture is that it makes it very
> difficult for me to provide comment preview, which is something that
> people really would like to have. To do preview, people submit the
> form, but we don't have a way of injecting that back into pyblosxom
> because it's a cgi script -- I didn't write the comment data to disk,
> because it was a preview, but then the pyblosxom script exits and the
> data was lost.
But Ted, you of all people should know how one can do this without even
using cookies. It's the same technique done in most Wiki implementation
and even Movable Type comment system uses this same way without cookies
or sessions whatsoever.
1. You have a comment form with a preview and post button
2. On post, you just post. End
3. On preview, you set up the comment rendered in it's glory HTML,
3.1 you also set up a bunch of hidden fields in a form containing the
data that was entered
3.2 and in that same page, you have that same bunch of widgets that
allows users to modify what they entered
3.4 put in a [preview/post] button, if you have hidden fields, you
need one button, because you can compare and set the preview or
post logic, no hidden fields means two buttons.
4. Rinse
5. Lather
6. Repeat step 2
Granted a lot of work had to be done on step 3 because you would have
three data formats to work with, which is
* The rendered HTML for comments
* The original data in the hidden fields
* The almost original (escape all & to $amps;) data in the TEXTAREA
form to be displayed to the user
I don't think this is impossible, a bit hard? Yes. Primitive? Also true,
this was done before netscape invented cookies. MovableType has been
working without cookies (during comment submission, not the MT ui), and
greymatter works in similar ways as well.
You can take a look at Will's registry plugin to see how he implements
previews, although he did not have a form in the preview page, one could
at least press the back button and modify from there. Once the user
clicks [OK], is the time when all that input is written to disk.
> I know how to fix this problem in the Java servlet environment -- I'd
> just stick the data in the session, but in the CGI environment, I
> haven't thought of a clean way to solve this problem.
What are sessions? Basically data that's serialized to memory or disk
that may or may not expire within the next few minutes. Extremely
complex sessions mechanism can work Amazon.com, helping you to buy a
tech book and recommending you to some other related ones, while simple
ones are used as short term memory, and your case, the preview data to
be commited.
Sessions require some ID, this being cookies, or a simple ?ID=foobar.
Ultimately, a background process will clean up unused or expired
sessions.
So let's talk about this and it's implications in Pyblosxom. We do not
have a cookie mechanism, but could probably be fixable using plugins.
With a cookie, one could implement sessions, and store data in a DB
file. That would allow one to have fast access to information. Even if
Pyblosxom is a CGI, you can get data about the user based on his session
info.
This of course requires some work doing up some form of session objects
that does all the hard work in the background. Expiration of sessions
can be done everytime pyblosxom fires up, or just by using a simple cron
job to do the dirty work.
Then, it'll be as easy as sticking the data into the session. It's not
that hard, lot's of programs out there has done it before, and not only
that, there are a few session objects available for python out there in
sourceforge, so you don't have to do the work of implementing your own.
Java makes it easy because the classes are there for you so that you can
concentrate on just the business logic. It still has to do the same old
hard work of keeping data in memory, or dumping it in Oracle database.
I do believe that you know all these things and I really shouldn't
explain to you about this, only that technologies exists to make you
forget about the details, no matter how simple it is.
-------------------------------------------------------
SF.Net is sponsored by: Speed Start Your Linux Apps Now.
Build and deploy apps & Web services for Linux with
a free DVD software kit from IBM. Click Now!
http://ads.osdn.com/?ad_id=1356&alloc_id=3438&op=click