So many answers,
A psp is compiled into a python servlet so you can call its method directly: htmlHtmlBody = self.callMethodOfServlet(servlet, 'writeHTML')
or you can define a method in PSP w/ <psp:method name="htHelpBody"> and then call it it via: htmlHtmlBody = self.callMethodOfServlet(servlet, 'htHelpBody')
But I would use Cheetah. If you load the template via something like: def __init__(self) self.t = Template(file)
def writeContent(self): t.title = "page title" self.writeln(t)
I am pretty sure that the template will record the timestamp of the source file and automatically recompile itself if the date changes.
But why not just have the first servlet just call itself. If hte form is verified then throw a redirect back to the browser. via :
if formIsValid:
self.session().setValue['username'] = usernameFromFrom
self.response().sendRedirect('page2')
then in page2 just read the session data. This way page2 can be a pure PSP or cheetah file.
-Aaron
Michel Thadeu wrote:
Hi guys,
I think I can�t but I won�t kill anyone asking :), is there a way to import from a psp?
See my problem, to implment forms I create 2 pages, a FormDoSomething.py and a DoSomething.py, the first show the form presentation, the second verifies the data, if the data is wrong, shows a error message on the top of the page and then show the Form.writeContent(self), else do something with the data and shows a ok message.
I have an example in http://www.portaldofornecedor.com.br/cgi-bin/wkcgi/ControleVendas/FormTest
The code for the example is above:
# file FormTest.py from Modelo import Modelo class FormTest(Modelo): def title(self): return 'The test form' def writeContent(self): self.writeln('''\ <form method="post" action="Test"> <p>Name: <input type="text" name="name" value="%s"></p> <p><input type="submit" value="Send Data"></p> </form>''' % self.request().value('name', ''))
# file Test.py from FormTest import FormTest class Test(FormTest): def validarRequest(self): if self.request().value('name', '')!='michel': self.erro.append('The name must be michel!') def writeContent(self): if self.erro: FormTest.writeContent(self) else: self.writeln('<p class="sucesso">Hi michel!</p>')
The form Test only shows the form presentation, I could derivate the Test class from a TestSucess class where there is a sucess message, so I can show the FormTest.writeContent or TestSucess.writeContent, and these 2 files could be generated by a designer, I only will mantain the data control... The designer could do this with psp or cheetah (I don�t want to need to compile the cheetah code each change :) or even zpt...
Sorry if I couldn�t be more especific, but my english is too bad. Thanks for any help...
===== -- Michel Thadeu Sabchuk Curitiba/PR
______________________________________________________________________
Yahoo! Mail - agora com 100MB de espa�o, anti-spam e antiv�rus gr�tis! http://br.info.mail.yahoo.com/
-------------------------------------------------------
This SF.Net email sponsored by Black Hat Briefings & Training.
Attend Black Hat Briefings & Training, Las Vegas July 24-29 - digital self defense, top technical experts, no vendor pitches, unmatched networking opportunities. Visit www.blackhat.com
_______________________________________________
Webware-discuss mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/webware-discuss
--
-Aaron
http://www.MetroNY.com/
If the car industry behaved like the computer industry over the last 30 years, a Rolls-Royce would cost $5, get 300 miles per gallon, and blow up once a year killing all passengers inside.
------------------------------------------------------- This SF.Net email sponsored by Black Hat Briefings & Training. Attend Black Hat Briefings & Training, Las Vegas July 24-29 - digital self defense, top technical experts, no vendor pitches, unmatched networking opportunities. Visit www.blackhat.com _______________________________________________ Webware-discuss mailing list [EMAIL PROTECTED] https://lists.sourceforge.net/lists/listinfo/webware-discuss
