Re: [Cheetahtemplate-discuss] CGI-Post methods and template rendering
Brought to you by:
rtyler,
tavis_rudd
From: <ir...@ms...> - 2002-12-23 16:17:08
|
I'm not at all sure what you're trying to do. On Mon, Dec 23, 2002 at 03:35:53PM +0100, Ralph Wiechmann wrote: > I have a little framework that builds up my html templates: > Starting at a fix index.html-call the next call is to a frame.tmpl like > that: I assume by "call" you mean a web request, thus: 1) index.html contains "<FRAMESET><FRAME ...> ... </FRAMESET>". 2) Each frame is a separate, completely independent servlet. > #from Datamarts.LoginModule.Controller.LoginController import > LoginController > #extends LoginController > #implements dummy > ############################## > ## Attributes > #attr $appTitle = 'Title' > #attr $title = 'Datamarts'' > ############################## > #def bodyframe > #include "./include/dataframeinc.tmpl" > #end def > #def footerframe > #include "./include/footerframeinc.tmpl" > #end def I don't understand why you're putting bodyframe and footerframe in the same template, but if it works... Note: using #include right can be tricky, especially if the include file is doing anything fancy. Often there's a way to avoid the #include.... > In some of these templates i call HTML-form submits to some existing > python classes (all that is a cgi-envrionment running under webware). By "cgi-environment" do you mean servlet environment? > Lets assume a cgi-call to one python method is > > class CGIPGM: > .. > . > . > def head(self): > pfad = os.path.dirname(__file__)+'/templates/' __file__ will work with pure Python classes, but it may do funny things in templates. With precompiled templates it refers to the .py template module (not the .tmpl file). With templates compiled to memory, it would probably refer to the temporary file the module was briefly written to. > self.bodyArgs = '' > myfields = self.request().fields() > org = myfields.get('org',None) > self.writeBody() This is with Webware's Page infrastructure? It requires some work to get Cheetah set up right with Page. Eventually we'll have an example of it in the Users' Guide, but not yet. It's not clear what good 'myfields' and 'org' are doing: they certainly aren't placeholders but just local variables. In short, we'd need to see more completely how the application is structured in order to troubleshoot it. > In this CGIPGM a want to call the frame.tmpl again. > How does this work ?? . I assume this translates to, "On this page (which displays in one of the frames), I want a hyperlink that when clicked, overwrites the entire window (all frames) with something else." This is not a Cheetah issue or a Webware issue, but an HTML issue. Your hyperlink should be constructed like: <A HREF="index.html" TARGET="_top">label</A> > Is it also possible to pass variables to templates method. #def myMethod($arg1, $arg2) My arguments are $arg1 and $arg2. #end def $myMethod("A", "B") t = MyPrecompiledTemplate() print t.myMethod("A", "B") Note: if you don't define $arg1 and $arg2 as arguments on the #def line, they will be looked up in the searchList, which provides an alternate way to set the values. -- -Mike (Iron) Orr, ir...@ms... (if mail problems: ms...@oz...) http://iron.cx/ English * Esperanto * Russkiy * Deutsch * Espan~ol |