Data Bound Grid

Hi everyone,

I'm about to embark on building a databound grid for my current project.
I've been told that it might be something others here are interested in. As usual, I don't want to "reinvent the wheel". I searched for something similar, but found nothing. If any of you know if something similar, please let me know.

Here's my current (basic) use case:

Build a grid based wxPython control that is able to display, modify and delete existing database records and insert new records. Each row in the grid represents a database record. The control has navigation buttons for selecting the first, previous, next and last record in the recordset as well as a button for creating a new record. Updates to the database occur when a record has changed and when the user selects a record other than the modified record. Records can be deleted by selecting the entire row and pressing the del key on the keyboard.

The data is bound to the control by supplying a python object encapsulating a DBAPI 2.0 Connection object. I plan on using a python package called ORM[1] to create these python objects.

Among others, the control class interface would include methods to set the field (column) labels and their display order

Essentially, I'd like to be able to do something like:
     # Get a data set from an ORM datasource and ORM table
     contacts = datasource.select(tables.contacts).fetchall()
     # Add a data bound grid control
     MyDbGrid(parent=self, data=contacts)

... and have the grid displayed and functional.

If any of you have input, I'd like to hear it.

Thanks,

Eric.

[1] http://www.tux4web.de/orm/
"""The Object Relational Membrane is a Python package that provides the functionality of an object relational layer like EJB or other persistence storage systems. It is a thin compatibility layer between SQL table layouts and Object Oriented Python. While providing a good deal of functionality, it tries to be as small and simple as possible."""

Hmm, if you're using an Object-relational adapter, you could probably use wxprop, which has collection-of-object views. It is used for "data-bound" controls in ConflictSolver (the project it was initially created for), though there a true OODB (ZODB4) is used. You'd likely have to write an adapter from ORM's object-description-method to wxprop's (ConflictSolver just adds ZODB's Persistence mechanisms to wxprop's classes).

I should be getting back to wxprop development some time soon (am still working on PyOpenGL just now), BTW.

Good luck,
Mike

Eric Walstad wrote:

···

Hi everyone,

I'm about to embark on building a databound grid for my current project.
I've been told that it might be something others here are interested in. As usual, I don't want to "reinvent the wheel". I searched for something similar, but found nothing. If any of you know if something similar, please let me know.

Here's my current (basic) use case:

Build a grid based wxPython control that is able to display, modify and delete existing database records and insert new records. Each row in the grid represents a database record. The control has navigation buttons for selecting the first, previous, next and last record in the recordset as well as a button for creating a new record. Updates to the database occur when a record has changed and when the user selects a record other than the modified record. Records can be deleted by selecting the entire row and pressing the del key on the keyboard.

The data is bound to the control by supplying a python object encapsulating a DBAPI 2.0 Connection object. I plan on using a python package called ORM[1] to create these python objects.

Among others, the control class interface would include methods to set the field (column) labels and their display order

Essentially, I'd like to be able to do something like:
    # Get a data set from an ORM datasource and ORM table
    contacts = datasource.select(tables.contacts).fetchall()
    # Add a data bound grid control
    MyDbGrid(parent=self, data=contacts)

... and have the grid displayed and functional.

If any of you have input, I'd like to hear it.

Thanks,

Eric.

[1] http://www.tux4web.de/orm/
"""The Object Relational Membrane is a Python package that provides the functionality of an object relational layer like EJB or other persistence storage systems. It is a thin compatibility layer between SQL table layouts and Object Oriented Python. While providing a good deal of functionality, it tries to be as small and simple as possible."""

---------------------------------------------------------------------
To unsubscribe, e-mail: wxPython-users-unsubscribe@lists.wxwindows.org
For additional commands, e-mail: wxPython-users-help@lists.wxwindows.org

--
_______________________________________
  Mike C. Fletcher
  Designer, VR Plumber, Coder
  http://members.rogers.com/mcfletch/

I am running an IDE tool BoaConstructor, I guess you all know about it.

After I installed wxPython 2.4.0.2, Boa will crash complaining about string name:

File "/home/marius/boa/boa_0.1.5/boa/Models/Controllers.py", line 273, in identifyFilename
    lext = string.lower(ext)
NameError: global name 'string' is not defined

I figured out that importing string module in wxPython/utils.py is solving the problem.

Anyway in the previous version of wxPython string module was imported in utils.py, as well as in other modules that doesn't import it no more in version 2.4.0.2.

Is it wrong?

Thanks,

Marius

Do I understand correctly that Controllers.py, which is
part of Boa, relies on "from <some wxPython thing> import *"
do put the string module in its namespace?

Hm... Another example of why "from X import *" is unhealthy.

Surely it's bad practice to rely on a third party library to
import a standard library module for you. I assume this is a
mistake by a Boa developer. They wrote string.lower(ext) and
forgot to add "import string" in the beginning of the file. It
worked anyway (by accident) since it was imported by someone
else.

Unless I completely misunderstood what this was about, the
reasonable solution is to add "import string" to the beginning
of Controllers.py, or even better, unless support for python
1.5.2 or older is needed, to change it to ext.lower().

···

At 10:34 2003-01-24 -0500, Marius Trestioreanu wrote:

After I installed wxPython 2.4.0.2, Boa will crash complaining about string name:

File "/home/marius/boa/boa_0.1.5/boa/Models/Controllers.py", line 273, in identifyFilename
   lext = string.lower(ext)
NameError: global name 'string' is not defined

--
Magnus Lycka, Thinkware AB
Alvans vag 99, SE-907 50 UMEA, SWEDEN
phone: int+46 70 582 80 65, fax: int+46 70 612 80 65
http://www.thinkware.se/ mailto:magnus@thinkware.se

Thanks Magnus. This does make sense. I forwarded your reply to Boa developer.

Cheers,

Marius

···

Argh, I have to take responsibility here. Over the last few weeks, I
converted the string module functions to string methods in wxPython. As a
consequence, any code that relied on wxPython having already imported string
is going to break. I missed one string.atoi() in PySketch, but pretty much
every other string reference left in the libs, demos, etc. is because of a
reference like string.digits or the use of the string functions in a map()
call.

As Magnus points out, the problem you are experiencing is really a bug in
the Boa code. I'm sorry I didn't catch this earlier, especially since I was
doing some Boa testing for Riaan, but 2.4.0.2 is the first binary build with
my changes.

I don't think you have any choice but to go back to wxPython 2.4.0.1 for now
unless you want to manually fix all the modules in Boa that rely on the
string module, but don't import it themselves. Boa 0.2 in cvs has the same
problems. I had to add 'import string' to the following modules just to get
it to startup and shutdown correctly.

boa\About.py
boa\PropEdit\PropertyEditors.py
boa\Views\StyledTextCtrls.py
boa\Models\Controllers.py

To do any real work, I suspect there are quite a few more modules that need
to be fixed.

Converting the string module references is just the first part of trying to
make the wxPython code adhere to the recommendations in PEP 290

http://www.python.org/peps/pep-0290.html

If Robin okays further patches, then the recommended changes for "Python 2.1
or Later" and all the content below that will be fixed in the sources. When
wxPython moves to Python 2.2 as a minimum, which certainly won't happen
until at least Python 2.3 final comes out, I plan to incorporate the "Python
2.2 or Later" recommendations too.

ka

···

-----Original Message-----
From: Magnus Lycka [mailto:magnus@thinkware.se]
Sent: Friday, January 24, 2003 2:38 AM
To: wxPython-users@lists.wxwindows.org
Subject: Re: [wxPython-users] import string

At 10:34 2003-01-24 -0500, Marius Trestioreanu wrote:
>After I installed wxPython 2.4.0.2, Boa will crash complaining about
>string name:
>
>File "/home/marius/boa/boa_0.1.5/boa/Models/Controllers.py",
line 273, in
>identifyFilename
> lext = string.lower(ext)
>NameError: global name 'string' is not defined

Do I understand correctly that Controllers.py, which is
part of Boa, relies on "from <some wxPython thing> import *"
do put the string module in its namespace?

Hm... Another example of why "from X import *" is unhealthy.

Surely it's bad practice to rely on a third party library to
import a standard library module for you. I assume this is a
mistake by a Boa developer. They wrote string.lower(ext) and
forgot to add "import string" in the beginning of the file. It
worked anyway (by accident) since it was imported by someone
else.

Unless I completely misunderstood what this was about, the
reasonable solution is to add "import string" to the beginning
of Controllers.py, or even better, unless support for python
1.5.2 or older is needed, to change it to ext.lower().

--
Magnus Lycka, Thinkware AB
Alvans vag 99, SE-907 50 UMEA, SWEDEN
phone: int+46 70 582 80 65, fax: int+46 70 612 80 65
http://www.thinkware.se/ mailto:magnus@thinkware.se

---------------------------------------------------------------------
To unsubscribe, e-mail: wxPython-users-unsubscribe@lists.wxwindows.org
For additional commands, e-mail: wxPython-users-help@lists.wxwindows.org

Hi Eric,

I have the same need in order to fast implement a CRUD interface to an existing data Base.
I mouved recently to SQLAlchemy in order to have an ORM approche.

Now I wonder which widget to use, methode or third part with wxPython.

Did you found out something usefull for those kind of application?

EDIT: I badly read the date of the poste. Thaught '03 was the day, not the year!

Does any frensh thinks to make easily use of ORM object to make a simple CRUD application?