Пример #1
0
        def fillDataTypes(objModel):
            classModel = DataModelElement()
            classModel.fillAttributes(objModel.attrib)
            for dataType in objModel.elements.getchildren():
                typeName = removeNSFromValue(dataType.tag)
                modelType = selectType(typeName)
                modelType.fillAttributes(dataType.attrib)

                if hasattr(dataType, "restriction"):
                    modelType.combination = dataType.restriction.attrib.get("combination", "all")
                    for rest in dataType.restriction.getchildren():
                        modelType.constraints[removeNSFromValue(rest.tag)] = rest.text

                classModel.fields[modelType.name] = modelType
            return classModel
Пример #2
0
 def fillRepeater(w):
     r = Repeater()
     for widget in w.getchildren():
         widgetType = removeNSFromValue(widget.tag)
         if widgetType == "repeater":
             r.addWidget(fillRepeater(widget))
         elif widgetType == "layout":
             r.addWidget(fillLayout(widget))
         w = selectWidget(widgetType)
         r.addWidget(w)
     return r
Пример #3
0
        def createWidgetFromXMLObject(w):
            wType = removeNSFromValue(w.tag)
            widget = selectWidget(wType)

            if wType == "layout":
                widget = fillLayout(w)
            elif wType == "repeater":
                widget = fillRepeater(w)
            else:
                widget.fillAttributes(w.attrib)
                if not widget.name:
                    widget.name = w.name + str(nameInc)
                    #                    global nameInc
                    nameInc += 1
            return widget
Пример #4
0
        def fillFreeWidgets():
            if not mainPage.layout:
                raise Exception, "Layout path in the page not defined"

            layoutPackage, layoutName = separateClassName(mainPage.layout)
            if not domains.has_key(layoutPackage):
                raise Exception, "Package %s not defined in layout packages" % layoutPackage
            l = domains.searchItemName(layoutPackage, layoutName)
            if not l:
                raise Exception, "Layout %s not defined in layout packages" % layoutName
            locations = UniqueMap()

            for w in objectModel.getchildren():
                if w.tag == "comment" or (type(w) is not StringElement and type(w) is not ObjectifiedElement):
                    continue
                name = removeNSFromValue(w.tag)

                #                widget = selectWidget(name)

                if name == "layout":
                    raise  Exception, "Layout in free widget!"
                else:
                    widget = createWidgetFromXMLObject(w)
                    #                    widget.fillAttributes(w.attrib)
                    #                    mainPage.addWidget(widget)
                    locations[widget.location] = widget
                    mainPage.widgetNames.append(widget.name)

            for row in l.rows:
                for cell in row.cells:
                    widget = locations.pop(cell.name)
                    if widget:
                        cell.addWidget(widget)

            if len(locations) > 0:
                raise Exception, "There is some unknown location in layout %s of package %s" % (
                    layoutName, layoutPackage)
            mainPage.layout = l