I'm wondering if anyone knows of any good tutorials on the web that describes how to properly integrate HTML in CherryPy code. As I write my web application I obviously need to create a header and a 'body' with HTML code. I haven't found any good documents online that describes how to go about doing this.
Also, does anyone have any recommendations on a good 'beginner' book for CherryPy? I'm very familiar with Python but am ramping up (slowly) with CherryPy and could use a good read. The documentation / tutorial on the CherryPy page was lacking a bit.
There are a lot of python-based tricks you can use for outputting HTML, such as string formatting, or base classes that define headers and footers and are extended by other classes that define content, etc etc. But I've found that after two or three pages of this sort of stuff it's far easier just to learn one of the many python templating packages and use that. I use Jinja, because I'm accustomed to django's templates, but Cheetah, Genshi, Mako and Myghty and Evoque are all popular options. It's just a major pain to do it yourself, and the more you work on a nice re-usable system for outputting html, the closer you come to re-inventing one of the aforementioned templating packages :)
> I'm wondering if anyone knows of any good tutorials on the web that > describes how to properly integrate HTML in CherryPy code. As I write > my web application I obviously need to create a header and a 'body' > with HTML code. I haven't found any good documents online that > describes how to go about doing this.
> Also, does anyone have any recommendations on a good 'beginner' book > for CherryPy? I'm very familiar with Python but am ramping up (slowly) > with CherryPy and could use a good read. The documentation / tutorial > on the CherryPy page was lacking a bit.
> I'm wondering if anyone knows of any good tutorials on the web that > describes how to properly integrate HTML in CherryPy code. As I write > my web application I obviously need to create a header and a 'body' > with HTML code. I haven't found any good documents online that > describes how to go about doing this.
> Also, does anyone have any recommendations on a good 'beginner' book > for CherryPy? I'm very familiar with Python but am ramping up (slowly) > with CherryPy and could use a good read. The documentation / tutorial > on the CherryPy page was lacking a bit.
> Thanks! > - james
I thought that Sylvain Hellegouarch's _CherryPy Essentials_ was quite good.
I especially like the chapters on web services and AJAX. I'd worked on projects that did some of this stuff before, but his examples showed me lots of things that I could have done better. If you are interested in building websites with CherryPy and you aren't sure where to start, you should start with _CherryPy Essentials_.
I use Mako templates and it is quite easy to integrate html with python using cherrry py. Initially there is a bit of a learning curve, however once you get it going, it flows along nicely...If you have any specific questions do post as I went through this learning curve as a complete newbie myself...\ Arjuna
On 6/25/08, jonathansamuel <jonathansam...@yahoo.com> wrote:
> I agree that Sylvain Hellegouarch's book on CherryPy is good. His > example in the book uses the Kid templating engine.
jonathansamuel <jonathansam...@yahoo.com> writes: > I agree that Sylvain Hellegouarch's book on CherryPy is good. His > example in the book uses the Kid templating engine.
The nice thing about Sylvain's book is that he shows you how easy it is to mix and match components in CherryPy. For example, I have quite a bit of experience with Zope Page Templates, and I didn't really want to learn the ins and outs of another templating language just because I got tired of trying to fit Zope into my head. After reading Sylvain's Kid examples I was able to integrate SimpleTAL in a similar manner.
In fact, choosing which templating language to use is much more difficult than integrating your choice into CherryPy. I swear someone creates a new templating language for Python every 14 minutes.
Jason Earl wrote: > jonathansamuel <jonathansam...@yahoo.com> writes:
> > I agree that Sylvain Hellegouarch's book on CherryPy is good. His > > example in the book uses the Kid templating engine.
> The nice thing about Sylvain's book is that he shows you how easy it is > to mix and match components in CherryPy. For example, I have quite a > bit of experience with Zope Page Templates, and I didn't really want to > learn the ins and outs of another templating language just because I > got tired of trying to fit Zope into my head. After reading Sylvain's > Kid examples I was able to integrate SimpleTAL in a similar manner.
> In fact, choosing which templating language to use is much more > difficult than integrating your choice into CherryPy. I swear someone > creates a new templating language for Python every 14 minutes.
On Wed, Jun 25, 2008 at 3:58 PM, Robert Brewer <fuman...@aminus.org> wrote:
> Jason Earl wrote: >> jonathansamuel <jonathansam...@yahoo.com> writes:
>> > I agree that Sylvain Hellegouarch's book on CherryPy is good. His >> > example in the book uses the Kid templating engine.
>> The nice thing about Sylvain's book is that he shows you how easy it > is >> to mix and match components in CherryPy. For example, I have quite a >> bit of experience with Zope Page Templates, and I didn't really want > to >> learn the ins and outs of another templating language just because I >> got tired of trying to fit Zope into my head. After reading Sylvain's >> Kid examples I was able to integrate SimpleTAL in a similar manner.
>> In fact, choosing which templating language to use is much more >> difficult than integrating your choice into CherryPy. I swear someone >> creates a new templating language for Python every 14 minutes.
> Is there a "best" templating system? Or is it a simple balance of > complexity vs flexibility and power?
I am new to cherrypy and python in general and after a little research I decided to use genshi. I think that the biggest impact on my decision was that there is excellent tutorial abount cherrypy and genshi.
James wrote: > Is there a "best" templating system? Or is it a simple balance of > complexity vs flexibility and power?
In my not very humble opinion, the choice of a templating system is *much* more a matter of personal preference than it is about performance or complexity. Seriously, unless you write a site that gets 500 hits a minute (and darned few of us will every do that), you don't need to think about performance. Instead, you should try a simple project with a bunch of them, then use the one that makes the most sense to you.
I know a lot of people like the Zope TAL scheme. I don't. To me, it has always seemed excessively wordy and non-intuitive. Now, I *know* that the TAL fans would disagree with my assessment (no need to write me), and that's just fine. That's why there are so many choices.
For me, the Cheetah scheme has always seemed incredibly sensible. Simple, quick, flexible, with a great blend of Python and HTML. It lets me concentrate on making my pages look the way I want, without getting in the way. Again, I know that many people think that Cheetah breaks the "separation of presentation and computation" rule too much, and that's fine. I will keep getting my work done with Cheetah, while they get their work done with TAL.
-- Tim Roberts, t...@probo.com Providenza & Boekelheide, Inc.
> For me, the Cheetah scheme has always seemed incredibly sensible. > Simple, quick, flexible, with a great blend of Python and HTML.
Hello!
I think, Cheetah is a very good choice! Because, it's simple to use for simple tasks. And it's mighty enough to do powerful tasks. And your template donīt look like a brace-storm. ;-)
-- ________________________________________________________________________ Gerold Penz - bcom - Programmierung http://halvar.at | http://sw3.at | http://bcom.at Wissen hat eine wunderbare Eigenschaft: Es verdoppelt sich, wenn man es teilt.
>> > I agree that Sylvain Hellegouarch's book on CherryPy is good. His >> > example in the book uses the Kid templating engine.
>> The nice thing about Sylvain's book is that he shows you how easy it > is >> to mix and match components in CherryPy. For example, I have quite a >> bit of experience with Zope Page Templates, and I didn't really want > to >> learn the ins and outs of another templating language just because I >> got tired of trying to fit Zope into my head. After reading Sylvain's >> Kid examples I was able to integrate SimpleTAL in a similar manner.
I actually have a rough draft started. I just need to finish it. Part of the problem is that while what I have got now is good enough for me. It's not quite to the point where it is good enough for the rest of y'all.
When I get to the point where my solution is as comprehensive as the Jinja example, then I'll share :).