On Fri, Sep 08, 2006 at 02:06:10AM +0200, Ksenia Marasanova wrote: > I want to use one controller method( "save") for both creating and > updating a record. I have two methods for displaying a form: "add" and > "edit". The problem is that the form for adding and editing are > slightly different (different validator in this case) . I can > instantiate two forms, but I can pass only one instance to @validate > decorator of "save" method. > Are separate methods for creating and updating record the only way out?
I'm facing a similar problem right now [1]. The solution I found is creating my own decorator for validation. It receives a callable which generates the schema for validation. I could send you some snippets if you need. But I believe in your case it would be better to use separate methods. What is the point of using single method? Code reuse? You could achieve it by extracting common parts into separate reusable methods. [1] http://groups.google.com/group/turbogears/browse_frm/thread/0f57bc6b3dc3caa5/ -- Timur Izhbulatov OILspace, 26 Leninskaya sloboda, bld. 2, 2nd floor, 115280 Moscow, Russia P:+7 495 105 7245 + ext.205 F:+7 495 105 7246 E:[EMAIL PROTECTED] Building Successful Supply Chains - One Solution At A Time. www.oilspace.com --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "TurboGears" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/turbogears -~----------~----~----~----~------~----~------~--~---

