On 05/02/2013 08:46 PM, Paul McNett wrote:
On 5/2/13 9:09 AM, John Fabiani wrote:
Man is this getting weird!  I removed "biz.new()" from the code and all works!  
I
still needed the blank record so I created one with an insert.  I'm not sure 
why I
used 'biz'.   What was wrong with 'self.biz'????  There must have been a reason 
but I
don't see it now.
I'm having a little bit of trouble following this thread. Can you please write a
small case using SQLite and one .py file, and then show me what version of Dabo
changed this or that behavior?

Paul


Let me give you a review (but I don't want you do anything).
I have been converting from 0.9.5 to 0.9.9 (I expect to move to 0.9.10).
At the same time I'm upgrading the database engine from 8.4 to 9.1.x (postgres) The new 9.1.x has built-in replication. I have three versions of Postgres available for testing.
1.  one instance of 8.4
2.  one instance of 9.1.4
3.  9.1.9 setup to replicate using a hot-standby (two computers).

I've done a lot of testing on the 1 and 2 (from above) without any issues. I see warnings but no errors (I'm fixing the warnings). But when I started testing on the hot-standby setup (number 3) I got tracebacks.

The first error I had to deal with was from a bizobj class I created that used a function for a field.

i.e.  self.addField("extract(year from age(born)) as studentage")

Dabo attempted to update the field "studentage" and postgres complained that the field did not exist in the relation.

I fixed that by just adding the field name to the NonUpdateField list.


The next issue was very different and I still do not understand the issue. I create a temporary table and then attempt to add a blank record and I get a strange traceback where postgres is reporting the relation (table) does not exist. Postgres creates temp tables in a special schema area and can only be accessed from the session that created the temp table. So my guess was the Postgres did not see the session as being the same when I tried to create the blank record. What I think is strange is I'm able to use the code without issue with 1 and 2 (from above). But it does not work with 3 (from above).


To get around the traceback I decided to add the record in a different manner (using an insert) and it worked. And where I'm using the temp table in other areas of the code is working.

 Below you can review the code.

    def createTempStudentTable(self, conn):
        create_StudenttableStr = """CREATE temporary TABLE tempstudent
(
  pkid integer,
  referral date ,
  enrolled date,
  fname character varying(25),
  lname character varying(50),
  address character varying(60),
  address2 character varying(60),
  city character varying(120),
  state_1 character varying(2) ,
  zip character varying(10),
  fk_county integer DEFAULT 0,
  homephone character varying(16) DEFAULT '(   )    - '::character varying,
  cell character varying(20) DEFAULT '(   )    -    '::character varying,
  accept_text boolean DEFAULT false,
  fk_cell_carrier integer DEFAULT 0,
  email character varying(80),
  dvrslic character varying(20),
  dvrslicst character varying(2) DEFAULT 'CA'::character varying,
  born date,
  ssn character varying(11),
  ethnic_grpid integer DEFAULT 0,
  languageid integer,
  gender character varying(10) DEFAULT 'Male' ::character varying,
  longitude character varying(40),
  latitude character varying(40),
  caseno character varying(13),
  ref_no character varying(60),
  ref2_no text,
  ret_to_court date,
  mustenrollby date,
  incident_date date,
  fk_escourse integer,
  fk_escourts integer,
  fk_pccode integer DEFAULT 0,
  community_tobedeter boolean DEFAULT true,
  restitution_tobedeter boolean DEFAULT true,
  community_service integer DEFAULT 0,
  victim_name character varying(120),
  victim_address character varying(100),
  victim_address2 character varying(100),
  victim_city character varying(80),
  victim_zip character varying(15),
  victim_state_1 character varying(2) DEFAULT 'CA'::character varying,
  victim_phone character varying(25),
  enroll_comments text,
  victim_comments text,
  community_comments text,
  course_pay_sched text

)"""

        biz = self.biz = dabo.biz.dBizobj(conn)
        biz.execute(create_StudenttableStr)
        #insert blank record into the student
        insert_str = """ insert into tempstudent (pkid) values (1) """
        biz.execute(insert_str)
        biz.execute('commit')
        biz.DataSource = 'tempstudent'
        biz.KeyField = "pkid"
        #biz.VirtualFields =
biz.DefaultValues={"referral":None,'enrolled':None,'born':None,'ret_to_court':None,'mustenrollby':None,'incident_date':None, 'gender':'Male','state_1':'na','victim_state_1':'CA','dvrslicst': 'CA' }

        #biz.new()
        self.recordstate = None

        return self.biz



_______________________________________________
Post Messages to: [email protected]
Subscription Maintenance: http://mail.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