Hi,
I finally got my first MVC program done that I mentioned I'd do in the "Simple Design" thread. Since that thread was getting so convoluted, I thought it would be better to just start a new thread. I've tested all the major stuff and it seems to work ok, but there's plenty of validation stuff that could be added and I'm sure it could be refactored too. However, while it may not be as elegant as Robin's or Andrea's code, I think it's a good start.
The code is longer than I wanted, but I guess that's to be expected since it actually does something! It is attached as a zip file.
Let me know what you think. I have tested it on Windows Vista and XP with wxPython 2.8.9.1 (unicode) and Python 2.5.2.
userInfo-mvc.zip (6.43 KB)
···
-------------------
Mike Driscoll
Blog: http:\\blog.pythonlibrary.org
Python Extension Building Network: http:\\www.pythonlibrary.org
Mike Driscoll wrote:
Hi,
I finally got my first MVC program done that I mentioned I'd do in the "Simple Design" thread. Since that thread was getting so convoluted, I thought it would be better to just start a new thread. I've tested all the major stuff and it seems to work ok, but there's plenty of validation stuff that could be added and I'm sure it could be refactored too. However, while it may not be as elegant as Robin's or Andrea's code, I think it's a good start.
The code is longer than I wanted, but I guess that's to be expected since it actually does something! It is attached as a zip file.
Let me know what you think. I have tested it on Windows Vista and XP with wxPython 2.8.9.1 (unicode) and Python 2.5.2.
-------------------
Mike Driscoll
Blog: http:\\blog.pythonlibrary.org
Python Extension Building Network: http:\\www.pythonlibrary.org
It occurred to me that I didn't really offer any instructions with my last email. You should unzip and run controller.py to get the program going. I didn't include any sample data, but it doesn't take long to add some. Just fill out the form and hit the Save button. Repeat until you have enough data. You can Edit anything you've added to the database by going to the "File" menu and choosing the "Edit Record" option.
I am using sqlite and sqlalchemy so you may need to download some extra stuff. Python 2.5 includes Sqlite, but I think it's a separate download for 2.4. I think that's all you'll need to know to get going.
Mike
Mike Driscoll escribió:
Mike Driscoll wrote:
Hi,
I finally got my first MVC program done that I mentioned I'd do in the "Simple Design" thread. Since that thread was getting so convoluted, I thought it would be better to just start a new thread. I've tested all the major stuff and it seems to work ok, but there's plenty of validation stuff that could be added and I'm sure it could be refactored too. However, while it may not be as elegant as Robin's or Andrea's code, I think it's a good start.
The code is longer than I wanted, but I guess that's to be expected since it actually does something! It is attached as a zip file.
Let me know what you think. I have tested it on Windows Vista and XP with wxPython 2.8.9.1 (unicode) and Python 2.5.2.
-------------------
Mike Driscoll
Blog: http:\\blog.pythonlibrary.org
Python Extension Building Network: http:\\www.pythonlibrary.org
It occurred to me that I didn't really offer any instructions with my last email. You should unzip and run controller.py to get the program going. I didn't include any sample data, but it doesn't take long to add some. Just fill out the form and hit the Save button. Repeat until you have enough data. You can Edit anything you've added to the database by going to the "File" menu and choosing the "Edit Record" option.
I am using sqlite and sqlalchemy so you may need to download some extra stuff. Python 2.5 includes Sqlite, but I think it's a separate download for 2.4. I think that's all you'll need to know to get going.
Mike
Hello Mike, I'm testing this example with Ubuntu 8.10, and it includes SQLAlchemy 0.4.6 (instead of 0.5.0), so to get it working you only have to comment this line and add this other one:
#import sqlalchemy.exc
import sqlalchemy.exceptions
The sqlalchemy.exceptions in 0.4.x module was renamed to sqlalchemy.exc in 0.5.
Despite this minor detail, it works ok.
Regards,
Marcelo
···
--
Marcelo F. Fernández
Buenos Aires, Argentina
Licenciado en Sistemas - CCNA
E-Mail: fernandezm22@yahoo.com.ar
Jabber ID: fernandezm22@jabber.org
Public Key ID: 5C990A6C 111C3661
Blog: http://marcelosoft.blogspot.com
Marcelo Fernández escribió:
Mike Driscoll escribió:
Mike Driscoll wrote:
Hi,
I finally got my first MVC program done that I mentioned I'd do in the "Simple Design" thread. Since that thread was getting so convoluted, I thought it would be better to just start a new thread. I've tested all the major stuff and it seems to work ok, but there's plenty of validation stuff that could be added and I'm sure it could be refactored too. However, while it may not be as elegant as Robin's or Andrea's code, I think it's a good start.
The code is longer than I wanted, but I guess that's to be expected since it actually does something! It is attached as a zip file.
Let me know what you think. I have tested it on Windows Vista and XP with wxPython 2.8.9.1 (unicode) and Python 2.5.2.
-------------------
Mike Driscoll
Blog: http:\\blog.pythonlibrary.org
Python Extension Building Network: http:\\www.pythonlibrary.org
It occurred to me that I didn't really offer any instructions with my last email. You should unzip and run controller.py to get the program going. I didn't include any sample data, but it doesn't take long to add some. Just fill out the form and hit the Save button. Repeat until you have enough data. You can Edit anything you've added to the database by going to the "File" menu and choosing the "Edit Record" option.
I am using sqlite and sqlalchemy so you may need to download some extra stuff. Python 2.5 includes Sqlite, but I think it's a separate download for 2.4. I think that's all you'll need to know to get going.
Mike
Hello Mike, I'm testing this example with Ubuntu 8.10, and it includes SQLAlchemy 0.4.6 (instead of 0.5.0), so to get it working you only have to comment this line and add this other one:
#import sqlalchemy.exc
import sqlalchemy.exceptions
The sqlalchemy.exceptions in 0.4.x module was renamed to sqlalchemy.exc in 0.5.
Despite this minor detail, it works ok.
Regards,
Marcelo
Sorry, I'll correct myself, that modification will not avoid the "can't find the sqlalchemy.exc module" error message. To (really) make it work I only modified this lines in controller.py:
#import sqlalchemy.exc
import sqlalchemy.exceptions
[... line 63 ...]
except sqlalchemy.exceptions.IntegrityError, e:
Regards,
Marcelo
···
--
Marcelo F. Fernández
Buenos Aires, Argentina
Licenciado en Sistemas - CCNA
E-Mail: fernandezm22@yahoo.com.ar
Jabber ID: fernandezm22@jabber.org
Public Key ID: 5C990A6C 111C3661
Blog: http://marcelosoft.blogspot.com
Marcelo Fernández wrote:
Marcelo Fernández escribió:
Mike Driscoll escribió:
Mike Driscoll wrote:
Hi,
I finally got my first MVC program done that I mentioned I'd do in the "Simple Design" thread. Since that thread was getting so convoluted, I thought it would be better to just start a new thread. I've tested all the major stuff and it seems to work ok, but there's plenty of validation stuff that could be added and I'm sure it could be refactored too. However, while it may not be as elegant as Robin's or Andrea's code, I think it's a good start.
The code is longer than I wanted, but I guess that's to be expected since it actually does something! It is attached as a zip file.
Let me know what you think. I have tested it on Windows Vista and XP with wxPython 2.8.9.1 (unicode) and Python 2.5.2.
-------------------
Mike Driscoll
Blog: http:\\blog.pythonlibrary.org
Python Extension Building Network: http:\\www.pythonlibrary.org
It occurred to me that I didn't really offer any instructions with my last email. You should unzip and run controller.py to get the program going. I didn't include any sample data, but it doesn't take long to add some. Just fill out the form and hit the Save button. Repeat until you have enough data. You can Edit anything you've added to the database by going to the "File" menu and choosing the "Edit Record" option.
I am using sqlite and sqlalchemy so you may need to download some extra stuff. Python 2.5 includes Sqlite, but I think it's a separate download for 2.4. I think that's all you'll need to know to get going.
Mike
Hello Mike, I'm testing this example with Ubuntu 8.10, and it includes SQLAlchemy 0.4.6 (instead of 0.5.0), so to get it working you only have to comment this line and add this other one:
#import sqlalchemy.exc
import sqlalchemy.exceptions
The sqlalchemy.exceptions in 0.4.x module was renamed to sqlalchemy.exc in 0.5.
Despite this minor detail, it works ok.
Regards,
Marcelo
Sorry, I'll correct myself, that modification will not avoid the "can't find the sqlalchemy.exc module" error message. To (really) make it work I only modified this lines in controller.py:
#import sqlalchemy.exc
import sqlalchemy.exceptions
[... line 63 ...]
except sqlalchemy.exceptions.IntegrityError, e:
Regards,
Marcelo
Oops...I didn't realize that Bayer had changed the exceptions code in SA like that. I knew there was some fairly heavy-duty stuff in the higher level calls, but obviously I'm not using them. Thanks for the bug report! I'll try to keep it in mind when I write my tutorial about this program...
Mike