[EMAIL PROTECTED] wrote:
Paul- many thanks for your code- it's gives me a clear idea of how to over-ride
the edit pages. I assume I can do something similar for the search page,
I'm going to add the ability to easily override the select page. Hopefully this
week.
and
that joining tables is just a matter of over-riding the sql code (however- how
would I display such results- as they couldn't be edited?).
There are a couple major ways to join tables, and it depends on whether you want
a parent/child relationship or if you just want simple lookups. You can
mix/match this to whatever you want to accomplish. For the simple lookups, just
mangle the bizobj's setBaseSQL() method. For instance, in one of my apps I have
a payments table that records client payments. It has a foreign key to the
clients table and I want to show, in the browse screen and in the edit screen,
the code and name of the client, and not the clientid. Here's the bizobj (feel
free to use this as boilerplate, it is working code):
import datetime
import decimal
from Base import Base
class Payments(Base):
def initProperties(self):
self.Caption = "Payments"
self.DataSource = "payments"
self.KeyField = "iid"
self.RequeryOnLoad = False
self.DefaultValues = {"dcheckdate": datetime.date.today()}
def afterInit(self):
self.setBaseSQL()
self.NonUpdateFields = ["cclientcode", "cclientcompany"]
def setBaseSQL(self):
self.setFromClause("""payments
inner join clients
on clients.iid = payments.iclientid""")
self.setLimitClause("500")
self.addField("payments.iid as iid")
self.addField("payments.iclientid as iclientid")
self.addField("payments.cchecknum as cchecknum")
self.addField("payments.dcheckdate as dcheckdate")
self.addField("payments.ncheckamt as ncheckamt")
self.addField("payments.mnotes as mnotes")
self.addField("payments.tcreated as tcreated")
self.addField("payments.ldeleted as ldeleted")
self.addField("clients.ccode as cclientcode")
self.addField("clients.ccompany as cclientcompany")
def getBaseWhereClause(self):
return "payments.ldeleted=0"
Okay, now the client.ccode and client.ccompany lookup values are part of the
bizobj, how to display in the browse? Just add the specs to the appropriate
place in the the fsxml file:
<field name="cclientcode" type="char" caption="Client Code"
searchInclude="1" searchOrder="15" wordSearch="0"
listInclude="1" listColWidth="-1" listOrder="15"
editInclude="0" editReadOnly="0" editOrder="15" />
<field name="cclientcompany" type="char" caption="Client Company"
searchInclude="1" searchOrder="16" wordSearch="0"
listInclude="0" listColWidth="-1" listOrder="16"
editInclude="0" editReadOnly="0" editOrder="16" />
I've used AppWizardX and I can see much more clearly how every thing fits
together.
Great. I plan to add more comments to the generated code, but I think the
structure really makes more sense.
However, the following error occurs (both using your MySQL database for the
Orders table, and your Firebird database for the Customers table):
The problem is that our default encoding in Dabo is utf8, but the encoding on
those test tables is latin-1. Just explicitly set the encoding in the bizobj:
def initProperties(self):
...
self.Encoding = "latin-1"
--
Paul McNett
http://paulmcnett.com
http://dabodev.com
_______________________________________________
Post Messages to: [email protected]
Subscription Maintenance: http://leafe.com/mailman/listinfo/dabo-users