creating new objects with references to them

Ant antroy at gmail.com
Thu Nov 2 10:52:40 EST 2006



On Nov 2, 3:15 pm, "JohnJSal" <johnj... at gmail.com> wrote:
> It seems like what I want to do is something that programmers deal with
> everyday, but I just can't think of a way to do it. Basically, I am
> writing a DB front-end and I want a new "Researcher" object to be
> created whenever the user presses the "New Record" button. He can open
> as many new records at a time as he wants and fill in the information.
>
> What I don't know how to do is handle this arbitrary number of objects.
> When it comes time to save the data to the DB, how do I access each
> object (to get the text fields associated with each)? Won't I have to
> have given each instance some name?

It all depends on what UI you are using (Web frontend? GUI such as
Tkinter?) and what your use case is.

What is it exactly that you want to do? Create a bunch of Researcher
objects and then save them in a single hit? Create a list of
Researchers and then choose which to save to the db? Populate a list of
researchers from the db, and have the option of editing or adding new
ones? Should the new Researcher objects be committed to the db as soon
as they are saved?

Anyway, a simple list of Researchers should suffice for any of these
purposes, and assuming you want to commit them all in one hit, you have
a list of objects ready to iterate over.




More information about the Python-list mailing list