rem
stringlengths
0
322k
add
stringlengths
0
2.05M
context
stringlengths
8
228k
static void *gen_void_ptr(int no ATTRIBUTE_UNUSED) { return(NULL); } static void des_void_ptr(int no ATTRIBUTE_UNUSED, void *val ATTRIBUTE_UNUSED) {
static void *gen_void_ptr(int no ATTRIBUTE_UNUSED, int nr ATTRIBUTE_UNUSED) { return(NULL); } static void des_void_ptr(int no ATTRIBUTE_UNUSED, void *val ATTRIBUTE_UNUSED, int nr ATTRIBUTE_UNUSED) {
def is_known_param_type(name): for type in known_param_types: if type == name: return 1 return 0
static void *gen_userdata(int no) {
static void *gen_userdata(int no, int nr ATTRIBUTE_UNUSED) {
def is_known_param_type(name): for type in known_param_types: if type == name: return 1 return 0
static void des_userdata(int no ATTRIBUTE_UNUSED, void *val ATTRIBUTE_UNUSED) {
static void des_userdata(int no ATTRIBUTE_UNUSED, void *val ATTRIBUTE_UNUSED, int nr ATTRIBUTE_UNUSED) {
def is_known_param_type(name): for type in known_param_types: if type == name: return 1 return 0
static int gen_int(int no) {
static int gen_int(int no, int nr ATTRIBUTE_UNUSED) { if (no == 0) return(0); if (no == 1) return(1); if (no == 1) return(-1); if (no == 2) return(122); return(-1); } static void des_int(int no ATTRIBUTE_UNUSED, int val ATTRIBUTE_UNUSED, int nr ATTRIBUTE_UNUSED) { } static unsigned int gen_unsigned_int(int no, int ...
def is_known_param_type(name): for type in known_param_types: if type == name: return 1 return 0
static void des_int(int no ATTRIBUTE_UNUSED, int val ATTRIBUTE_UNUSED) {
static void des_unsigned_int(int no ATTRIBUTE_UNUSED, unsigned int val ATTRIBUTE_UNUSED, int nr ATTRIBUTE_UNUSED) {
def is_known_param_type(name): for type in known_param_types: if type == name: return 1 return 0
static const char *gen_const_char_ptr(int no) {
static const char *gen_const_char_ptr(int no, int nr ATTRIBUTE_UNUSED) {
def is_known_param_type(name): for type in known_param_types: if type == name: return 1 return 0
static void des_const_char_ptr(int no ATTRIBUTE_UNUSED, const char *val ATTRIBUTE_UNUSED) {
static void des_const_char_ptr(int no ATTRIBUTE_UNUSED, const char *val ATTRIBUTE_UNUSED, int nr ATTRIBUTE_UNUSED) {
def is_known_param_type(name): for type in known_param_types: if type == name: return 1 return 0
static xmlChar *gen_xmlChar_ptr(int no) {
static xmlChar *gen_xmlChar_ptr(int no, int nr ATTRIBUTE_UNUSED) {
def is_known_param_type(name): for type in known_param_types: if type == name: return 1 return 0
static void des_xmlChar_ptr(int no ATTRIBUTE_UNUSED, xmlChar *val ATTRIBUTE_UNUSED) {
static void des_xmlChar_ptr(int no ATTRIBUTE_UNUSED, xmlChar *val ATTRIBUTE_UNUSED, int nr ATTRIBUTE_UNUSED) {
def is_known_param_type(name): for type in known_param_types: if type == name: return 1 return 0
static const xmlChar *gen_const_xmlChar_ptr(int no) {
static const xmlChar *gen_const_xmlChar_ptr(int no, int nr ATTRIBUTE_UNUSED) {
def is_known_param_type(name): for type in known_param_types: if type == name: return 1 return 0
static void des_const_xmlChar_ptr(int no ATTRIBUTE_UNUSED, const xmlChar *val ATTRIBUTE_UNUSED) {
static void des_const_xmlChar_ptr(int no ATTRIBUTE_UNUSED, const xmlChar *val ATTRIBUTE_UNUSED, int nr ATTRIBUTE_UNUSED) {
def is_known_param_type(name): for type in known_param_types: if type == name: return 1 return 0
static const char *gen_filepath(int no) {
static const char *gen_filepath(int no, int nr ATTRIBUTE_UNUSED) {
def is_known_param_type(name): for type in known_param_types: if type == name: return 1 return 0
static void des_filepath(int no ATTRIBUTE_UNUSED, const char *val ATTRIBUTE_UNUSED) {
static void des_filepath(int no ATTRIBUTE_UNUSED, const char *val ATTRIBUTE_UNUSED, int nr ATTRIBUTE_UNUSED) {
def is_known_param_type(name): for type in known_param_types: if type == name: return 1 return 0
static const char *gen_fileoutput(int no) {
static const char *gen_fileoutput(int no, int nr ATTRIBUTE_UNUSED) {
def is_known_param_type(name): for type in known_param_types: if type == name: return 1 return 0
static void des_fileoutput(int no ATTRIBUTE_UNUSED, const char *val ATTRIBUTE_UNUSED) {
static void des_fileoutput(int no ATTRIBUTE_UNUSED, const char *val ATTRIBUTE_UNUSED, int nr ATTRIBUTE_UNUSED) {
def is_known_param_type(name): for type in known_param_types: if type == name: return 1 return 0
static xmlParserCtxtPtr gen_xmlParserCtxtPtr(int no) {
static xmlParserCtxtPtr gen_xmlParserCtxtPtr(int no, int nr ATTRIBUTE_UNUSED) {
def is_known_param_type(name): for type in known_param_types: if type == name: return 1 return 0
static void des_xmlParserCtxtPtr(int no ATTRIBUTE_UNUSED, xmlParserCtxtPtr val) {
static void des_xmlParserCtxtPtr(int no ATTRIBUTE_UNUSED, xmlParserCtxtPtr val, int nr ATTRIBUTE_UNUSED) {
def is_known_param_type(name): for type in known_param_types: if type == name: return 1 return 0
static xmlValidCtxtPtr gen_xmlValidCtxtPtr(int no) {
static xmlValidCtxtPtr gen_xmlValidCtxtPtr(int no, int nr ATTRIBUTE_UNUSED) {
def is_known_param_type(name): for type in known_param_types: if type == name: return 1 return 0
static void des_xmlValidCtxtPtr(int no ATTRIBUTE_UNUSED, xmlValidCtxtPtr val) {
static void des_xmlValidCtxtPtr(int no ATTRIBUTE_UNUSED, xmlValidCtxtPtr val, int nr ATTRIBUTE_UNUSED) {
def is_known_param_type(name): for type in known_param_types: if type == name: return 1 return 0
static xmlDocPtr gen_xmlDocPtr(int no) {
static xmlDocPtr gen_xmlDocPtr(int no, int nr ATTRIBUTE_UNUSED) {
def is_known_param_type(name): for type in known_param_types: if type == name: return 1 return 0
static void des_xmlDocPtr(int no ATTRIBUTE_UNUSED, xmlDocPtr val) {
static void des_xmlDocPtr(int no ATTRIBUTE_UNUSED, xmlDocPtr val, int nr ATTRIBUTE_UNUSED) {
def is_known_param_type(name): for type in known_param_types: if type == name: return 1 return 0
static xmlNodePtr gen_xmlNodePtr(int no) {
static xmlNodePtr gen_xmlNodePtr(int no, int nr ATTRIBUTE_UNUSED) {
def is_known_param_type(name): for type in known_param_types: if type == name: return 1 return 0
static void des_xmlNodePtr(int no ATTRIBUTE_UNUSED, xmlNodePtr val) {
static void des_xmlNodePtr(int no ATTRIBUTE_UNUSED, xmlNodePtr val, int nr ATTRIBUTE_UNUSED) {
def is_known_param_type(name): for type in known_param_types: if type == name: return 1 return 0
static xmlNodePtr gen_xmlNodePtr_in(int no) {
static xmlNodePtr gen_xmlNodePtr_in(int no, int nr ATTRIBUTE_UNUSED) {
def is_known_param_type(name): for type in known_param_types: if type == name: return 1 return 0
static void des_xmlNodePtr_in(int no ATTRIBUTE_UNUSED, xmlNodePtr val ATTRIBUTE_UNUSED) {
static void des_xmlNodePtr_in(int no ATTRIBUTE_UNUSED, xmlNodePtr val ATTRIBUTE_UNUSED, int nr ATTRIBUTE_UNUSED) {
def is_known_param_type(name): for type in known_param_types: if type == name: return 1 return 0
static xmlTextWriterPtr gen_xmlTextWriterPtr(int no) {
static xmlTextWriterPtr gen_xmlTextWriterPtr(int no, int nr ATTRIBUTE_UNUSED) {
def is_known_param_type(name): for type in known_param_types: if type == name: return 1 return 0
static void des_xmlTextWriterPtr(int no ATTRIBUTE_UNUSED, xmlTextWriterPtr val) {
static void des_xmlTextWriterPtr(int no ATTRIBUTE_UNUSED, xmlTextWriterPtr val, int nr ATTRIBUTE_UNUSED) {
def is_known_param_type(name): for type in known_param_types: if type == name: return 1 return 0
static xmlTextReaderPtr gen_xmlTextReaderPtr(int no) {
static xmlTextReaderPtr gen_xmlTextReaderPtr(int no, int nr ATTRIBUTE_UNUSED) {
def is_known_param_type(name): for type in known_param_types: if type == name: return 1 return 0
static void des_xmlTextReaderPtr(int no ATTRIBUTE_UNUSED, xmlTextReaderPtr val) {
static void des_xmlTextReaderPtr(int no ATTRIBUTE_UNUSED, xmlTextReaderPtr val, int nr ATTRIBUTE_UNUSED) {
def is_known_param_type(name): for type in known_param_types: if type == name: return 1 return 0
static xmlBufferPtr gen_xmlBufferPtr(int no) {
static xmlBufferPtr gen_xmlBufferPtr(int no, int nr ATTRIBUTE_UNUSED) {
def is_known_param_type(name): for type in known_param_types: if type == name: return 1 return 0
static void des_xmlBufferPtr(int no ATTRIBUTE_UNUSED, xmlBufferPtr val) {
static void des_xmlBufferPtr(int no ATTRIBUTE_UNUSED, xmlBufferPtr val, int nr ATTRIBUTE_UNUSED) {
def is_known_param_type(name): for type in known_param_types: if type == name: return 1 return 0
static xmlListPtr gen_xmlListPtr(int no) {
static xmlListPtr gen_xmlListPtr(int no, int nr ATTRIBUTE_UNUSED) {
def is_known_param_type(name): for type in known_param_types: if type == name: return 1 return 0
static void des_xmlListPtr(int no ATTRIBUTE_UNUSED, xmlListPtr val) {
static void des_xmlListPtr(int no ATTRIBUTE_UNUSED, xmlListPtr val, int nr ATTRIBUTE_UNUSED) {
def is_known_param_type(name): for type in known_param_types: if type == name: return 1 return 0
static xmlHashTablePtr gen_xmlHashTablePtr(int no) {
static xmlHashTablePtr gen_xmlHashTablePtr(int no, int nr ATTRIBUTE_UNUSED) {
def is_known_param_type(name): for type in known_param_types: if type == name: return 1 return 0
static void des_xmlHashTablePtr(int no ATTRIBUTE_UNUSED, xmlHashTablePtr val) {
static void des_xmlHashTablePtr(int no ATTRIBUTE_UNUSED, xmlHashTablePtr val, int nr ATTRIBUTE_UNUSED) {
def is_known_param_type(name): for type in known_param_types: if type == name: return 1 return 0
static xmlXPathObjectPtr gen_xmlXPathObjectPtr(int no) {
static xmlXPathObjectPtr gen_xmlXPathObjectPtr(int no, int nr ATTRIBUTE_UNUSED) {
def is_known_param_type(name): for type in known_param_types: if type == name: return 1 return 0
static void des_xmlXPathObjectPtr(int no ATTRIBUTE_UNUSED, xmlXPathObjectPtr val) {
static void des_xmlXPathObjectPtr(int no ATTRIBUTE_UNUSED, xmlXPathObjectPtr val, int nr ATTRIBUTE_UNUSED) {
def is_known_param_type(name): for type in known_param_types: if type == name: return 1 return 0
"xmlChar_ptr", "const_xmlChar_ptr", "void_ptr" ];
"xmlChar_ptr", "const_xmlChar_ptr", "void_ptr", "xmlXPathObjectPtr", "xmlCharEncoding" ];
def is_known_param_type(name): for type in known_param_types: if type == name: return 1 return 0
printf("Total: %d tests, %d errors\\n", call_tests, ret);
printf("Total: %d functions, %d tests, %d errors\\n", function_tests, call_tests, ret);
def is_known_return_type(name): for type in known_return_types: if type == name: return 1 return 0
test.write(" %s = gen_%s(n_%s);\n" % (nam, type, nam))
test.write(" %s = gen_%s(n_%s, %d);\n" % (nam, type, nam, i)) i = i + 1;
test.write("#ifdef %s\n" % (cond.get_content()))
test.write(" des_%s(n_%s, %s);\n" % (type, nam, nam))
test.write(" des_%s(n_%s, %s, %d);\n" % (type, nam, nam, i)) i = i + 1;
test.write("#ifdef %s\n" % (cond.get_content()))
Makefile = Makefile + "\t%s\n" % (test)
Makefile = Makefile + "\t@(%s)\n" % (test)
def dump_Makefile(): for file in glob.glob('*.xml'): extras.append(file) for file in glob.glob('*.out'): extras.append(file) Makefile="""# Beware this is autogenerated by config.py
elif name[0:9] == "xmlRegexp":
elif name[0:9] == "xmlRegexp" and file == "xmlregexp":
def nameFixup(name, classe, type, file): listname = classe + "List" ll = len(listname) l = len(classe) if name[0:l] == listname: func = name[l:] func = string.lower(func[0:1]) + func[1:] elif name[0:12] == "xmlParserGet" and file == "python_accessor": func = name[12:] func = string.lower(func[0:1]) + func[1:] elif name...
elif name[0:6] == "xmlReg":
elif name[0:6] == "xmlReg" and file == "xmlregexp":
def nameFixup(name, classe, type, file): listname = classe + "List" ll = len(listname) l = len(classe) if name[0:l] == listname: func = name[l:] func = string.lower(func[0:1]) + func[1:] elif name[0:12] == "xmlParserGet" and file == "python_accessor": func = name[12:] func = string.lower(func[0:1]) + func[1:] elif name...
def registerErrorHandler(f, ctx): """Register a Python written function to for error reporting. The function is called back as f(ctx, error). """ import sys if not sys.modules.has_key('libxslt'): ret = libxml2mod.xmlRegisterErrorHandler(f,ctx) else: import libxslt ret = libxslt.registerErrorHandler(f,ctx) return ret
def registerXPathFunction(ctxt, name, ns_uri, f): ret = libxml2mod.xmlRegisterXPathFunction(ctxt, name, ns_uri, f)
"xmlTextWriterPtr", "xmlTextReaderPtr" ];
"xmlTextWriterPtr", "xmlTextReaderPtr", "xmlBufferPtr", "xmlListPtr", "xmlXPathObjectPtr", "xmlHashTablePtr", ]
def type_convert(str, name, info, module, function, pos): res = string.replace(str, " *", "_ptr") res = string.replace(res, " ", "_") res = string.replace(res, "htmlNode", "xmlNode") res = string.replace(res, "htmlDoc", "xmlDoc") res = string.replace(res, "htmlParser", "xmlParser") if res == 'const_char_ptr': if string...
if (no == 0) return(&chartab);
if (no == 0) return(&chartab[0]);
def is_known_param_type(name): for type in known_param_types: if type == name: return 1 return 0
"xmlChar_ptr" ];
"xmlChar_ptr", "const_xmlChar_ptr" ];
def is_known_param_type(name): for type in known_param_types: if type == name: return 1 return 0
nr = 0 miss = 'none'
nr1 = 0 miss1 = 'none' nr2 = 0 miss2 = 'none' nr3 = 0 miss3 = 'none'
test.write("#ifdef %s\n" % (cond.get_content()))
if n > nr: miss = missing nr = n if nr > 0: print "most needed type support: %s %d times" % (miss, nr)
if n > nr1: miss3 = miss2 nr3 = nr2 miss2 = miss1 nr2 = nr1 miss1 = missing nr1 = n elif n > nr2: miss3 = miss2 nr3 = nr2 miss2 = missing nr2 = n elif n > nr3: miss3 = missing nr3 = n if nr1 > 0: print "most needed type support: %s %d times, %s %d and %s %d" % ( miss1, nr1, miss2, nr2, miss3, nr3)
test.write("#ifdef %s\n" % (cond.get_content()))
file = 'html/libxml-' + string.lower(hash[id]) + '.html';
if hash.has_key(id): module = string.lower(hash[id]) else: module = 'index' file = 'html/libxml-' + module + '.html';
def link(id): if ids.has_key(id): target = string.upper(ids[id]) else: target = string.upper(id) file = 'html/libxml-' + string.lower(hash[id]) + '.html'; return file + '#' + target
ret = _libxml.registerXPathFunction(ctxt, name, ns_uri, f)
ret = _libxml.xmlRegisterXPathFunction(ctxt, name, ns_uri, f)
def registerXPathFunction(ctxt, name, ns_uri, f): ret = _libxml.registerXPathFunction(ctxt, name, ns_uri, f)
reader.SetParserProp(libxml2.PARSER_LOADDTD,1) reader.SetParserProp(libxml2.PARSER_DEFAULTATTRS,1) reader.SetParserProp(libxml2.PARSER_SUBST_ENTITIES,1) reader.SetParserProp(libxml2.PARSER_VALIDATE,self.__validate)
if self.__extparams: reader.SetParserProp(libxml2.PARSER_LOADDTD,1) reader.SetParserProp(libxml2.PARSER_DEFAULTATTRS,1) reader.SetParserProp(libxml2.PARSER_SUBST_ENTITIES,1) reader.SetParserProp(libxml2.PARSER_VALIDATE,self.__validate) else: reader.SetParserProp(libxml2.PARSER_LOADDTD, 0)
def parse(self, source): self.__parsing = 1 try: # prepare source and create reader if type(source) in StringTypes: reader = libxml2.newTextReaderFilename(source) else: source = saxutils.prepare_input_source(source) input = libxml2.inputBuffer(source.getByteStream()) reader = input.newTextReader(source.getSystemId()) r...
return 1
return self.__extparams
def getFeature(self, name): if name == feature_namespaces: return self.__ns elif name == feature_namespace_prefixes: return self.__nspfx elif name == feature_validation: return self.__validate elif name == feature_external_ges: return 1 # TODO (does that relate to PARSER_LOADDTD)? elif name == feature_external_pes: ret...
if state == 0: raise SAXNotSupportedException("Feature '%s' not supported" % \ name)
self.__extparams = state
def setFeature(self, name, state): if self.__parsing: raise SAXNotSupportedException("Cannot set feature %s " \ "while parsing" % name) if name == feature_namespaces: self.__ns = state elif name == feature_namespace_prefixes: self.__nspfx = state elif name == feature_validation: self.__validate = state elif name == fea...
print "Missing type converters: %s" % (unknown_types.keys())
print "Missing type converters: " for type in unknown_types.keys(): print "%s:%d " % (type, len(unknown_types[type])), print
def print_function_wrapper(name, output, export, include): global py_types global unknown_types global functions global skipped_modules try: (desc, ret, args, file) = functions[name] except: print "failed to get function %s infos" return if skipped_modules.has_key(file): return 0 if skip_function(name) == 1: return 0...
writeline(global_functions_hdr,"extern "+fields[0]+" "+fields[1]+fields[2]+";")
writeline(global_functions_hdr,"LIBXML_DLL_IMPORT extern "+fields[0]+" "+fields[1]+fields[2]+";")
writeline(global_functions_hdr, "#ifdef LIBXML_THREAD_ENABLED")
writeline(global_functions_hdr,"extern "+fields[0]+" "+fields[1]+";")
writeline(global_functions_hdr,"LIBXML_DLL_IMPORT extern "+fields[0]+" "+fields[1]+";")
writeline(global_functions_hdr, "#ifdef LIBXML_THREAD_ENABLED")
writeline(global_functions_impl, "\treturn (&get_glob_struct()->"+fields[1]+");")
writeline(global_functions_impl, "\treturn (&xmlGetGlobalState()->"+fields[1]+");")
writeline(global_functions_hdr, "#ifdef LIBXML_THREAD_ENABLED")
log.write("\n ============= test %d line %d ================\n" % ( nb_schemas_tests, node.lineNo()))
sections = node.xpathEval('string(section)') log.write("\n ======== test %d line %d section %s ==========\n" % ( nb_schemas_tests, node.lineNo(), sections))
def handle_testCase(node): global nb_schemas_tests global nb_instances_tests global resources log.write("\n ============= test %d line %d ================\n" % ( nb_schemas_tests, node.lineNo())) resources = {} if debug: print "test %d line %d" % (nb_schemas_tests, node.lineNo()) dirs = node.xpathEval('dir') for ...
if sections != []:
if sections != [] and level <= 0:
def handle_testSuite(node, level = 0): global nb_schemas_tests, nb_schemas_success, nb_schemas_failed global nb_instances_tests, nb_instances_success, nb_instances_failed if level >= 1: old_schemas_tests = nb_schemas_tests old_schemas_success = nb_schemas_success old_schemas_failed = nb_schemas_failed old_instances_tes...
print "Usage index.py [--force] [--archive] [--archive-month month] [--API] [--docs]"
print "Usage index.py [--force] [--archive] [--archive-year year] [--archive-month month] [--API] [--docs]"
def usage(): print "Usage index.py [--force] [--archive] [--archive-month month] [--API] [--docs]" sys.exit(1)
analyzeArchives(force)
analyzeArchives(None, force) elif args[i] == '--archive-year': i = i + 1; year = args[i] months = ["January" , "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"]; for month in months: try: str = "%s-%s" % (year, month) T = time.strptime(str, "%Y-%B") t = time....
def main(): args = sys.argv[1:] force = 0 if args: i = 0 while i < len(args): if args[i] == '--force': force = 1 elif args[i] == '--archive': analyzeArchives(force) elif args[i] == '--archive-month': i = i + 1; month = args[i] try: T = time.strptime(month, "%Y-%B") t = time.mktime(T) + 3600 * 24 * 10; analyzeArchives(t...
../../test/valid/rss.xml:172: validity error: Element rss does not carry attribute version </rss> ^
../../test/valid/xlink.xml:529: validity error: attribute def line 199 references an unknown ID "dt-xlg"
valid_files = files = glob.glob("../../test/valid/*.x*")
valid_files = glob.glob("../../test/valid/*.x*") valid_files.sort()
def callback(ctx, str): global err err = err + "%s" % (str)
ids = dict.functions.keys() + dict.variables.keys() + \ dict.macros.keys() + dict.typedefs.keys() + \ dict.structs.keys() + dict.enums.keys()
ids = dict.macros.keys()
def serialize_exports(self, output, file): module = self.modulename_file(file)
output.write(" <exports symbol='%s'/>\n" % (id))
if dict.functions.has_key(id): continue if dict.variables.has_key(id): continue if dict.typedefs.has_key(id): continue if dict.structs.has_key(id): continue if dict.enums.has_key(id): continue output.write(" <exports symbol='%s' type='macro'/>\n" % (id)) ids = dict.enums.keys() ids.sort() for id in uniq(ids): outpu...
def serialize_exports(self, output, file): module = self.modulename_file(file)
return self.content()
return _libxml.xmlNodeGetContent(self._o)
def __getattr__(self, attr): if attr == "parent": ret = _libxml.parent(self._o) if ret == None: return None return xmlNode(_obj=ret) elif attr == "properties": ret = _libxml.properties(self._o) if ret == None: return None return xmlAttr(_obj=ret)
module = string.split(file, '/')[-1]
module = os.path.basename(file)
def modulename_file(self, file): module = string.split(file, '/')[-1]
Normaly, readonly fields are included. To exclude readonly fields,
Normally, readonly fields are included. To exclude readonly fields,
def getWidgetsData(view, schema, strict=True, names=None, set_missing=True, do_not_raise=False, exclude_readonly=False): """Collect the user-entered data defined by a schema Data is collected from view widgets. For every field in the schema, we look for a view of the same name and get it's data. The data are returned...
return ('<input type="hidden" name="%s" value="%s">' % (self.name, cgi.escape(term.token))
return ('<input type="hidden" name="%s" value=%s />' % (self.name, xml.sax.saxutils.quoteattr(term.token))
def hidden(self): value = self._value() if value == self.context.missing_value: return '' # Nothing to hide ;)
result.append(' <input type="hidden" name="%s" value="%s">' % (self.name, cgi.escape(term.token))) result.append(' <input type="hidden" name="%s.displayed" value="y">'
result.append( ' <input type="hidden" name="%s" value=%s />' % (self.name, xml.sax.saxutils.quoteattr(term.token))) result.append(' <input type="hidden" name="%s.displayed" value="y" />'
def __call__(self): result = ['<div class="value">'] value = self._value() field = self.context
'<input type="submit" name="%s.apply" value="%s">'
'<input type="submit" name="%s.apply" value="%s" />'
def _renderResults(self, results, name): terms = [] for value in results: term = self.terms.getTerm(value) terms.append((term.title, term.token)) terms.sort()
result.append('<input type="hidden" name="%s:list" value="%s">' % (self.name, cgi.escape(term.token)) )
result.append( '<input type="hidden" name="%s:list" value=%s />' % (self.name, xml.sax.saxutils.quoteattr(term.token)) )
def hidden(self): value = self._value() if value == self.context.missing_value: return '' # Nothing to hide ;)
' value="%s">' % (self.name, cgi.escape(term.token))
' value=%s />' % (self.name, xml.sax.saxutils.quoteattr(term.token))
def __call__(self): result = ['<div class="value">'] value = self._value() field = self.context
' <input type="hidden" name="%s:list" value="%s">' % (self.name, cgi.escape(term.token))) result.append(' <br>')
' <input type="hidden" name="%s:list" value=%s />' % (self.name, xml.sax.saxutils.quoteattr(term.token))) result.append(' <br />')
def __call__(self): result = ['<div class="value">'] value = self._value() field = self.context
' <input type="submit" name="%s.remove" value="%s">'
' <input type="submit" name="%s.remove" value="%s" />'
def __call__(self): result = ['<div class="value">'] value = self._value() field = self.context
result.append(' <br>') result.append(' <input type="hidden" name="%s.displayed" value="y">'
result.append(' <br />') result.append(' <input type="hidden" name="%s.displayed" value="y" />'
def __call__(self): result = ['<div class="value">'] value = self._value() field = self.context
'<input type="submit" name="%s.apply" value="%s">'
'<input type="submit" name="%s.apply" value="%s" />'
def _renderResults(self, results, name): terms = [] apply = self._translate(_("SourceListInputWidget-apply", default="Apply")) for value in results: term = self.terms.getTerm(value) terms.append((term.title, term.token)) terms.sort() return ( '<select name="%s.selection:list" multiple>\n' '%s\n' '</select>\n' '<input t...
selected_values = self.context.get(self.context.context)
if hasattr(self.context.context, self.context.__name__): selected_values = self.context.get(self.context.context) else: selected_values = []
def choices(self): """Return a set of tuples (text, value) that are available.""" selected_values = self.context.get(self.context.context) return [{'text': self.textForValue(term), 'value': term.token} for term in self.vocabulary if term.value not in selected_values]
prefix is a string that is appended to the widget names in the generated
prefix is a string that is prepended to the widget names in the generated
def setUpWidgets(view, schema, viewType, prefix=None, ignoreStickyValues=False, initial={}, names=None, context=None): """Sets up widgets for the fields defined by a schema. view is the view that will be configured with widgets. schema is an interface containing the fields that widgets will be created for. prefix is...
>>> isinstance(widget, MultiSelectWidget)
>>> isinstance(widget, OrderedMultiSelectWidget)
def setUp(test): setup.placelessSetUp() context = xmlconfig.file("tests/registerWidgets.zcml", zope.app.form.browser)
>>> def normalize(s): ... return '\\n '.join(s.split())
>>> field = Bool(__name__='foo', title=u'on') >>> request = TestRequest() >>> widget = CheckBoxWidget(field, request)
>>> def normalize(s):
>>> print normalize( widget() ) <input class="hiddenType" id="field.foo.used" name="field.foo.used" type="hidden" value="" /> <input class="checkboxType" checked="checked" id="field.foo" name="field.foo" type="checkbox" />
hasInput returns True when the request contains the field.<name>.used value:
>>> def normalize(s):
>>> print normalize( widget.hidden() ) <input class="hiddenType" id="field.foo" name="field.foo" type="hidden" value="on" />
>>> 'field.foo.used' in request.form False >>> widget.hasInput() False >>> request.form['field.foo.used'] = '' >>> widget.hasInput() True getInputValue returns True when field.<name> equals (and only equals) 'on': >>> 'field.foo' in request.form False >>> widget.getInputValue() False >>> request.form['field.foo'] = '...
>>> def normalize(s):
When a checkbox is not 'checked', it's value is not sent in the request, so we consider it 'False', which means that 'required' for a boolean field doesn't make much sense in the end.
The checkbox widget does not support None values, so a Bool required constraint will always be met with checkbox input:
>>> def normalize(s):
>>> field = Bool(__name__='foo', title=u'on', required=True) >>> request = TestRequest(form={'field.foo.used': u''}) >>> widget = CheckBoxWidget(field, request) >>> widget.hasInput() True >>> widget.validate() >>> widget.getInputValue() False
>>> field.required = True >>> widget.validate()
>>> def normalize(s):
if self.context.value_type is None: return ''
assert self.context.value_type is not None
def __call__(self): """Render the widget """ # XXX we really shouldn't allow value_type of None if self.context.value_type is None: return ''
def unescape(str): if str is not None: str = saxutils.unescape(str) return str
def unescape(str): if str is not None: str = saxutils.unescape(str) return str
return unescape(value)
return value
def _toFieldValue(self, input): if self.convert_missing_value and input == self._missing: value = self.context.missing_value else: # We convert everything to unicode. This might seem a bit crude, # but anything contained in a TextWidget should be representable # as a string. Note that you always have the choice of over...
value = unescape(value)
def _toFieldValue(self, value): value = super(TextAreaWidget, self)._toFieldValue(value) if value: try: value = unicode(value) except ValueError, v: raise ConversionError(_("Invalid unicode data"), v) else: value = unescape(value) value = value.replace("\r\n", "\n") return value
ifaces = implementedBy(class_)
def widget(self, _context, field, class_, **kw): attrs = kw ifaces = implementedBy(class_) # Try to do better than accepting the string value by looking through # the interfaces and trying to find the field, so that we can use # 'fromUnicode()' for name, value in kw.items(): for iface in ifaces: if name in iface: attrs...
for name, value in kw.items(): for iface in ifaces: if name in iface: attrs[name] = iface[name].fromUnicode(value) break
if isinstance(class_, type): ifaces = implementedBy(class_) for name, value in kw.items(): for iface in ifaces: if name in iface: attrs[name] = iface[name].fromUnicode(value) break
def widget(self, _context, field, class_, **kw): attrs = kw ifaces = implementedBy(class_) # Try to do better than accepting the string value by looking through # the interfaces and trying to find the field, so that we can use # 'fromUnicode()' for name, value in kw.items(): for iface in ifaces: if name in iface: attrs...
def _getCurrentValue(self): """Detects the status of the widget and selectes either the input value that came from the request, the value from the _data attribute or the default value. """ if not self._renderedValueSet():
def _getCurrentValueHelper(self): """Helper to get the current input value. Raises InputErrors if the data could not be validated/converted. """ input_value = None if self._renderedValueSet(): input_value = self._data else:
def _getCurrentValue(self): """Detects the status of the widget and selectes either the input value that came from the request, the value from the _data attribute or the default value. """ if not self._renderedValueSet(): if self.hasInput():
try: value = self.getInputValue() except InputErrors: return self.request.form.get(self.name, self._missing)
input_value = self.getInputValue()
def _getCurrentValue(self): """Detects the status of the widget and selectes either the input value that came from the request, the value from the _data attribute or the default value. """ if not self._renderedValueSet(): if self.hasInput():
value = self._getDefault()
input_value = self._getDefault() return input_value def _getCurrentValue(self): """Returns the current input value. Returns None if the data could not be validated/converted. """ try: input_value = self._getCurrentValueHelper() except InputErrors: input_value = None return input_value def _getFormValue(self): """Ret...
def _getCurrentValue(self): """Detects the status of the widget and selectes either the input value that came from the request, the value from the _data attribute or the default value. """ if not self._renderedValueSet(): if self.hasInput():
value = self._data return value def _getFormValue(self): """Returns a value suitable for use in an HTML form.""" value = self._getCurrentValue() return self._toFormValue(value)
form_value = self._toFormValue(input_value) return form_value
def _getCurrentValue(self): """Detects the status of the widget and selectes either the input value that came from the request, the value from the _data attribute or the default value. """ if not self._renderedValueSet(): if self.hasInput():
self.context.validate(value)
field.validate(value)
def getInputValue(self): value = self._input_value() # Remaining code copied from SimpleInputWidget
tag = 'input' type = 'text' cssClass = '' extra = '' _missing = ''
tag = u'input' type = u'text' cssClass = u'' extra = u'' _missing = u''
... def __call__(self):
return '<div class="%s">%s</div><div class="field">%s</div>' \ '<div class="error">%s</div>' % (self.labelClass(), self.label(), self(), self.error()) else: return '<div class="%s">%s</div><div class="field">%s</div>' % (
return u'<div class="%s">%s</div><div class="field">%s</div>' \ u'<div class="error">%s</div>' % (self.labelClass(), self.label(), self(), self.error()) else: return u'<div class="%s">%s</div><div class="field">%s</div>' % (
def row(self): if self._error: return '<div class="%s">%s</div><div class="field">%s</div>' \ '<div class="error">%s</div>' % (self.labelClass(), self.label(), self(), self.error()) else: return '<div class="%s">%s</div><div class="field">%s</div>' % ( self.labelClass(), self.label(), self())