On Thu, Jun 20, 2013 at 8:20 AM, Antonia Horincar < [email protected]> wrote:
> Hi, > > Thank you for your reply. I have installed my plugin in development > mode, however I'm a bit confused at this point. I read the "Egg > Cooking Tutorial"[1], but I'm not sure if this is the way to test > things like request handling. I haven't developed a template yet for > what I've written so far, and I'm not sure how to check if specific > methods (for example like the ones in IRequestHandler), work. > If you want to test the logic of the IRequestHandler method implementations (match_request and process_request), you should probably write unit tests. If you would just like to check that your plugin is being invoked from Trac, but don't have a template yet, one way would be to make a minimal template with basically just a pair of html, head and body elements and the necessary attributes (check any of the templates in Bloodhound to see what is required) and display the contents of the data dictionary that you return from `process_request`. The tips on debugging Genshi templates might help in showing you how to print the data passed to the template: http://trac.edgewall.org/wiki/TracDev/PortingFromClearSilverToGenshi#Debugging > Also, I was wondering if the following way is the right way to start > the Python interpreter so that I can see things such as ticket > details: > 1. opening the Python interpreter > 2. importing trac.env > 3. env = trac.env.Environment("bloodhound/environments/main") > 4. following the steps used in methods from the BookmarkPlugin[2] and > write something like: > db = env.get_db_cnx() > cursor = db.cursor() > and then using cursor.execute() to select resource > I guess you are trying to configure an environment where you can interactively work with Trac in order to try out various pieces of code? I've never tried to do this, but it seems like the code snippet you posted should work, and I could see that it would be valuable for experimenting with code. I usually just write a unit test and step through the code while running the debugger. Your way could be nice though because it is more interactive. You'll see `get_db_cnx()` used in a lot of plugins, and it is still allowed, but it is deprecated, so you won't want to use it in your plugin (fine for the interactive session though(. The reason it is used in a lot of plugins is that the plugins are trying to support Trac versions back to 0.11 (as BookmarkPlugin is), but for plugins that only need to support Trac 1.0 and later, which is the case for any Bloodhound plugin, you'll want to use the newer Trac database API. It is all explained here: http://trac.edgewall.org/wiki/TracDev/DatabaseApi
