The bulk of my application is hand coded, and I'm planing to use cdxml dForm
(instantiated as Modal) to edit simple records.
I'm experimenting with such a form, but ran into a PyDeadObjectError
exception that I can figure out how to avoid. his exception is significant
since I can no longer reinstantiate the same form!
Here's my traceback:
Traceback (most recent call last):
File
"/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/dabo/ui/uiwx/dControlMixin.py",
line 27, in _onWxHit
self.raiseEvent(dEvents.Hit, evt, *args, **kwargs)
File
"/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/dabo/ui/uiwx/dPemMixin.py",
line 949, in raiseEvent
super(dPemMixin, self).raiseEvent(eventClass, nativeEvent, *args,
**kwargs)
File
"/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/dabo/lib/eventMixin.py",
line 93, in raiseEvent
bindingFunction(event)
File
"/Users/miguelek/Documents/programming/daboprgs/HandCoding_02/ui/appModules/AccountPages.py",
line 160, in onEdit
frm.showForm(contactsForAccount, 'EditRec') #, parentPK, childPK
File "/var/folders/XN/XNKKbB+9EVeY1y0rXolJBE+++TI/-Tmp-/tmpLfCKRL.py",
line 247, in showForm
self.show()
File
"/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/dabo/ui/uiwx/dPemMixin.py",
line 1282, in show
self.Visible = True
File
"/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/dabo/ui/uiwx/dForm.py",
line 964, in _setVisible
self._hackToFrame()
File
"//usr/local/lib/wxPython-unicode-2.8.9.2/lib/python2.5/site-packages/wx-2.8-mac-unicode/wx/_core.py",
line 14524, in __getattr__
raise PyDeadObjectError(self.attrStr % self._name)
wx._core.PyDeadObjectError: The C++ part of the dForm_43298 object has been
deleted, attribute access no longer allowed.
The "form" (dialog) class is created from the cdxml file in the normal way.
Since I pass a bizobj to the dialog with the record to edit, I have my own
method to show the form:
# This method lives in the dialog
def showForm(self, contactsBizobj, usage):
# set the forms Bizobj - this makes the form reusable for different
origins
# of contacts (e.g. Children of account, children of opportunity, ...)
self.VCRactive = True
self.addBizobj(contactsBizobj)
self.requery()
if usage == 'NewRec':
self.new()
self.show()
#to close the form I just use close:
## *!* ## Dabo Code ID: dButton-dPanel-956
def onHit(self, evt):
self.Form.close()
I suppose this is either a wxPython or a Dabo bug, since I'm not doing
anything special here.
Platform: Mac
Python Version: 2.5.4 on darwin
Dabo Version: Version 0.9.2; Revision 5254M
UI Version: 2.8.9.2 on wxMac
Best Miguel
--- StripMime Report -- processed MIME parts ---
multipart/alternative
text/plain (text body -- kept)
text/html
---
On Jul 7, 2009, at 6:22 AM, Miguel Lopes wrote:
> The bulk of my application is hand coded, and I'm planing to use
> cdxml dForm
> (instantiated as Modal) to edit simple records.
>
> I'm experimenting with such a form, but ran into a PyDeadObjectError
> exception that I can figure out how to avoid. his exception is
> significant
> since I can no longer reinstantiate the same form!
I've never been able to run a dForm as a modal dialog. The error is
occurring in the code that attempts to make the form into a dialog
temporarily, and then turn it back into a form. I'll wait for Paul to
comment on this, since I don't have any experience with this. I am
pretty certain that this hack was never tested with .cdxml forms.
-- Ed Leafe
Ed Leafe wrote:
> I've never been able to run a dForm as a modal dialog. The error is
> occurring in the code that attempts to make the form into a dialog
> temporarily, and then turn it back into a form.
There are all kinds of subtle and not-so-subtle problems with this hack.
The problems all (I think) boil down to the fact that we are changing
things at the class-definition level (IOW some basic behavior for all
instantiated forms, not just this form).
That said, I do use this in my app and it seems to work just fine. I
wanted to be able to instantiate a datanav.Form modally so I could use
it as a "pick list". So, I have a customers form defined for modifying
customer records. Now I can re-use that form to choose a customer from,
say, the orders module by doing:
frmPickCust = app.ui.FrmCustomers(self, FormMode="picklist", Modal=True)
I've probably been doing this for 2 years now with an app in the field
without trouble (although I've suspected the hack sometimes and wasted
cycles on it only to find a different root cause of a bug).
Really, if you can avoid setting dForm.Modal (by just defining your form
as a dialog instead), please do.
> I'll wait for Paul to
> comment on this, since I don't have any experience with this. I am
> pretty certain that this hack was never tested with .cdxml forms.
No I didn't test with cdxml. One of the requirements is that the Modal
property setting be sent in the constructor, not in initProperties etc.
Perhaps that's the problem?
Paul
On Tue, Jul 7, 2009 at 4:20 PM, Paul McNett<p@ulmcnett.com> wrote:
> Ed Leafe wrote:
>> =A0 =A0 =A0 I've never been able to run a dForm as a modal dialog. The e=
rror is
>> occurring in the code that attempts to make the form into a dialog
>> temporarily, and then turn it back into a form.
...
> That said, I do use this in my app and it seems to work just fine. I
> wanted to be able to instantiate a datanav.Form modally so I could use
> it as a "pick list". So, I have a customers form defined for modifying
> customer records. Now I can re-use that form to choose a customer from,
> say, the orders module by doing:
>
> frmPickCust =3D app.ui.FrmCustomers(self, FormMode=3D"picklist", Modal=3D=
True)
>
> I've probably been doing this for 2 years now with an app in the field
> without trouble (although I've suspected the hack sometimes and wasted
> cycles on it only to find a different root cause of a bug).
>
> Really, if you can avoid setting dForm.Modal (by just defining your form
> as a dialog instead), please do.
My problem is that dialogs are not bizobj aware, which limits usage;
for example, it is not possible to a complex picklist like those
moving elements from one list to the other, or allowing for editing
and creation without closing and re-opening the form (well at least
not without much work).
>> I'll wait for Paul to
>> comment on this, since I don't have any experience with this. I am
>> pretty certain that this hack was never tested with .cdxml forms.
>
> No I didn't test with cdxml. One of the requirements is that the Modal
> property setting be sent in the constructor, not in initProperties etc.
> Perhaps that's the problem?
I suppose I'm setting the Modal attribute at instantiation, since the
previous step should only create the class definition. Here's my
method:
# self is MainForm
def onNew(self, evt):
EditContactDlg =3D dui.createClass('EditContact.cdxml')
frm =3D EditContactDlg(self.Form, Modal=3DTrue)
contactsForAccount =3D self.Form.getBizobj("contact")
frm.showForm(contactsForAccount, 'NewRec')
Anyway, I'll try and code the dialog by hand.
Do you suggest another way of having a modal dialog that is bizobj aware?
Or the alternative is always fetching the record values from another
form (including next record if we want to allow multiple edits without
closing)?
Txs for the help,
Miguel
(revisited thread from July 7):
http://leafe.com/archives/showFullThd/422649
Miguel Lopes wrote:
> The bulk of my application is hand coded, and I'm planing to use cdxml dForm
> (instantiated as Modal) to edit simple records.
>
> I'm experimenting with such a form, but ran into a PyDeadObjectError
> exception that I can figure out how to avoid. his exception is significant
> since I can no longer reinstantiate the same form!
>
> Here's my traceback:
>
> Traceback (most recent call last):
> File
> "/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/dabo/ui/uiwx/dControlMixin.py",
> line 27, in _onWxHit
> self.raiseEvent(dEvents.Hit, evt, *args, **kwargs)
> File
> "/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/dabo/ui/uiwx/dPemMixin.py",
> line 949, in raiseEvent
> super(dPemMixin, self).raiseEvent(eventClass, nativeEvent, *args,
> **kwargs)
> File
> "/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/dabo/lib/eventMixin.py",
> line 93, in raiseEvent
> bindingFunction(event)
> File
> "/Users/miguelek/Documents/programming/daboprgs/HandCoding_02/ui/appModules/AccountPages.py",
> line 160, in onEdit
> frm.showForm(contactsForAccount, 'EditRec') #, parentPK, childPK
> File "/var/folders/XN/XNKKbB+9EVeY1y0rXolJBE+++TI/-Tmp-/tmpLfCKRL.py",
> line 247, in showForm
> self.show()
> File
> "/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/dabo/ui/uiwx/dPemMixin.py",
> line 1282, in show
> self.Visible = True
> File
> "/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/dabo/ui/uiwx/dForm.py",
> line 964, in _setVisible
> self._hackToFrame()
> File
> "//usr/local/lib/wxPython-unicode-2.8.9.2/lib/python2.5/site-packages/wx-2.8-mac-unicode/wx/_core.py",
> line 14524, in __getattr__
> raise PyDeadObjectError(self.attrStr % self._name)
> wx._core.PyDeadObjectError: The C++ part of the dForm_43298 object has been
> deleted, attribute access no longer allowed.
>
> The "form" (dialog) class is created from the cdxml file in the normal way.
> Since I pass a bizobj to the dialog with the record to edit, I have my own
> method to show the form:
>
> # This method lives in the dialog
> def showForm(self, contactsBizobj, usage):
>
> # set the forms Bizobj - this makes the form reusable for different
> origins
> # of contacts (e.g. Children of account, children of opportunity, ...)
> self.VCRactive = True
>
> self.addBizobj(contactsBizobj)
> self.requery()
>
> if usage == 'NewRec':
>
> self.new()
>
> self.show()
>
> #to close the form I just use close:
> ## *!* ## Dabo Code ID: dButton-dPanel-956
> def onHit(self, evt):
> self.Form.close()
>
> I suppose this is either a wxPython or a Dabo bug, since I'm not doing
> anything special here.
>
> Platform: Mac
> Python Version: 2.5.4 on darwin
> Dabo Version: Version 0.9.2; Revision 5254M
> UI Version: 2.8.9.2 on wxMac
Does this patch fix it?
{{{
Index: dabo/ui/uiwx/dForm.py
===================================================================
--- dabo/ui/uiwx/dForm.py (revision 5305)
+++ dabo/ui/uiwx/dForm.py (working copy)
@@ -924,30 +924,30 @@
# This is a normal SDI form:
preClass = wx.PreFrame
self._mdi = False
- self._hackToFrame()
+ dForm._hackToFrame()
## (Note that it is necessary to run the above blocks each time, because
## we are modifying the dForm class definition globally.)
BaseForm.__init__(self, preClass, parent, properties, attProperties,
*args, **kwargs)
- self._hackToFrame()
+ dForm._hackToFrame()
def _hackToDialog(self):
dForm.__bases__ = (BaseForm, wx.Dialog)
- def _hackToFrame(self):
- if self._mdi:
+ def _hackToFrame(cls):
+ if dabo.settings.MDI:
dForm.__bases__ = (BaseForm, wx.MDIChildFrame)
else:
dForm.__bases__ = (BaseForm, wx.Frame)
+ _hackToFrame = classmethod(_hackToFrame)
-
def Show(self, show=True, *args, **kwargs):
self._gtk_show_fix(show)
if self.Modal:
self._hackToDialog()
dForm.__bases__[-1].Show(self, show, *args, **kwargs)
- self._hackToFrame()
+ dForm._hackToFrame()
def _getModal(self):
return getattr(self, "_modal", False)
@@ -961,7 +961,7 @@
if val and self.Modal:
self._hackToDialog()
self.ShowModal()
- self._hackToFrame()
+ dForm._hackToFrame()
else:
self.Show(val)
else:
}}}
Paul
On Mon, Aug 3, 2009 at 6:02 PM, Paul McNett<p@ulmcnett.com> wrote:
>
> Does this patch fix it?
>
> {{{
> Index: dabo/ui/uiwx/dForm.py
> =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
> --- dabo/ui/uiwx/dForm.py =A0 =A0 =A0 (revision 5305)
> +++ dabo/ui/uiwx/dForm.py =A0 =A0 =A0 (working copy)
> @@ -924,30 +924,30 @@
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0# This is =
a normal SDI form:
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0preClass =
=3D wx.PreFrame
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0self._mdi =
=3D False
> - =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 self._hackToFrame()
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 dForm._hackToFrame()
>
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0## (Note that it is necessary to run the a=
bove blocks each time, because
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0## =A0we are modifying the dForm class def=
inition globally.)
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0BaseForm.__init__(self, preClass, parent, =
properties, attProperties,
> *args, **kwargs)
> - =A0 =A0 =A0 =A0 =A0 =A0 =A0 self._hackToFrame()
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 dForm._hackToFrame()
>
>
> =A0 =A0 =A0 =A0def _hackToDialog(self):
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0dForm.__bases__ =3D (BaseForm, wx.Dialog)
>
> - =A0 =A0 =A0 def _hackToFrame(self):
> - =A0 =A0 =A0 =A0 =A0 =A0 =A0 if self._mdi:
> + =A0 =A0 =A0 def _hackToFrame(cls):
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 if dabo.settings.MDI:
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0dForm.__bases__ =3D (BaseF=
orm, wx.MDIChildFrame)
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0else:
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0dForm.__bases__ =3D (BaseF=
orm, wx.Frame)
> + =A0 =A0 =A0 _hackToFrame =3D classmethod(_hackToFrame)
>
> -
> =A0 =A0 =A0 =A0def Show(self, show=3DTrue, *args, **kwargs):
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0self._gtk_show_fix(show)
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0if self.Modal:
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0self._hackToDialog()
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0dForm.__bases__[-1].Show(self, show, *args=
, **kwargs)
> - =A0 =A0 =A0 =A0 =A0 =A0 =A0 self._hackToFrame()
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 dForm._hackToFrame()
>
> =A0 =A0 =A0 =A0def _getModal(self):
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0return getattr(self, "_modal", False)
> @@ -961,7 +961,7 @@
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0if val and self.Modal:
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0self._hack=
ToDialog()
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0self.ShowM=
odal()
> - =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 self._hackT=
oFrame()
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 dForm._hack=
ToFrame()
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0else:
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0self.Show(=
val)
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0else:
>
> }}}
>
>
> Paul
Working greate on both:
Python Version: 2.5.4 on darwin
Dabo Version: Version 0.9.2; Revision 5328M + Your Patch to dForm
UI Version: 2.8.9.2 on wxMac
And:
PythonVersion: 2.6.2 on win32
Dabo Version: Version 0.9.2; Revision ~5308 + Your Patch to dForm
UI Version: 2.8.10.1 on wxMSW
txs,
Miguel
Miguel Lopes wrote:
> On Mon, Aug 3, 2009 at 6:02 PM, Paul McNett<p@ulmcnett.com> wrote:
>> Does this patch fix it?
>>
>> {{{
>> Index: dabo/ui/uiwx/dForm.py
> Working greate on both:
> Python Version: 2.5.4 on darwin
> Dabo Version: Version 0.9.2; Revision 5328M + Your Patch to dForm
> UI Version: 2.8.9.2 on wxMac
>
> And:
> PythonVersion: 2.6.2 on win32
> Dabo Version: Version 0.9.2; Revision ~5308 + Your Patch to dForm
> UI Version: 2.8.10.1 on wxMSW
Thanks for testing. Seems to work here, too. Committed in r5329. I actually did a bit
more in the commit so if you see any trouble let me know!
Paul