473,507 Members | 12,693 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Cheetah template driven object output? Pythonically?

This may be trivial or stupid or both, but does anyone have a recipe
for gracefully using Cheetah to generate a text representation of an
object, but embedded in the object (so that it can be pickled,
unpickled, and told to display itself)?

Here is what I am thinking:

<pre>

import Cheetah.Template as T
class Foo:
def __init__(self, mystate, cheetah_template='./mytemplate.tmpl'):
self.mystate = mystate
self._template = T.compile(<stuff>)

def set_state(self, newstate):
self.mystate = newstate

def as_html(self):
print self._template(searchlist=<SOMETHING GENERIC>)

</pre>

I guess that would work pretty well, though it is untested completely.
Has anyone done anything fairly generic and similar? Pitfalls?

Jan 30 '06 #1
1 1132
Fried Egg wrote:
This may be trivial or stupid or both, but does anyone have a recipe
for gracefully using Cheetah to generate a text representation of an
object, but embedded in the object (so that it can be pickled,
unpickled, and told to display itself)?

Here is what I am thinking:

<pre>

import Cheetah.Template as T
class Foo:
def __init__(self, mystate, cheetah_template='./mytemplate.tmpl'):
self.mystate = mystate
self._template = T.compile(<stuff>)

def set_state(self, newstate):
self.mystate = newstate

def as_html(self):
print self._template(searchlist=<SOMETHING GENERIC>)

</pre>

I guess that would work pretty well, though it is untested completely.
Has anyone done anything fairly generic and similar? Pitfalls?


I don't know if may be of any help, but David Mertz has done something
related (pickling/unpickling) with XML and metaclasses:

http://gnosis.cx/download/gnosis/
--
bruno desthuilliers
python -c "print '@'.join(['.'.join([w[::-1] for w in p.split('.')]) for
p in 'o****@xiludom.gro'.split('@')])"
Jan 30 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
1948
by: Timo Virkkala | last post by:
I tried to install Cheetah (0.9.15) and ran into trouble. When running the test suite, I get 61 failures and 57 errors. Most of the errors are "ImportError: No module named temp", with some...
1
2388
by: Mike Grigorov | last post by:
I am using cheetah with jython 2.1 and I have problem generating templates that contain cyrillic text. Some texts are printed OK and others are not. I searched Jython and cheetah projects mailing...
13
3500
by: Charlotte | last post by:
I am developing a web application and am looking for the best framework to do this in. I know this is an old question, and I have read the list archives and a couple of comparison pages on the web....
0
910
by: ajay.padala | last post by:
Hi I would like to be able to get the inputs that are needed into a template file programmatically. For example if we had a template: ===================== $name has $num marbles in his...
1
1382
by: chun ping wang | last post by:
I am having trouble using cheetah and getting it to work the way i want (mvc) I have the following file. index.py : # imports BibleController and setting. BibleController.py that includes...
4
1344
by: Paolo Pantaleo | last post by:
I have a cheetah template something like this: x is: $x y is: $y z is: $z If for example $y is not defined I get an exception and the parsing of the template stops. Is there any way to...
2
1364
by: Sai Krishna M | last post by:
Hi, I have been working for some time developing web pages using python, modpython, cheetah. I find that this method has come inherent difficulties in it like if we want to generate a single...
0
1184
by: manuel.reil | last post by:
Hello, currently i am developing a very small cms using python and cheetah. very early i have noticed that i was lacking the method to extract/recover the contents (html,text) from the html that...
1
3065
by: brianrpsgt1 | last post by:
Newbie here.... I have been able to successful pull info from a MySQL DB, get the results and output them in an HTML format using Cheetah to the screen using IDLE. I am doing this on a Windows...
0
7110
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7314
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
7030
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7482
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5623
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
3191
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3179
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1540
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
758
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.