Пример #1
0
    def test_obj2(self, **kw):
        user = UserO(u"test")
        root = self.app.GetRoot()
        obj = root.Create("type1", data1_2, user)
        self.remove.append(obj.id)
        v = Viewy()

        form = ObjectForm(loadFromType="type1", context=obj, view=v, request=Request(), app=self.app)
        form.formUrl = "form/url"
        form.cssID = u"upload"
        form.css_class = u"niveform"
        count = self.app.db.GetCountEntries()
        # edit
        form.actions = [
        Conf(**{"id": "default", "method": "StartObject","name": "Initialize",    "hidden":True, "description": "", "css_class":"", "html":"", "tag":""}),
        Conf(**{"id": "save",       "method": "UpdateObj","name": "Save",         "hidden":False, "description": "", "css_class":"", "html":"", "tag":""}),
        Conf(**{"id": "cancel",  "method": "Cancel",    "name": "Cancel",         "hidden":False, "description": "", "css_class":"", "html":"", "tag":""})
        ]
        form.Setup()
        form.Process()
        req = {"save$":1}
        req.update(data1_1)
        form.request = req
        form.Process()
        req = {"cancel$":1}
        form.request = req
        form.Process()
        d = form.LoadObjData()
        self.assertEqual(count, self.app.db.GetCountEntries())

        form = ObjectForm(loadFromType="type1", context=obj, view=v, request=Request(), app=self.app)
        form.subsets = {u"test": {"fields": [u"ftext",u"funit"], 
                                  "actions": [u"defaultEdit",u"edit",u"cancel"]}}
        form.Setup(subset = "test")
        form.Process()
        req = {"edit$":1}
        req.update(data1_2)
        form.request = req
        form.Process(values={"fnumber":333})
        req = {"cancel$":1}
        form.request = req
        form.Process()
        self.assertEqual(count, self.app.db.GetCountEntries())

        form = ObjectForm(loadFromType="type1", context=obj, view=v, request=Request(), app=self.app)
        form.subsets = {u"test": {"fields": [u"ftext", FieldConf(**{"id": "section1", "name": "Section 1", "datatype": "url"})],
                                  "actions": [u"defaultEdit",u"edit",u"cancel"]}}
        form.subset = "test"
        form.Setup(subset = "test")
        form.Process()
        req = {"edit$":1}
        req.update(data1_2)
        form.request = req
        form.Process()
        req = {"cancel$":1}
        form.request = req
        form.Process()
        self.assertEqual(count, self.app.db.GetCountEntries())

        form = ObjectForm(loadFromType="type1", context=obj, view=v, request=Request(), app=self.app)
        form.subsets = {u"test": {"fields": [u"ftext", FieldConf(**{"id": "section1", "name": "Section 1", "datatype": "unitlist"})],
                                  "actions": [u"defaultEdit",u"edit",u"cancel"]}}
        try:
            form.Setup(subset="test3")
            form.Process()
            self.assert_(False)
        except ConfigurationError:
            pass
        self.assertEqual(count, self.app.db.GetCountEntries())
Пример #2
0
    def test_obj2(self, **kw):
        user = UserO(u"test")
        root = self.app.GetRoot()
        obj = root.Create("type1", data1_2, user)
        self.remove.append(obj.id)
        v = Viewy()

        form = ObjectForm(loadFromType="type1",
                          context=obj,
                          view=v,
                          request=Request(),
                          app=self.app)
        form.formUrl = "form/url"
        form.cssID = u"upload"
        form.css_class = u"niveform"
        count = self.app.db.GetCountEntries()
        # edit
        form.actions = [
            Conf(
                **{
                    "id": "default",
                    "method": "StartObject",
                    "name": "Initialize",
                    "hidden": True,
                    "description": "",
                    "css_class": "",
                    "html": "",
                    "tag": ""
                }),
            Conf(
                **{
                    "id": "save",
                    "method": "UpdateObj",
                    "name": "Save",
                    "hidden": False,
                    "description": "",
                    "css_class": "",
                    "html": "",
                    "tag": ""
                }),
            Conf(
                **{
                    "id": "cancel",
                    "method": "Cancel",
                    "name": "Cancel",
                    "hidden": False,
                    "description": "",
                    "css_class": "",
                    "html": "",
                    "tag": ""
                })
        ]
        form.Setup()
        form.Process()
        req = {"save$": 1}
        req.update(data1_1)
        form.request = req
        form.Process()
        req = {"cancel$": 1}
        form.request = req
        form.Process()
        d = form.LoadObjData()
        self.assertEqual(count, self.app.db.GetCountEntries())

        form = ObjectForm(loadFromType="type1",
                          context=obj,
                          view=v,
                          request=Request(),
                          app=self.app)
        form.subsets = {
            u"test": {
                "fields": [u"ftext", u"funit"],
                "actions": [u"defaultEdit", u"edit", u"cancel"]
            }
        }
        form.Setup(subset="test")
        form.Process()
        req = {"edit$": 1}
        req.update(data1_2)
        form.request = req
        form.Process(values={"fnumber": 333})
        req = {"cancel$": 1}
        form.request = req
        form.Process()
        self.assertEqual(count, self.app.db.GetCountEntries())

        form = ObjectForm(loadFromType="type1",
                          context=obj,
                          view=v,
                          request=Request(),
                          app=self.app)
        form.subsets = {
            u"test": {
                "fields": [
                    u"ftext",
                    FieldConf(**{
                        "id": "section1",
                        "name": "Section 1",
                        "datatype": "url"
                    })
                ],
                "actions": [u"defaultEdit", u"edit", u"cancel"]
            }
        }
        form.subset = "test"
        form.Setup(subset="test")
        form.Process()
        req = {"edit$": 1}
        req.update(data1_2)
        form.request = req
        form.Process()
        req = {"cancel$": 1}
        form.request = req
        form.Process()
        self.assertEqual(count, self.app.db.GetCountEntries())

        form = ObjectForm(loadFromType="type1",
                          context=obj,
                          view=v,
                          request=Request(),
                          app=self.app)
        form.subsets = {
            u"test": {
                "fields": [
                    u"ftext",
                    FieldConf(
                        **{
                            "id": "section1",
                            "name": "Section 1",
                            "datatype": "unitlist"
                        })
                ],
                "actions": [u"defaultEdit", u"edit", u"cancel"]
            }
        }
        try:
            form.Setup(subset="test3")
            form.Process()
            self.assert_(False)
        except ConfigurationError:
            pass
        self.assertEqual(count, self.app.db.GetCountEntries())
Пример #3
0
    def test_obj(self, **kw):
        root = self.app.GetRoot()
        v = Viewy()
        form = ObjectForm(loadFromType="type1", context=root, view=v, request=Request(), app=self.app)
        form.formUrl = "form/url"
        form.cssID = u"upload"
        form.css_class = u"niveform"

        # create
        form.actions = [
        Conf(**{"id": "default", "method": "StartForm","name": "Initialize", "hidden":True,  "description": "", "css_class":"", "html":"", "tag":""}),
        Conf(**{"id": "create",  "method": "CreateObj","name": "Create",     "hidden":False, "description": "", "css_class":"", "html":"", "tag":""}),
        Conf(**{"id": "cancel",  "method": "Cancel",   "name": "Cancel",     "hidden":False, "description": "", "css_class":"", "html":"", "tag":""})
        ]
        form.Setup(addTypeField = True)
        
        count = self.app.db.GetCountEntries()
        result, data, action=form.Process()
        self.assert_(result)
        self.assertEqual(action.id,"default")
        self.assertEqual(count, self.app.db.GetCountEntries())

        req = {"create$":1, "pool_type":"type1"}
        req.update(data1_1)
        form.request = req
        result, data, action=form.Process(values={"fnumber":999})
        self.assert_(result)
        self.assertEqual(action.id,"create")
        self.assertEqual(count+1, self.app.db.GetCountEntries())
        self.remove.append(result.id)
        
        req = {"cancel$":1}
        form.request = req
        result, data, action=form.Process()
        self.assert_(result)
        self.assertEqual(action.id,"cancel")
        self.assertEqual(count+1, self.app.db.GetCountEntries())
        
        form = ObjectForm(loadFromType="type1", context=root, view=v, request=Request(), app=self.app)
        form.subsets = {u"test": {"fields": [u"ftext",u"funit"], 
                                  "actions": [u"default", u"create",u"cancel"]}}
        form.Setup(subset = "test", addTypeField = True)
        result, data, action=form.Process()
        self.assert_(result)
        self.assertEqual(action.id,"default")
        self.assertEqual(count+1, self.app.db.GetCountEntries())

        req = {"create$":1, "pool_type":"type1"}
        req.update(data1_2)
        form.request = req
        result, data, action=form.Process()
        self.assert_(result)
        self.assertEqual(action.id,"create")
        self.assertEqual(count+2, self.app.db.GetCountEntries())
        self.remove.append(result.id)
        
        req = {"cancel$":1}
        form.request = req
        result, data, action=form.Process()
        self.assert_(result)
        self.assertEqual(action.id,"cancel")
        self.assertEqual(count+2, self.app.db.GetCountEntries())

        form = ObjectForm(loadFromType="type1", context=root, view=v, request=Request(), app=self.app)
        form.subsets = {u"test": {"fields": [u"ftext", FieldConf(**{"id": "section1", "name": "Section 1", "datatype": "email"})], 
                                  "actions": [u"default", u"create",u"cancel"]}}
        form.Setup(subset = "test", addTypeField = True)
        result, data, action=form.Process()
        self.assert_(result)
        self.assertEqual(action.id,"default")
        self.assertEqual(count+2, self.app.db.GetCountEntries())
        
        req = {"create$":1, "pool_type":"type1"}
        req.update(data1_2)
        form.request = req
        result, data, action=form.Process()
        self.assert_(result)
        self.assertEqual(action.id,"create")
        self.assertEqual(count+3, self.app.db.GetCountEntries())
        self.remove.append(result.id)

        req = {"cancel$":1}
        form.request = req
        result, data, action=form.Process()
        self.assert_(result)
        self.assertEqual(action.id,"cancel")
        self.assertEqual(count+3, self.app.db.GetCountEntries())
Пример #4
0
    def test_obj(self, **kw):
        root = self.app.GetRoot()
        v = Viewy()
        form = ObjectForm(loadFromType="type1",
                          context=root,
                          view=v,
                          request=Request(),
                          app=self.app)
        form.formUrl = "form/url"
        form.cssID = u"upload"
        form.css_class = u"niveform"

        # create
        form.actions = [
            Conf(
                **{
                    "id": "default",
                    "method": "StartForm",
                    "name": "Initialize",
                    "hidden": True,
                    "description": "",
                    "css_class": "",
                    "html": "",
                    "tag": ""
                }),
            Conf(
                **{
                    "id": "create",
                    "method": "CreateObj",
                    "name": "Create",
                    "hidden": False,
                    "description": "",
                    "css_class": "",
                    "html": "",
                    "tag": ""
                }),
            Conf(
                **{
                    "id": "cancel",
                    "method": "Cancel",
                    "name": "Cancel",
                    "hidden": False,
                    "description": "",
                    "css_class": "",
                    "html": "",
                    "tag": ""
                })
        ]
        form.Setup(addTypeField=True)

        count = self.app.db.GetCountEntries()
        result, data, action = form.Process()
        self.assert_(result)
        self.assertEqual(action.id, "default")
        self.assertEqual(count, self.app.db.GetCountEntries())

        req = {"create$": 1, "pool_type": "type1"}
        req.update(data1_1)
        form.request = req
        result, data, action = form.Process(values={"fnumber": 999})
        self.assert_(result)
        self.assertEqual(action.id, "create")
        self.assertEqual(count + 1, self.app.db.GetCountEntries())
        self.remove.append(result.id)

        req = {"cancel$": 1}
        form.request = req
        result, data, action = form.Process()
        self.assert_(result)
        self.assertEqual(action.id, "cancel")
        self.assertEqual(count + 1, self.app.db.GetCountEntries())

        form = ObjectForm(loadFromType="type1",
                          context=root,
                          view=v,
                          request=Request(),
                          app=self.app)
        form.subsets = {
            u"test": {
                "fields": [u"ftext", u"funit"],
                "actions": [u"default", u"create", u"cancel"]
            }
        }
        form.Setup(subset="test", addTypeField=True)
        result, data, action = form.Process()
        self.assert_(result)
        self.assertEqual(action.id, "default")
        self.assertEqual(count + 1, self.app.db.GetCountEntries())

        req = {"create$": 1, "pool_type": "type1"}
        req.update(data1_2)
        form.request = req
        result, data, action = form.Process()
        self.assert_(result)
        self.assertEqual(action.id, "create")
        self.assertEqual(count + 2, self.app.db.GetCountEntries())
        self.remove.append(result.id)

        req = {"cancel$": 1}
        form.request = req
        result, data, action = form.Process()
        self.assert_(result)
        self.assertEqual(action.id, "cancel")
        self.assertEqual(count + 2, self.app.db.GetCountEntries())

        form = ObjectForm(loadFromType="type1",
                          context=root,
                          view=v,
                          request=Request(),
                          app=self.app)
        form.subsets = {
            u"test": {
                "fields": [
                    u"ftext",
                    FieldConf(**{
                        "id": "section1",
                        "name": "Section 1",
                        "datatype": "email"
                    })
                ],
                "actions": [u"default", u"create", u"cancel"]
            }
        }
        form.Setup(subset="test", addTypeField=True)
        result, data, action = form.Process()
        self.assert_(result)
        self.assertEqual(action.id, "default")
        self.assertEqual(count + 2, self.app.db.GetCountEntries())

        req = {"create$": 1, "pool_type": "type1"}
        req.update(data1_2)
        form.request = req
        result, data, action = form.Process()
        self.assert_(result)
        self.assertEqual(action.id, "create")
        self.assertEqual(count + 3, self.app.db.GetCountEntries())
        self.remove.append(result.id)

        req = {"cancel$": 1}
        form.request = req
        result, data, action = form.Process()
        self.assert_(result)
        self.assertEqual(action.id, "cancel")
        self.assertEqual(count + 3, self.app.db.GetCountEntries())