On 4/11/10 5:40 PM, jvandal wrote:
>
> I want to use this test routine , but I also want to use production data.
> What would I do to comment out certain lines, or would I ???
> if __name__ == "__main__":
>       from FrmRecipes import FrmRecipes
>       app = dabo.dApp(MainFormClass=None)
>       app.setup()
>       class TestForm(FrmRecipes):
>               def afterInit(self): pass
>       frm = TestForm(Caption="Test Of PagEditRecipes", Testing=True)
>       test = frm.addObject(PagEditRecipes)
>       test.createItems()
>       frm.Sizer.append1x(test)
>       frm.show()
>       app.start()

The test stuff is intended to show you a quick layout, not to test the data 
binding 
of the entire app. However, you could connect up the live data manually if you 
wanted. I've added such code to PagEditRecipes.py in the repository (r12), but 
here's 
the diff:

Index: PagEditRecipes.py
===================================================================
--- PagEditRecipes.py   (revision 11)
+++ PagEditRecipes.py   (working copy)
@@ -90,14 +90,33 @@


  if __name__ == "__main__":
+       import sys
+       sys.path.insert(0, "../")  ## so we can import biz
        from FrmRecipes import FrmRecipes
+       from biz.Recipes import Recipes
+       from biz.Reccats import Reccats
+
        app = dabo.dApp(MainFormClass=None)
        app.setup()
+
+       con = dabo.db.connect(open("../db/default.cnxml").read())
+       app.dbConnection = con  ## normally added by the main file which we are 
bipassing
+
+       bizRecipes = Recipes(con)
+       bizRecipes.addWhere("recipes.title like '%paul%'")
+       bizRecipes.requery()
+
+       bizReccats = Reccats(con)
+
        class TestForm(FrmRecipes):
-               def afterInit(self): pass
-       frm = TestForm(Caption="Test Of PagEditRecipes", Testing=True)
+               def afterInit(self):
+                       self.addBizobj(bizRecipes)
+                       self.addBizobj(bizReccats)
+
+       frm = TestForm(Caption="Test Of PagEditRecipes")
        test = frm.addObject(PagEditRecipes)
        test.createItems()
+       frm.update()
        frm.Sizer.append1x(test)
        frm.show()
        app.start()


Note that we must manually do things that are normally done at the application 
or 
form level.

Paul
_______________________________________________
Post Messages to: [email protected]
Subscription Maintenance: http://leafe.com/mailman/listinfo/dabo-users
Searchable Archives: http://leafe.com/archives/search/dabo-users
This message: http://leafe.com/archives/byMID/[email protected]

Reply via email to