This is mostly for RC, but I figured I'd send it to the list.
I rewrote all of my tag test code, and below is the interface I'm using to abstract db acces a step away from algorithm for the TagsProcessing. I have a version that does the work via 3 files (instead of 3 tables) as a fake database because have no idea what I'm doing with databases. I'm going to take a stab at writing the database interface myself, just to learn something new, but I figured I'd pass this along so RC could get hacking on that stuff he he wanted to. I copied my TagsDB_file.py over to TagsDB_sql.py, and deleted the body of each function. RC, if you want to reference the original TagsDB_file.py you can grab it from my test wiki's action or macro directory. Let me know if I can help get that running, I'm be trying to do it on my own here to, so RC expect some off-channel dumb questions. - Far --------------------- TagsDB_sql.py (prototypes only)----------------------------------------- # -*- coding: iso-8859-1 -*- """ Sycamore - TagsDB_file (Helper Functions) This abstracts database access away from the user. In this case, the data is just saved as text in a few files. This is paralell to TagsDB_sql. Both of these are temporary, until a more global 'database' abstraction can be setup/used. @copyright: 2007 Far McKon <[EMAIL PROTECTED]> @license: GNU GPL, see COPYING for details. """ # Import necessary modules import time # for localtime() call import string,re ## # tag defines the tag. # the primary key is an integer sequence (id) auto-generated on insert. # foreign key is the userid of the creating user # class is for future use if tag classes are implemented and should # be a foreign key to class. ## # Checks if a table of name 'inTableName' eixsts in our database # @return 1 if a table of name 'inTableName' exists in the database 0 otherwise def tableExists(inTableName): ## # Creates an entry in the 'Tag' table for a new tag. Does not check if the tag already exists # it assumes that a pre-existing check was done before this is called # [EMAIL PROTECTED] inTag tag name as a string [EMAIL PROTECTED] inUser user info (not sure if this is an ID or text yet) [EMAIL PROTECTED] inUserIP user ip(not sure if this is an ID or text yet) [EMAIL PROTECTED] inTime time the tag was created (defaults to CURRENT_TIMESTAMP) [EMAIL PROTECTED] inTagClass Tag Class, use default of 1 if you know or care (defaults to 1) [EMAIL PROTECTED] returns (for now) 0 on falilure, positive integer otherwise def createTagEntry( inTagName, inUser, inUserIP, inTime = time.localtime(), inTagClass = 1): ## # Returns 1 if the passed tag exists in the table 'tags'. Does not check for the # tables existance, assumes that was checked for by caller # @param inTagName # @return 1 if the tag exists, in table 'tags', 0 otherwise def tagExists(inTagName): ## # Checks if a page exists in the database # @param inPageName the 'proper' capitalized name of the page to test for # @return 0 on no 1 for yes def pageExists(inPageName): ## # Hack for File-DB only! The 'real' database should have the page alaready # in the database. If not we are screwee # @return 1 if the page was inserted correctly (file hack only) 0 otherwise def insertPage(inPageName): ## # This checks the page-tag relation table, and returns all of that tags in the database linked # to the page 'inPageName # @param inPageName the page to search for tags lined to # @return returns an [] of all of the tags for the page inPageName. The [] is empty if # there are no tags for that page def getTagsByPage(inPageName): ## # # unused. always returns 0 for now def getTagsCount(inTagName): ## # # unused. always returns 0 for now def getPagesByTag(inTagName): return 0 ## # This adds a new entry to the page-tag link table. It's assumed that the caller # checked that the tag exists in the tag table, the page exists in the page table, # and the page-tag link table exists # [EMAIL PROTECTED] inPageName the target page to link a tag to [EMAIL PROTECTED] inTag A new tag to link to page inPageName. [EMAIL PROTECTED] 0 always (should return a status, but does not yet) def insertPageTagLink(inPageName,inTag): # # unused. always returns 0 for now def findPageTagLink(inTag,inPageName): return 0 ## # Removes a page-tag link from the page-to-tag table. This will chekc for page tag link table # existance, # @param inTag Target tag to remove link from # @param inPageName target page to remove tag from # @return 1 always (should be bool success status, is not yet) def removePageTagLink(inTag,inPageName): ## # This function takes a string of comma seperated 'tags, # and turns it into a list. If a tag has quotes around it, it can # have commas within that tag. Returns a list of the tags, (Quotes not included) def stringToList(inTagsString, inIncludeQuotes = 0): startedQuotes = 0 TagArray = [] # Split comma seperated inTagList into a list TempTagArray = string.split(inTagsString, ',') halfTag = None# used in loop for gluing "," stuff back together for tag in TempTagArray: #check that the change here 'carries' #TagArray.append(tag.replace('"','')) if( (tag.count('"') == 1) and (startedQuotes == 0) ): #start of quotes, must have exactly one quote halfTag = tag startedQuotes = 1 continue if( (tag.count('"') == 1) and (startedQuotes == 1) ): #end of quotes, or start, exactly 1 " symbol startedQuotes = 0; tmpTag = halfTag +','+ tag tmpTag = tmpTag.rstrip() tmpTag = tmpTag.lstrip() if(inIncludeQuotes == 0): tmpTag = tmpTag.replace('"','') TagArray.append(tmpTag) continue elif (startedQuotes == 1): #in the middle of quotes halfTag = halfTag +','+ tag continue #else not in quotes at all if(inIncludeQuotes == 0): tmpTag = tag.replace('"','') else: tmpTag = tag tmpTag = tmpTag.rstrip() tmpTag = tmpTag.lstrip() TagArray.append(tmpTag) return TagArray ## # build a list of tags. Each entry in the list is a single use of a tag, so if tag 'x' # is used 9 times in the wiki, there will be 9 instances of 'x' in the list. #ToDo: write a new function write a better replacement function that returns (pagename,count). # @returns an array of tag names, as specified in the description def getPageTagsLinkArray(): _______________________________________________ Sycamore-Dev mailing list [EMAIL PROTECTED] http://www.projectsycamore.org/ https://tools.cernio.com/mailman/listinfo/sycamore-dev