The Spring Framework carries a certain legacy that when carried into the Python world, can have strong negative consequences. There are blogs that discuss Should Python and XML Coexist?. Well, I have asked a similar question when I worked at a previous job while working with Java and XML. When I read Rod Johnson's blog entry about a pure Java Spring configuration option, I saw a code example that could become the beginnings of a beautiful relationship:
@Configuration
public class MyConfig
{ @Bean
public Person rod
() { return new Person
("Rod Johnson");
}
@Bean(scope = Scope.PROTOTYPE)
public Book book() {
Book book = new Book("Expert One-on-One J2EE Design and Development");
book.setAuthor(rod()); // rod() method is actually a bean reference !
return book;
}
}
To me, it seemed simpler to read configuration of code written in the same language as the code itself. When
Spring Java Config made its debut, I migrated an existing application over to it immediately. It should be no surprise that when I started Spring Python, this was one of the target features I pursued.
When I decided to write the book, it was a no-brainer that I would code all the sample configurations using pure Python. The only areas where it made sense to write about XML was where I wanted to offer that convenient bridge for Java developers to transisition some/all of their code into Python. I have done plenty of upgrades/transitions/rewrites and I have found that the less it takes to move into a new area of technology, the better my chances of success are. Being able to migrate one bit at a time makes it possible to transition smoothly while still adding new features. That is the message I wanted to convey.
I was really happy to read a
5-star book review this morning where one of my readers caught this perfectly.
...I can only applaud that despite its Java roots almost no XML is used - that's a good news for all Python programmers fearing that "Spring" means a lot of unnecessary XML, the prevailing majority of examples is in pure Python.
Spring Python doesn't mean a lot of XML. Code it with pure Python and enjoy!