Fog Creek Software
Discussion Board




Where to start?

I will be writing an application in python using mod_python for the delivery against an Oracle database. This part I am comfortable with. I would however like to extend parts of the application with Windows applications. The first will be an check dispersment application that will also tie the financial parts back into QuickBooks Pro. I am looking to develop these components in wxPython.

From the QuickBooks manuals for their API:
"This API requires that you construct the qbXML messages separately, using a method of your choice, and then supply the messages as a text stream to the COM method (ProcessRequest) contained in this library."

Now I have never done any Windows programming before. The XML part I understand, the COM part is a mystery to me. Where do I start in understanding what it is? More specifically if I go down the path of writing this application in python with wxPython as the GUI tool how does it talk to COM, how do those pieces fit together?

Any advice on where to start learning about this would be greatly appreciated.

Jeff
Monday, April 05, 2004

Heh, it's hard to do much Windows programming without running into COM.  COM is like Microsoft's version of CORBA as I understand it... it's a high-level language-independant layer that can be used to talk to COM dlls or for interprocess communication.

If you haven't done COM stuff before, I'd just try it a little in VB first... maybe go through some of Intuit's examples until it makes sense.  Then you can try it with Python.  I haven't done COM with Python before but I'm sure there's a way.

Jesse Collins
Monday, April 05, 2004

Hi Jeff, I've written an application that worked with the QuickBooks API you're talking about.  Right now, all you need to know about COM is that it's a way of creating and using objects defined by external applications or libraries. 

These objects are accessed by 'interfaces' (which are essentially just a list of methods supported by the objects in question).  In addition, COM defines the notion of a 'universal' or 'dispatch' interface, which allows you to 'dynamically' invoke methods on an object.  If this sounds complex, just keep in mind that it's only the difference between pObject->MyMethod() and pObject->Invoke("MyMethod") [ie: one added level of indirection].

With the QuickBooks API you can work either through the published interfaces (see the documentation for the list of all object types) or through the universal COM interfaces.

Either way you go, QuickBooks (using 'QBFC') requires that you first create an instance of its "session manager" object before you do anything else.

If you're using VC++ 6 (or above), you can use the #import statement to load the QuickBooks classes as native types.

Here's an example of a way to establish a session:

#import "qbFC2.dll" no_namespace, named_guids

void main()
{
    IQBSessionManagerPtr pQBSession(CLSID_QBSessionManager);

    try
    {
        pQBSession->OpenConnection("54321", "JeffsPlugin");
        pQBSession->BeginSession("C:\\myQBfile.ext", omDontCare);
        MessageBox(0, "Session Established!", "", 0);
        pQBSession->EndSession();
        pQBSession->CloseConnection();
    }
    catch (_com_error e)
    {
        MessageBox(0, static_cast<char*>(e.Description()), "QuickBooks Error", 0);
    }
}

There are different interfaces that can be used if you don't want to use QBFC, but they require that you package the XML requests yourself (which is tedious and essentially not important to your application).  If you'd rather do that, just #import "QBXMLRP.dll" and look up the (fewer, but functionally more complex) interfaces for sending XML-packaged requests to QuickBooks.

Kalani
Monday, April 05, 2004

You probably need to starte here: http://www.python.org/windows/win32com/

Tony Edgecombe
Monday, April 05, 2004

Thanks for the info. This is defintly giving me a start in the right direction. A couple minutes of reading and google searching has brought me much further along. I am going to try and find a good book an COM and read up on that a bit before I get more into the wxPython code and do some testing in VB or something where it is more native to QuickBooks documentation. I feel pretty confident in sticking with python for even the windows part of the system now. Thanks again.

Jeff
Monday, April 05, 2004

I am curious about the part of your project regarding extending the application with Windows applications...
Was it part of the project from get-go? Or did you throw it in there as an extra? Is this project for a customer or something you are working on your own?

Either way, I am curious about how you take on a project -presumably with a deadline- without actually knowing how to accomplish it? Yes, you can learn the COM interface on your own in fast forward mode, and get your app to build and run, but without the expert skills which build up over time with experience, the application you write will potentially be a sub-par product. It might even work great for a while until you need to extend it and realize that it was a time-bomb waiting to explode in your face all along.

Learning a brand new technology as you work on a professional project is probably not the best thing to do.
Even if you start with VB, which will hide many of the details of real programming from you, you will still be lacking the expertise to write windows programs. I say this based on your statement that you never did windows programming before. If you had some kind of exposure to windows programming and had some previous experience, maybe then jumping into COM wouldn't be so bad.

I think Joel has a few articles about layers of abstraction and the dangers of ignoring/avoiding how things work by using high-level tools to accomplish things. It is all great if everything works out, but that rarely happens.

Disclaimer: I don't mean to offend you or upset you. Just a comment that might save your butt a few months down the road when you are neck deep in windows programming, things aren't working out and your deadline is approaching.

curious
Monday, April 05, 2004

Curious,

Thank you for the questions, they are right on. The core application is in an area and language I am familiar with. I am an employee of the company using the product. I got the job because of my experitse in solving problems for small companies within even smaller vertical markets and because my skills fit with the primary application. The first set of deliverables is the part I am very familiar with and have a solid understanding of, a web delivered application written in Python against Oracle.

It is a from scratch application so I am looking into the future here and seeing how my choices now will effect me as I move along. One of the key aspects of interest to me is in implementing some windows apps to help in efficency. I am going to start with VB just to see how that works, make sure that QuickBooks will even do what I want in this area. Then I am planning on reading some in depth books, (recommended elsewhere on this board, the books by Petzold and Rector in particular). I will then roll some complete test applications in my spare time and learn all the details of such programming by refactoring them a couple times just to get the feel for the implications of ones decisions. Once I feel I have a good background then I will spec the windows apps and write them.

The need for this part of the application to be excellent is not as important as the level of excellence I will deliver to the core application. I am lucky in that I am provided great flexibility in my job for learning and bumping my head hard along the way as long as the production systems are up to par.

So the deadlines and expectations do not include this need yet, but I forsee its nessesity so once again in my carrier I start learning something new from the ground up, this time I have picked a practical goal to drive my learning.

Thanks for the questions, it is good to see someone provide such a sanity check.

Jeff
Monday, April 05, 2004

Having relatively recently got into COM myself, I can suggest some "why?" books.  Essential COM by Don Box is a bit more of a pedantic style than the usual technology du jour book, but it isn't nearly as unreadable as a lot of people seem to say it is.  And unlike most books with COM in the title, it has the big picture view rather than five hundred pages of slightly modified VB code.

Also, I first grokked interfaces while reading Eric Harmon's Delphi COM book, the first half of which is a good COM overview/introduction.  You'll either be able to score that for cheap, or won't be able to find it at all, since it was written back in the Delphi 5 era.  But I appreciated the non-MS-centric less-hyped view of COM, as might anyone from the planet python/wxWindows. :)

Mikayla
Monday, April 05, 2004

*  Recent Topics

*  Fog Creek Home