comparison MoinMoin/wikiutil.py @ 517:39da9e68875c

wikiutil.parseAttribute extension now must return a tuple (found_flag, errmsg), fixing table attr parsing imported from: moin--main--1.5--patch-521
author Thomas Waldmann <tw@waldmann-edv.de>
date Wed, 29 Mar 2006 07:12:28 +0000
parents 1b9f0d6b9f48
children d141b2a723cf
comparison
equal deleted inserted replaced
516:ec330d9ec20b 517:39da9e68875c
926 def parseAttributes(request, attrstring, endtoken=None, extension=None): 926 def parseAttributes(request, attrstring, endtoken=None, extension=None):
927 """ 927 """
928 Parse a list of attributes and return a dict plus a possible 928 Parse a list of attributes and return a dict plus a possible
929 error message. 929 error message.
930 If extension is passed, it has to be a callable that returns 930 If extension is passed, it has to be a callable that returns
931 None when it was not interested into the token, '' when all was OK 931 a tuple (found_flag, msg). found_flag is whether it did find and process
932 and it did eat the token, and any other string to return an error 932 something, msg is '' when all was OK or any other string to return an error
933 message. 933 message.
934 934
935 @param request: the request object 935 @param request: the request object
936 @param attrstring: string containing the attributes to be parsed 936 @param attrstring: string containing the attributes to be parsed
937 @param endtoken: token terminating parsing 937 @param endtoken: token terminating parsing
958 if not key: break 958 if not key: break
959 if endtoken and key == endtoken: break 959 if endtoken and key == endtoken: break
960 960
961 # call extension function with the current token, the parser, and the dict 961 # call extension function with the current token, the parser, and the dict
962 if extension: 962 if extension:
963 msg = extension(key, parser, attrs) 963 found_flag, msg = extension(key, parser, attrs)
964 if msg == '': continue 964 #request.log("%r = extension(%r, parser, %r)" % (msg, key, attrs))
965 if msg: break 965 if found_flag:
966 continue
967 elif msg:
968 break
969 #else (we found nothing, but also didn't have an error msg) we just continue below:
966 970
967 try: 971 try:
968 eq = parser.get_token() 972 eq = parser.get_token()
969 except ValueError, err: 973 except ValueError, err:
970 msg = str(err) 974 msg = str(err)