On Thur, 2002-12-19 Ian Bicking wrote:

> I have to admit I haven't really tried using them together yet.
> Especially with 0.4, with repeating and compound fields, it becomes
> harder to do layout (though 0.4 provides better layout as well).

> But I have imagined them being used where the RenderableForm is in the
> searchList, without any subclassing between them.  Or, if you have two
> forms, put a dictionary like {'form1': self.renderableForm('form1'),
> 'form2': self.renderableForm('form2')}

Ian, could you please post an example of code doing this? I looked at FFK
many months ago, when it was v0.2x, but could never get it to play nicely
with Cheetah via the inheritance approach.

Now, I use something akin to the containment approach (i.e, write Webware
servlets that contain and control the output of Cheetah templates). I just
looked at FFK again yesterday, and managed to get the Login.py example
working within a Cheetah template, but only by dropping in the output of
renderableForm() into a placeholder. That is:

Servlet:
-------
class Login(Page, FormServlet):

    requiresLogin = 0

    def __init__(self):
        ## 'writeContent' is the method that is overidden.  That's what
        ## ExamplePage calls.  'writeForm' is the method that writes
        ## the form (not the one that handles the result).  We declared
        ## the method that handles the result when we created
        ## SubmitButton.
        FormServlet.__init__(self, [formDef])
        Page.__init__(self)
        rf0 = self.renderableForm()
        self.t = self.template(file='TLogin.tmpl', searchList=[rf0])

    def mainResponse(self):
        submitted, data = self.processForm()
        if not submitted:
            rf = self.renderableForm()
            self.t.form = rf.htFormTable()
            print self.t.searchList()
            self.writeTemplate(self.t)
        else:
            self.t.form = "Welcome User <b>#%s</b>!" % data['username']
            self.writeTemplate(self.t)


Cheetah Template:
----------------
#extends Test.Lib.PageTemplate

#def mainPanel
<h1>Testing FunFormKit</h1>
$form
#end def mainPanel



What would be better would be to be able to manually place the widgets that
FFK generates via individual placeholders. How can I achieve this? i.e.,
I'd like to use a Cheetah template like the following instead:

#extends Test.Lib.PageTemplate

#def mainPanel
<h1>Testing FunFormKit</h1>
$myField1
$myField2
#end def mainPanel

There is some mention in Form.py about placing individual fields via
fieldName.html(), fieldName.error() calls, but this is a bit lower level
than what would be ideal. Also, the comments note that compound and
repeating fields are difficult to deal with this way. Being able to place
the FFK fields as complete widgets would be nice. Can I do this?


...Edmund.



-------------------------------------------------------
This SF.NET email is sponsored by: Geek Gift Procrastinating?
Get the perfect geek gift now!  Before the Holidays pass you by.
T H I N K G E E K . C O M      http://www.thinkgeek.com/sf/
_______________________________________________
Webware-discuss mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/webware-discuss

Reply via email to