| WebSeitz/wikilog |
| Ro Baccia |
|
| last edited by BillSeitz on May 13, 2008 4:59 am |
super-thin WSGI-based Python Web Framework by Joe Gregorio
see z2006-10-01- Gregorio Disposable Python Web Framework
http://bitworking.org/projects/robaccia/
Feb22'2007: I'm going to try to migrate the Piki Piki Wiki Engine to this. Goal: Clone Zwiki
no Data Base, not much structure to content (though the File System [IO] will go here, I guess), so ignoring the model.py for now plus dbconfig and manage.py...
urls.py
I have Select Or in place, but it's a bit behind, so update it
one of my goals is to easily support Multiple Thinking Spaces, so have to design URI structure/mapping...
hmm, actually I don't think that's an issue here - I'm not mapping to a different method per space, so within the actual app code I can access the domain/host/path params to decide which space I'm working in...
Apr3 (I've been busy)
decide to "start" by ripping out all the kid and Sql Alchemy bits from the example files. Then launch the listener, get no errors. Hit the server, and get 404 error back. Perfect!
Apr5
have established that WSGI environ variables hold lots of what I'll want in determining which Name Space I'm in: HTTP_HOST, PATH_INFO, SCRIPT_NAME...
info on wsgi.routing_args
Apr9
now delivering the unrendered content, from a single Name Space
Apr13
forking bits of Piki Piki code to conform to this model
it's rendering the Wiki Text nicely, but
it's "printing" the same Front Page from a different Name Space in the terminal window
the import was running the whole thing - once I put the main piki bits inside a name=main test that went away
it's not linking a Wiki Name to the existing appropriate page (probably looking in the wrong Name Space)
Apr19
put same htdocs logic in piki.py code as in model.py - now rendering proper page links!
though it's got the wrong script in the urls it generates.
tweaked link_tag() and that's fine
but link to non-existent page returns "server error" page with no error logged in terminal window - that's from model.page_get():
File "/Users/billseitz/Documents/flux/flux/model.py", line 9, in page_get
f = open(doc_path, 'r')
IOError: [Errno 2] No such file or directory: '/Users/billseitz/Documents/flux/flux/htdocs/SecondPage'
it probably makes sense to decide how to handle this within view.page_get()
Apr25
decided to handle the normal Edit-form-deliver before handling the page-not-found case, as the latter will probably just give an edit-form
Apr28
was being driven crazy by Select Or seeming not to work to get to my edit_form, then finally realized that somehow I'd duplicated the bulk of the code, so the edits in the first copy were being eliminated by re-creating the object in the 2nd copy. Duh.
May1
what kind of URI do I want for the edit form: /PageName/edit_form (which ZWiki uses) or /PageName/;edit_form (which the Ro Baccia examples uses) or /PageName;edit_form (which seems right to me, treating the edit form as a representation of the page document)?
May5
it definitely looks like Select Or jumps to the 1st URI expression match. Therefore the specific Edit URI needs to come before the get-page URI that is a subset. Joe's example urls.py page doesn't seem to be ordered that way.
May7
it looks like nothing installed so far provides a nice dictionary of form-field data. Should I load Luke Arno's [YARO]] Python Paste has a parse_formvars function in paste.request which just takes the WSGI environment and calls the cgi module (the [Field Storage] class) and turns that into a [Multi Dict]. I'm actually just ripping out parts of that function from [YARO]. But I'm getting a weird error:
File "/Users/billseitz/Documents/flux/flux/view.py", line 54, in form_parse
if isinstance(value, list):
TypeError: isinstance() arg 2 must be a class, type, or tuple of classes and types
* finally decided to rip out that chunk, and assume for now that won't be facing any multi-value fields. Used "this":http://docs.python.org/lib/node561.html code to only take the first value if it comes up.
May10
got the page_update working, with redirect back to page when done
but not logging change for Recent Changes (is that even really necessary, or can I just do a directory listing?)
May19'2007
create-page link is now just going to same format of URI as getting existing page
but then Http Post is going to wrong place.
is this the wrong approach? Should I be pointing initially to an edit-form? Yes, will change that rendering.
yes, that's better
May21
but what if request is for page that doesn't exist? Render edit form? No, just make page-not-found.
but if use regular template, then edit up with Edit button, which we don't want.
so made not_found function with just 1-line body
Jun14
have decided to make simplest possible Recent Changes to Clone Zwiki - so won't make a changelog, just generate directory listing in mod-time order.
but os.listdir only gives you names, with no mod-time.
there are a variety of examples involving stepping through every file in a directory to get its info.
but if I have a directory with thousands of files, and just want the last 20-50 of them, that smells awfully inefficient.
am I going to use commands.getoutput() to call an ls -ltT function and then parse the results?
July07
Yes, using os.commands() to call ls; then using os.stat() to get mod-time of most recent files (because the dates included in the ls can be rather inconsistent in rendering).
Probably time to find a CSS stylesheet somewhere.
but to deliver it, I have to support a static page delivery method
and images too, i guess - actually I'll plan on using Amazon S3 for that.
Jul10
assuming URI with . in it is static; that works.
put ref to CSS sheet in head of template
now watch it get hit for every single page - I would have thought the browser would cache that like an image. Apparently not. Definitely going to want ETag working, but not worrying about it for now. (Could even just use Amazon S3 to deliver that, I suppose.)
for that matter could plan on using Amazon S3 for all static pages. But probably not.
hmm, static page has not Edit button; if tweak the URI to have the edit bit at the end, it doesn't work. Do I want that to work? Or is this rare enough that I'd just use FTP or something to upload static stuff? Will assume that for now.
what about images? That would probably be a good reason to go with Amazon S3, at which point I might as well stick the CSS page in there, too.
actually, should probably just plan on using "real" Web Server like ApaChe as Proxy Server and to handle static content.
Jul22
have Recent Changes fork for RSS feed. It uses the right tags.
need to add guid, smells like just mirrors the link
Aug03
did escaping (of output) and guid
pubdate: need correct format
hey maybe I should just be using http://www.dalkescientific.com/Python/PyRSS2Gen.html for all this stuff? Though hardly seems worth it now.
just use time.strftime()
need to test against validator
Aug08
validating RSS...
doh! forgot to close item
had to change pubdate tag name to pubDate
had to make item.author an email address
passed!
what's next?
go back to work on CSS page?
authentication?
settle Smart Ascii flavor decision?
Aug09 - considering Smart Ascii choice
currently using Piki Piki, not fan of the lots-of-single-quotes model
Structured Text: already in my WikiLog
annoyed by italics getting broken by pasted-in non-low-ascii chars (like curly quotes) - but that may be code issue, not spec issue
don't like single-quote breaking italics, since pasted-in text often uses them
don't like single-square-brackets having meaning, since they are often used as normal punctuation
sublists need 2 spaces per level
ugh, the hyperlinks syntax is horrible, having to move them to a separate line
I'd still consider it if there was an existing converter for Structured Text, but I haven't seen one.
Wiki Creole: not supported much yet
TextIle: poor performance
Mark Down: blech I hate the syntax
Oct22:
not loving any of the choices, going to stick with Structured Text since that's the content I have and it's not horrible.
use Easy Install to install zope.structuredtext - it works interactively
hmm, but generates a whole page/document of HTML, including header/etc when I really just want a body to insert into a template. I wonder whether that's controllable?
ugh doesn't look like it. Do I (a) edit the underlying library to skip that stuff (or have an option to skip it), or (b) leave it untouched and strip the output in a separate function in my own library? Probably (b).
| User Options Recent Changes Help Page |