gnumed-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Gnumed-devel] re: create_identity


From: syan tan
Subject: [Gnumed-devel] re: create_identity
Date: Thu, 20 Nov 2003 12:17:01 +1100
User-agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.3) Gecko/20030313

I checked out gmPG. Doing the change below works to return the identity's id. But then when the patient_selected signal is sent, I get a list error which occurs
in gmDemographicRecord.getActiveNames().  This is understandable because
only the identity is created , but no names are. That was another reason why just inserting into v_basic_person worked, as it has triggers for patient name creation : the only problem was that you had to supply "dummy" names, which I used question -marks .


def run_commit (service, queries):
       """Convenience function for running a transaction
          that is supposed to get committed.

       The point is to handle errors so the calling code can
       avoid the highly repetitive try..except bureaucracy.

       Takes a list of (query, [args]) to execute as a single transaction
       """
       dbp = ConnectionPool ()
       con = dbp.GetConnection (service, readonly = 0)
       cur = con.cursor ()
       for query, args in queries:
               try:
                       cur.execute (query, *args)
               except:
                       cur.close()
                       con.close()
_log.LogException ("RW query >>>%s<<< with args >>>%s<<< failed" % (query, args), sys.exc_inf
o(), verbose = _query_logging_verbosity)
                       return None

# MADE A CHANGE HERE
       try:
               result = cur.fetchall()
       except:
               result = 0
#---------
       cur.close()
       con.commit()
       # FIXME:
# this is very wasteful, why can't we save this read-write connection # for the next time it's used (I understand it can't be shared at once)
       #> def run_commit():
       #>     conn = rw_conn_pool.get_cached()
       #>     if conn is None:
#> if rw_conn_pool.curr_size_per_service() > rw_conn_hard_limit_per_service:
       #>           _log('insufficient connections, getting temporary one')
       #>           conn = rw_conn_pool.establish_new(keep=false)
       #>       else:
       #>           _log('insufficient connections, increasing pool')
       #>           conn = rw_conn_pool.establish_new(keep=true)
       #>     ... error checking ...
       #>     do_stuff()
       #>     conn.commit()
       con.close()

# AND HERE
       return result

The error message is now:


no cleared value for <wxPython.controls.wxListBox instance; proxy of C++ wxListBox instance at _9874840_wxListBox_p>
[[8L]]
id =  8

[PANIC] (/home/sjtan/projects/gnumed/gnumed/client/business/gmPatient.py::__init__:216): cannot connect with patient [8] [PANIC] (/home/sjtan/projects/gnumed/gnumed/client/business/gmPatient.py::__init__:216): exception type : exceptions.IndexError [PANIC] (/home/sjtan/projects/gnumed/gnumed/client/business/gmPatient.py::__init__:216): exception value: list index out of range [PANIC] (/home/sjtan/projects/gnumed/gnumed/client/business/gmPatient.py::__init__:216): Traceback (most recent call last):<#10-0x0A-lf> [PANIC] (/home/sjtan/projects/gnumed/gnumed/client/business/gmPatient.py::__init__:216): File "/home/sjtan/projects/gnumed/gnumed/client/business/gmPatient.py", line 214, in __init__<#10-0x0A-lf> self.__send_selection_notification()<#10-0x0A-lf> [PANIC] (/home/sjtan/projects/gnumed/gnumed/client/business/gmPatient.py::__init__:216): File "/home/sjtan/projects/gnumed/gnumed/client/business/gmPatient.py", line 269, in __send_selection_notification<#10-0x0A-lf> gmDispatcher.send(gmSignals.patient_selected(), kwds=kwargs)<#10-0x0A-lf> [PANIC] (/home/sjtan/projects/gnumed/gnumed/client/business/gmPatient.py::__init__:216): File "/home/sjtan/projects/gnumed/gnumed/client/python-common/gmDispatcher.py", line 137, in send<#10-0x0A-lf> response = _call(receiver, signal=signal, sender=sender, **kwds)<#10-0x0A-lf> [PANIC] (/home/sjtan/projects/gnumed/gnumed/client/business/gmPatient.py::__init__:216): File "/home/sjtan/projects/gnumed/gnumed/client/python-common/gmDispatcher.py", line 161, in _call<#10-0x0A-lf> return receiver(**kwds)<#10-0x0A-lf> [PANIC] (/home/sjtan/projects/gnumed/gnumed/client/business/gmPatient.py::__init__:216): File "gmPatientSelector.py", line 671, in _on_patient_selected<#10-0x0A-lf> self._display_name()<#10-0x0A-lf> [PANIC] (/home/sjtan/projects/gnumed/gnumed/client/business/gmPatient.py::__init__:216): File "gmPatientSelector.py", line 737, in _display_name<#10-0x0A-lf> name = self.curr_pat['demographic record'].getActiveName()<#10-0x0A-lf> [PANIC] (/home/sjtan/projects/gnumed/gnumed/client/business/gmPatient.py::__init__:216): File "/home/sjtan/projects/gnumed/gnumed/client/business/gmDemographicRecord.py", line 153, in getActiveName<#10-0x0A-lf> result = {<#10-0x0A-lf> [PANIC] (/home/sjtan/projects/gnumed/gnumed/client/business/gmPatient.py::__init__:216): IndexError: list index out of range<#10-0x0A-lf>



Looking in gmDemographicRecord.getActiveName, we find the list which has an index error is data ? ( len of data is zero?) :


def getActiveName(self): cmd = "select firstnames, lastnames from v_basic_person where i_id = %s"
               data, idx = gmPG.run_ro_query('personalia', cmd, 1, self.ID)
               if data is None:
                       return None
# this line 153
               result = {
                       'first': data[0][idx['firstnames']],
                       'last': data[0][idx['lastnames']]
               }
               return result










reply via email to

[Prev in Thread] Current Thread [Next in Thread]