Archive System
Setting up a custom archive system is slightly trickier than a prologue or epilogue module, but not by much. You must create a main
module that contains five functions: add_post, del_post, edit_post, search_posts, fetch_post. It is up to you, the archive system implementor to decide how to handle all of the back-end details.
add_post(post object) -> ID
This function takes in a post object and returns its ID that the archive system assigns it. This is called everytime a post object needs to be added to the archive. The ID is used for referencing in the posting page.
del_post(ID) -> 1 or 0
Removes a post from the archive. Returns 1 if successful, 0 otherwise.
edit_post(post object, ID) -> 1 or 0
Although not currently used, edit_post()
is included for possible future use. It will accept a post object and an ID and will return 1 if successful, 0 otherwise.
search_posts(search object, ID=None) -> list of IDs
Searches the archive for posts that match the search object and returns a list of IDs of posts that match the search criteria. A search object is just like the data_dict from a post object; it is the values entered in at search.py as a dictionary. The ID is optional and if specified will only search that specific ID to see if it is a match. The return is a list of IDs that match the search criteria.
fetch_post(ID) -> post object or 0
Fetches a post from the archive. Takes in an ID and returns the post object stored by the archive. If the fetch failed, returns 0.
pyBlog 1.0; 2001-09-10