Archive for the ‘Sprox’ Category

Best of Breed: TG is still the best choice for people who hate hitting the wall.

Monday, September 21st, 2009

We get a lot of refugees who come to TG from other frameworks where they got themselves to a place they could not get out of.  I have worked with some of these frameworks in the past.  Things are awesome in the beginning.  You work on some less complex stuff, maybe change a template around, or the theme for a site.  Then you have some technical detail you need changed and BAM!  You just hit the wall.  Now you are forced to dig, or suck it  up and go on IRC and ask noob question.  Many times I find myself getting shut down, told to RTFM, or whatever.

With TG I never really felt the wall.  TW was a bit of a hump to get over, but seriously, things are so un-coupled in TG that using a technology you are already familiar with, or swapping out the standard stack is not something totally unheard of.  I for one do not like working with Genshi.  I’ll do it, and I support it for major OSS work I do, but really I prefer Mako.  Mako is fast, works in a non-xml way (which makes it great for writing form-emails for instance).  What this means is that TG has good support for Mako in the “standardized” parts like the admin.

The thing is, we really did not have to add much to TG to allow it to work with Mako.  I think one of the ingenious things that TG supports is dotted template lookup.  What this does is allow you to pull data from any package, because the lookup occurs using pkg_resources.  Beautiful, now we have the ability to move templates into their own succinct packages.  Also, we support non-dotted template lookup for template languages like Jinja, and adding support for dotted lookup wouldn’t be too hard to do in the future.

The new TGAdmin interface is another example where hitting the wall is just not something that happens.  TGAdmin is built on new technologies for TG2.0.  Namely RestController, Sprox, and lookup.  It creates a custom controller for each of your model classes, and therefore you have a good place to start from when you get going with your application.  This is great for demoing.  With SQLAutocode, Sprox, and TGAdmin you can literally hook into your client’s database (MySQL, Postgres, sqlite or MSSQL) and generate web forms where you can have an infinitely scrolling tableview, edit, and create forms.  From there you have the ability to customize further, by hiding table/form fields, changing the look and feel of any component in the chain.  This is made possible by Sprox’s configuration interface.  You can also modify the controller code for each model by adding controller methods to your default controller in the admin’s config object.  All of this customization is outlined in a tutorial.  

The great thing with the new TGAdmin is that since it is based on Sprox, you can re-use the knowledge of sprox externally to the admin, and also bring any existing knowledge you may have about ToscaWidgets to the table.  You can even use sprox outside of TurboGears for any other python web-based applications that you have that also use SQLAlchemy (read: Pylons).

To get back to the TurboGears discussion, a lot of folks don’t want everything that TG brings to the table.  Some folks need different auth/auth models,  have no use for a widget library, or even a relational database connection.  TG can serve you too, and it’s still fast.  Recently SourceForge moved over to TG for their main website.  This requires a connection to MongoDB on the back end (read: no SQLAlchemy), zero ToscaWidgets, and a different authentication method.  According to Mark Ramm, they had started with a different framework which lends itself to the Jinja2 templating engine.  As far as I know, Mark was able to meet all of these goals, and eliminate 9/10ths of the server load they had with their previous system, written in something non-python.  This just goes to show how flexible TG was to be able to meet all of these needs, and still provide a technically sufficient solution.  Maybe he will comment more about this in the future.

Now, there are those folks out there who have decided to role their own.  And WSGI definitely supports, if not encourages this behavior.  But I just have to ask:  Who’s agenda are you really fulfilling?  Even if people like your code and you have a small following, are you helping to further the benefits of your projects, or your career in general?  Are you helping your customer in the long run if you leave the project, or leaving them with a dead-end piece of code?  Will they be able to find someone to replace you, should you decide to leave?

TG has an active community of folks who are willing and able to help get your contributions into the main code branch.  We have embraced mercurial, and use it’s abilities to offer a lessened barrier for those who want to contribute.  So, please, before you go make your own framework, see if you can help us make TG better, and your reward is that you now have a community of folks that will help maintain your work, even if you decide not to.

Basically what I am saying here is that TG has an even learning curve.  Sure, as you get more involved, the problems will get harder, but you wont end up having to re-write half of the framework just to get it to do what you want.  And, if you do find something that needs work to meet your needs, you have options to participate in the development of TG.

In 2008 TurboGears ran a sprint series to flesh out the 2.0 release.  We successfully released in Spring of 2009, thanks to the hard work and dedication of a number of folks who saw the process through.  This was a great opportunity for folks who wanted to be actively involved with a web framework to jump in.  It is very likely in the coming months that TG 2.1 will see the same sort of community out-reach as we prepare to move from a development cycle, to a release one.  So, look forward to that, find out how you can contribute, and by all means, give us feedback as to what you really want from a Best of Breed framework.

Best of Breed: TG’s job is hard. Here’s why.

Thursday, September 17th, 2009

In 2005 Kevin Dangoor made the decision to glue together a few existing technologies into something that would be useful for the creation of web pages.  This was marketed as the “Best of Breed” selection.  The challenge with Best of Breed is that the best is constantly in flux.  Also, making that claim requires TG to put in a serious amount of effort in _finding_ and evaluating the best of breed technology and then integrating them with TG.  This is a job I LOVE doing.  Even better than that, when I find something that doesn’t cut the mustard when it comes to being the best of things, I get to write it.

For example, when SQLAlchemy blazed on the scene, and TG was one of the first frameworks to support it.  My own frustrations with SQLObject lead to an early adoption of SQLAlchemy, and I never looked back.  This illustrates TG’s challenge succinctly.  In order to choose SA, I had to give up ModelDesigner and Catwalk.  For me, I just want to write code, not use a [buggy] web page to manipulate data or move pictures around to auto-generate my code.

In 2007 at Pycon, I tried in vain to make Catwalk work with SA.  It just wouldn’t happen.  This was the spark that lit the fire which has become the new TGAdmin, driven by Sprox.  The interesting thing here is that if the “Next ORM” is found, a reasonably small amount of code has to be written to make this happen.   We already have some successes with this with Sprox.

Let’s look at the template language choices you have as a TG developer.  TG started with Kid, and while this is a decent XML-oriented framework, if you used it in the early days if you are like me, you probably hit your head on the keyboard a few times for each complex page you tried to write.  www.percious.com still runs kid tho, and that’s important to note.  TG has not only to support new users who want to use new technologies.  We have to support those sites that are still running but want to migrate over to newer technology.  And I think we do a pretty good job of that, but again, this is a more difficult job than say a Dj-framework that has absolute control over the template language.

So, TG 1.1 will use SA and Genshi, the entire community decided to make the decision I made 3 years ago, that the usage of SA outweighs the benefits from Catwalk and ModelDesigner. Hooray!  Again, framework decisions made by committee are challenging.  This is what I LOVE about TG.  I didn’t have to wait 3 years for the community to catch up, I added SA to my stack of tools, and went  happily on my way.

Even the framework is not immune to TG’s “Best of Breed” mentality.  In 2007, while I was futzing with Catwalk, Mark Ramm hid in a room with Ben Bangert for a few hours and created what would become TG2.0.  We had been struggling with the changes that CherryPy 3.0 represented, and even though in some ways CP3 is a better back end server, we decided to use Pylons for our server level stuff because of the collaboration potential there.  Pylons is indeed a great platform for server-level development.

TG’s team spends an unbelievable amount of time evaluating what _could_ be the best of breed, and some things make the cut, some don’t.  Sometimes we even add stuff because it’s neat and we want to support it for that person who thinks it is the best of breed.  Sometimes folks come to us with a request to support what they believe is the best of breed, and we do the best to enable them to provide their solution as yet another way of using TurboGears.  ToscaWidgets is probably the best example of this.  If you look at the repository, you will see over 15 JavaScript library wrappers, and quite a few other libs that make creating web content easier.  Again, TG allows the developer to choose which JS library fits them the best.  For 2.0 we decided to leave that choice up to the developer.

In short, TG makes the choices so that you don’t have to.  We spend a lot of time examining new technologies, and exploring what _might_ work for you.  All of our developers use TG in real world applications that differ from giant source code repositories to scientific database management applications.  TG handles a diverse set of application in stride.

The next part in this three part series is entitled: “Best of Breed: TG is still the best choice for people who hate hitting the wall.” This will further express the flexibility of TurboGears and describe a bit about what we are doing to make it even easier to get started with TG.

Best of Breed: TurboGears is alive and breathing. We are even thriving.

Tuesday, September 15th, 2009

I think a lot of people wonder what’s happened to TurboGears.  Where is TG going?  Where has it gone?  In a recent mailing list post, we were blasted for our documentation, or lack there-of.  People seem sort of frustrated that they have a great tool in TG2.0, but have to spend so much time isolating their own technical problems that they fail to see that there is considerable documentation in most areas, but that the docs have a few sore spots here and there.

2008 was all about making TG2 _work_.  We’re past that now.  Most things pretty much work, some things work really well.  Other things need some attention.  Now that we’ve got the hard part of actually  designing a functioning framework, we can focus on documentation, and using that valuable framework we have written to push the envelope of what TG can do.

One of the “things” we need provide to the user community is better documentation.  In the past few weeks I have seen more drive in our community to improve the docs than ever before.  Michael Pedersen has taken over responsibility for our documentation.  I cannot thank him enough for his work, both in reviewing, reorganizing, adding to, and fixing errors in our existing documentation.  His kind of no-sacrifices attitude towards the docs means that we won’t just have “something” up there, we will have what it takes for developers to create web applications using TurboGears.

ToscaWidgets is a sore spot for a lot of folks.  I feel your pain.  Lot’s of folks say you don’t really need TW to do what it does because you are just creating HTML forms, what is so hard about that.  Well, I’ll tell you that I could not have written Sprox without it’s flexibility.  Here’s the good news: TW has been re-written from the ground up by Paul Johnston in the past few months.  I’ve been helping in this process, providing the tests that will make it more stable than the previous version, and making sure the codebase is not so complex a feeble mind like my own cannot comprehend it.  I spent some time benchmarking it, and making sure it’s as fast as it can be.   TW2 is 2x as fast as TW.  It approaches the speed of simpler frameworks that _only_ produce html (they don’t do resource injection, parameter cascading, etc.)

On other fronts, Jorge Vargas and I have been working on integrating MongoDB with Sprox.  This will become the “killer app” for sprox 0.7.  For me, this represents proof of concept for Sprox.  We have successfully integrated the basic workings of MongoDB into Sprox, which means I generalized in the right places enough for this to work.  The result is a TG Admin that will work for MongoDB or for SQLAlchemy equally.

So yeah, there’s still a lot of activity on the TG front, and if you pop into IRC you can feel free to chat up at least one of the TG dev team at almost any hour.  Also, we are having a DocSprint Sept. 25-27 (with a main emphasis on Sept. 26), in Boulder, CO and worldwide remotely.  We will be addressing the over 100 todo items that Michael has so graciously gathered for us.

This is the first part in a 3 part serious on TurboGears.  The next part is entitled: “TG’s Job is hard.  Here’s why.” which will discuss various philosophical challenges with running a project like TurboGears.

Pycon 2009

Wednesday, February 4th, 2009

So, Pycon registration has been up for a few days, I will be speaking both on and off-podium (read: open space) and providing assistance to and presenting tutorials.  Here is a run down of what I am planning in case you wanted a little bit more in-depth information.

Tutorials:

Turbogears2 Beginner and Intermediate:

I will be assisting Mark Ramm by giving individuals help installing and using the new TurboGears2 framework.  Mark is an experienced tutorial presenter, an expert in the technology, and in general a fun character to spend a few hours with.  When you leave his tutorials you should expect to have a working version of TG2 on your machine, along with an understanding of Model, View, and Controller paradigms.  Middleware, Forms, and REST will also be covered.  One note, if you are getting started with TG2, it’s best to have it installed and running if you plan to attend only the Intermediate Section.  We will not be going over installation in the second-half.

 Toscawidgets: Test Driven Modular Ajax:

I am presenting this tutorial which will describe how to use the valuable Toscawidgets package to create web content.  If you are currently use WSGI technology, and are interested in creating reusable, modular web content, this is a perfect way to get started.  I will show you how to configure TW middleware to work with pylons (which is applicable to other frameworks like repoze.bfg, paste, or even plone/Grok).  I will then describe how you might use this middleware to generate web forms.  The last few hours of class will be devoted to using the JavaScript utilities of TW to create an Ajaxified website, and test it using YUITest.

The Big F’ing Tutorial: Development Using the repoze.bfg Web Framework

I will assist/present with Chris McDonough about this up-and-coming framework who’s goals are to utilize bits of the zope 3 framework, wsgi, and new technologies to make a lighting-fast web server.  Those of you who are familiar with Zope technologies may be interested to find how nicely some of the familiar bits of zope are integrated with wsgi with repoze.bfg.

 Presentations:

Using Sphinx and Doctests to provide Robust Documentation

This is a 1/2 hour slot which describes how you can integrate tested documentation with your source code… with sanity!  I go over a quick install of Sphinx, and use some screencasts to demenstrate how to add, run, and display doctests using it.

Open Space:Agile Development with SQLAlchemy and Python Testing Tools

I really enjoy giving this talk, and even though it was not accepted as a formal talk, I will find a venue by way of Open Space to express my knowledge of Testing, SA, and Nose.  I have given this talk a few times now, and it’s fairly polished.  My presentation, while on some dry topics, won’t put you to sleep.  Carefully prepared screencasts and photograph-punctuated slides makes the 45 minutes breeze by.  Questioneers/Hecklers welcome!

 Sprint Topics

I want to spend some time with the Dispatch of TG2, and probably push Sprox further a bit.  If you are just starting with TG, please feel free to contribute.  Sprinting is a great way to learn a lot from the experts in the domain.  We usually do a meet-greet-install the night before the sprints.  Oh, and I’ve been known to provide refreshments to all of our sprinting hordes (read: FREE BEER).

So, I hope to see all of you there!  If you see me in the hall, feel free to introduce yourself and tell me what you are using Python for!

Coding Binge

Tuesday, January 27th, 2009

I haven’t written to the blog in a while.  Quite frankly, I’ve been busy.  In the last 30 days, I have released 3 software new packages, updated 1, deprecated 1, participated in a sprint that lasted a virtual 2 weeks, closed countless tickets, and pushed forward TG2 functionality.

TG2b4 was released last Saturday.  This was mostly a bug-fix release, but b3 is where the new functionality really came into the scene.  TG2b3 is the first build to include Sprox, a new library for schema-generated widget generation.  Sprox is the offspring of DBSprockets.  I decided I liked the declarative part of DBSprockets so much I wanted to spin it off as it’s own entity.  Sprox looses DBSprocket’s table-based dependency, utilizing the mapping provided by SQLAlchemy.  I realized that much of DBSprocket’s code was doing precisely what SQLSoup was designed to do, and decided to focus my efforts on making and extremely configurable widget base.  The result was a considerable removal of the cruft that was associated with DBSprockets.  Sprox releases with an excellent documentation base provided by Sphinx.

There has been a bit of resistance to Sprox, people were/are confused/upset about my providing yet more options for schema based widget generation.  The fact is I have yet to find anything that performs as well as Sprox from a developer/speed standpoint, and I needed to provide our TurboGears user base with a better way to administrate their site, and also allow them to use that tool component-wise in their system.  I think this method for developing widgets is well done in other frameworks, and we need a solid answer to this problem.  Sprox is just that.

The next step was to re-work Catwalk to use Sprox.  This took a little effort, and I put in RESTful URLs while I was at it, but struggled with making the URLs work within TG2’s dispatch system.  The result was as close to REST as you can get without conforming to a set standard.

The result of hacking REST into Catwalk got me thinking, and I decided to implement content-type dispatch as well as RESTful dipatch in TG2.  I went back for another round on Catwalk, and converted it over to the standard.

I’ve also been toying around with Dojo at NREL.  I’m pretty much done with ExtJS due to licensing issues, a not-so-hot codebase, and weak support from IRC.  It’s bad when you go on to ask a question on the channel as a 6 month-user of a software project and end up spending all your time answering everyone else’s questions (as the most experienced person in the room).  Something must be said for an organization that does not push paid consulting as a primary focus on their website…  #dojo has been an exceptional resource for getting my work done.  Those guys know their software, and lend a great hand to help you with it.

Back to the topic at hand… I was able to shoe-horn Dojo into Sprox with little effort, and implemented DojoCatwalk, which worked, but was ultimately not what I wanted.  What I really wanted was configurability.  I started work on tgext.admin, which was supposed to provide enough functionality to replace tgcrud, a command to auto-create crud in your own TG application.  To support tgext.admin, I created a new package called tgext.crud, which provided a CrudRestController, which is a simple way of providing crud for any object in your model.  AdminController combines this functionality with that of Mark’s lookup code to provide a fast, configurable set of tables/forms/etc for all objects in your model.  AdminController takes a declarative AdminConfig as input which provides a consistent way to create your administrative toolset.  Did I mention it does Dojo tables with ajax loading?  Yeah.

I’m not done with this binge yet.  Catwalk is going to mutate one more time before I’m through with it.  It is going to become a default-configured AdminController specifically designed to work within the context of a quickstarted TG2 application.  I had one blocker ticket which was solved last weekend, so it’s time to get Catwalk good and finished.