On Thursday, June 30, 2011 06:41:20 am Ruffy Collado wrote:
> Hello, I have got a few questions and this may end up very long so sorry.
>
>
>
> I came from the Web Application development style using PHP, a few console
> programming in C but never had a full blown GUI Desktop application
> experience. I can now fairly see the difference in both development.
>
> I admire the work and elegance of Dabo, the style, the ideas are very well
> engineered. That's why even for a complete newbie in Python, let alone
> Desktop Applications, I chose this Framework.
>
>
>
> Enough with the admiration and on to the questions,
>
>
>
> 1. Example I have a password field connected to the datasource and
> datafield in a MySQL table. I also have another field which is a confirm
> password, this one is of course no connected to the datasource. On the
> OnHit method of a button, I called in the self.Form.save(). I did some
> validations on empty fields and it works just like in the tutorial. But I
> never got the way to compare if the two password fields match each other
> using the validateRecord() Method of the Bizobj. By the way, I was
> following the Create application from start tutorial using my own tables.
> So, how can I get the value of the confirm password textbox using the
> bizobj? Should I create another method to validate it, using the Form as
> the caller of a Bizobj method passing the two textboxes values as
> parameters? Or should I just use the self.Application.ui way?
>
>
>
> 2. In CodeIgniter a PHP MVC Web Framework, I use the Model to handle
> all the queries, I write my input and output queries in methods like
> add_new_user(data) and get_selected_members(data). Then this methods pass
> the result of the query or the dataset back to the Controller. That way
> when some SQL guy decides to change my queries for optimization, he can
> play with it while I do the business logic. Is there anyway to this in
> Dabo? I was thinking of using the db Folder as the storage for my Model
> Classes. Oh and I would also like to write my own SQL queries rather than
> the alchemy stuffs.
>
>
>
> 3. Lastly, for now. Let's say have a table which has a ID, Name,
> Address, Image and Status as fields. Of course I wouldn't show my ID but
> dabo already takes care of this. I would also not show my status field
> cause I update them according to events or user choices. How can I do that
> in the bizobjs? When I call self.Form.save() I won't be able to access it
> through the self.Record.Status cause it is not in the form. Should I use a
> query in the validateRecord to fetch the chosen user? Or could I still
> access the self.Record.Status without it being included in my Form?
>
>
>
> Sorry for the long questions. It may be the most pointless one in the whole
> mail list. I just wanted to clarify these things, it really gets confusing
> when coming from a web app background and a web MVC architecture.
>
>
>
> I use Windows Xp, Python 2.7, Dabo 0.9.3, wxPython 2.8.
When you need to retrieve a value from a control (such as a dTextBox) you can
use the "RegID" property. "RegID" is used as an identifier. So in the case of
your passwords you can check to see if the passwords match by:
self.Form.passwd1.Value == self.Form.passwd2.Value
where "passwd1" and "passwd2" are "RegID" properties of the controls.
Where you do the validation depends on you. You can validate in the bizobj,
or in one of the many hooks (beforeSave, Save), or maybe use an event trigger
(dEvents.LostFocus).
Dabo's "model" is the bizobj's. Somewhere in your code there is a definition
of your table in the form of a "Bizobj Class". The "Bizobj Class" contains
the name of the table, the names of fields, the name of the primary key, and
optional joins, order by, group by. You can even have virtual fields and
default values. But the bizobj class is not limited to just those things.
Almost anything that you can do in standard SQL can be done in the Bizobj
Class.
If you need to write an ad hoc SQL query Dabo's temporary cursor is the tool I
use.
tempCur = self.Form.PrimaryBizObj.getTempCursor()
tempCur.execute("Select * from someTable where pk = %s" %
(self.Form.RegID.Value))
Please review SQL injections before using the above,
The last question:
If the value you need is not on the form nor in a bizobj field then you will
need to retrieve it from some table. Use the temp cursor to retrieve it.
Better would be that you add the information in a bizobj or make it a value in
the form.
self.Form.User = someStrValue
Then use the "self.User" in the save routine.
Johnf
_______________________________________________
Post Messages to: [email protected]
Subscription Maintenance: http://leafe.com/mailman/listinfo/dabo-users
Searchable Archives: http://leafe.com/archives/search/dabo-users
This message:
http://leafe.com/archives/byMID/[email protected]