From celtek at wp.pl Sat Aug 13 19:07:26 2005 From: celtek at wp.pl (Justyna Tomczyk) Date: Sat Aug 13 19:17:15 2005 Subject: [ZPT] validation in a table Message-ID: <42fe7d2e43298@wp.pl> Hi, I have a table with results from database(MySQL). I can edit every field in this table (change data and save it in database). Problem is that I don't know how to validate every field in this table before I want to save this changed data in database. I've tried figured out how to validate this data but without results. Now I am really in a whirl. What and where I should insert ? Any clue? Any help? Here is a bit of code from ZPT : from Script(Python): #from Products.Formulator.Form import FormValidationError #request = context.REQUEST #RESPONSE = request.RESPONSE #matricula=request.form.get('matricula') #name=request.form.get('name') #term=request.form.get('term')) #Id=request.form.get('Id') #container.sql_corect(matricula=matricula,name=name,term=term,Id=Id) #return RESPONSE.redirect('show_table?message=data was changed ! ') from ZSQLMethod: update students set matricula = , name = '', term = where Id = ---------------------------------------------------- I Ty mo?esz nabra? fantastycznych mocy! Mister Fantastic, Niewidzialna kobieta, Ludzka pochodnia i Stw?r - Fantastyczna czw?rka, w kinach od 19 sierpnia. http://klik.wp.pl/?adr=www.film.wp.pl%2Ffilm.html%3Fid%3D23237&sid=463 From mkur at poczta.gazeta.pl Sat Aug 13 21:16:37 2005 From: mkur at poczta.gazeta.pl (Michal Kurowski) Date: Sat Aug 13 21:26:30 2005 Subject: [ZPT] Re: validation in a table In-Reply-To: <42fe7d2e43298@wp.pl> References: <42fe7d2e43298@wp.pl> Message-ID: <20050814011637.GA26612@calvados> Justyna Tomczyk [celtek@wp.pl] wrote: > > I have a table with results from database(MySQL). I can edit every > field in this table (change data and save it in database). Problem > is that I don't know how to validate every field in this table > before I want to save this changed data in database. I've tried > figured out how to validate this data but without results. Now I am > really in a whirl. What and where I should insert ? Any clue? Any > help? Generally, your code is layed out in too fine grained way. Normally you would use ZPublisher "record" - type input fields and then do all the work in a PythonScript to perform validation on a form variables(s) (and eventually call ZSQL). Check out the Zope Book. There are many alternatives. A product dubbed "Formulator" is certainly worth trying. Cheers, -- Michal Kurowski From fdrake at gmail.com Thu Aug 18 18:01:15 2005 From: fdrake at gmail.com (Fred Drake) Date: Thu Aug 18 18:11:22 2005 Subject: [ZPT] New METAL feature for Zope 3.1 Message-ID: <9cee7ab80508181501755d2ee1@mail.gmail.com> Zope 3.1 will include a new feature in METAL, the Macro Expansion Tag Attribute Language used in page templates. The implementation is largely complete, but some issues with it were uncovered in the past week that have caused some re-evaluation of the details. At this point, we discovered that sufficient documentation did not exist, so I'm working on a new revision of the METAL specification. This is currently in draft form on the ZPT wiki, along with a description of the macro extension feature. I plan to update the tests and finish the documentation sometime tomorrow. The feature is described here: http://www.zope.org/Wikis/DevSite/Projects/ZPT/MacroExtension The draft specification is here: http://www.zope.org/Wikis/DevSite/Projects/ZPT/MetalSpecification11 Comments are welcome, though I can only apologize for bringing this up to the list so late. (I'm afraid the non-availability of my own time prevented me from knowing about the issue until recently.) -Fred -- Fred L. Drake, Jr. Zope Corporation From fdrake at gmail.com Mon Aug 22 11:48:40 2005 From: fdrake at gmail.com (Fred Drake) Date: Mon Aug 22 11:59:01 2005 Subject: [ZPT] METAL 1.1 implemented, specification updated Message-ID: <9cee7ab805082208481e4cd1a5@mail.gmail.com> The METAL 1.1 specification has been updated (though it's still marked as a draft, pending review), and the implementation has been completed on the Zope 3 trunk and backported to the Zope 3.1 branch. This would be a good time to review the specification and ask any questions that come up. I hope there's nothing outstanding that can't be handled by improving the documentation! -Fred -- Fred L. Drake, Jr. Zope Corporation From celtek at wp.pl Tue Aug 23 09:59:03 2005 From: celtek at wp.pl (celtek@wp.pl .) Date: Tue Aug 23 10:09:27 2005 Subject: [ZPT] pass parameter in href Message-ID: <430b2ba71b283@wp.pl> Hi, In 2.zpt I have: this 'firstValue' come from 1.zpt I want to pass this integer ' value ' into script using link in 2.zpt: but I can't figured out what I should insert in place of this question marks When I insert : I receive only word ' value ' not integer value depending on what was 'firstValue'. I know that when I want to pass parameter from script to zpt I can use something like this: #return RESPONSE.redirect('test_results?%s' % query) but in this case?? Thanks and greetings! ---------------------------------------------------- We? udzia? w naszym letnim konkursie AlleJazda! G??wna nagroda to Nisan Micra! http://klik.wp.pl/?adr=http%3A%2F%2Fadv.reklama.wp.pl%2Fas%2Faj.html&sid=472 From fdrake at gmail.com Tue Aug 23 10:08:39 2005 From: fdrake at gmail.com (Fred Drake) Date: Tue Aug 23 10:19:03 2005 Subject: [ZPT] pass parameter in href In-Reply-To: <430b2ba71b283@wp.pl> References: <430b2ba71b283@wp.pl> Message-ID: <9cee7ab805082307082106f0ec@mail.gmail.com> On 8/23/05, celtek@wp.pl . wrote: > In 2.zpt I have: > this 'firstValue' come from 1.zpt > I want to pass this integer ' value ' into script using link in 2.zpt: > > but I can't figured out what I should insert in place of this question marks > When I insert : > > I receive only word ' value ' not integer value depending on what was 'firstValue'. I'm just guess that you don't really want it all in a comment. :-) Try this: -Fred -- Fred L. Drake, Jr. Zope Corporation From celtek at wp.pl Thu Aug 25 16:45:55 2005 From: celtek at wp.pl (celtek@wp.pl .) Date: Thu Aug 25 16:56:26 2005 Subject: [ZPT] formating validation results Message-ID: <430e2e0394530@wp.pl> Hi, I have a script responsible for validation and when an error occurs it will be return : #return RESPONSE.redirect('show_zpt?formErrors=%s&value2=%s' %(error, value2)) then in 'show_zpt' it will be use : and message: {'surname': 'Input is required but no input given.'} but I don't want to have this message format, it would be better to have something like this: surname: Input is required but no input given. - without this additional marks! What I should change to have this message format? Thanks and regards! ---------------------------------------------------- 26 sierpnia w Stoczni Gda?skiej koncert J.M.Jarre'a - "To b?dzie m?j najlepszy koncert - koncert wolno?ci" - zapowiedzia? artysta. http://klik.wp.pl/?adr=www.muzyka.wp.pl%2Fjarre&sid=468 From crobbenhaar at web.de Thu Aug 25 19:19:13 2005 From: crobbenhaar at web.de (Clemens Klein-Robbenhaar) Date: Thu Aug 25 19:18:46 2005 Subject: [ZPT] formating validation results In-Reply-To: <430e2e0394530@wp.pl> References: <430e2e0394530@wp.pl> Message-ID: <430E51F1.60903@web.de> Hi celtek: > Hi, > I have a script responsible for validation and when an error occurs it will be return : > #return RESPONSE.redirect('show_zpt?formErrors=%s&value2=%s' %(error, value2)) > First better try not to do a redirect, but return the page directly; if You use a redirect You can only pass the error dictionary as a string. Saying: context.REQUEST.set('formErrors', error) context.REQUEST.set('value2', value2) return context.show_zpt() should call the page directly and allow to pass the dictionary as is. Alternatively You can say return context.show_zpt(formErrors=errors, value2=value2) and then get the parameters via options/formErrors instead of request/formErrors. (unless I am mistaken here.) > then in 'show_zpt' it will be use : > > and message: > {'surname': 'Input is required but no input given.'} > > but I don't want to have this message format, it would be better to have something like this: > > surname: Input is required but no input given. - without this additional marks! > Yow: when passing in the errors dictionary directly, You should be able to say something like:

Form validation errors

The details depend on Your data structure, of course. Most probably You want to loop over the fields of Your form and check if there is an error for the given field, so the errors appear in the same order and the fields (the order is pretty undefined for the dictionary ...) Cheers, Clemens P.S. If not found already, a ZPT + Formulator intro is here: http://www.zope.org/Members/beno/HowTo/Formulator_With_ZPT