On Fri, Jun 5, 2009 at 3:55 PM, Dan Winslow<dwins...@aiminstitute.org> wrote: > I am attempting to modify some plugin code, despite my lack of python > knowledge. I wanted to add type checking to the validator plugin, and so I > added the modified the function. With a trac.ini entry of > > > > [fieldscheck] > > int_fields=Hours > > > > and running this code : > > > > def validate_ticket(self, req, ticket): > > """Make sure required fields for the next state have been > > the ticket will be in have been entered.""" > > > > state = self._get_state(req, ticket) > > > > editcheck_fields = self.config.getlist('fieldscheck','int_fields') > > > > errors = [(field_name, '%s must be an integer' % field_name) > > for field_name in editcheck_fields > > if self._is_not_integer(ticket[field_name])] > > > > required_fields = self.config.getlist('ticketvalidator', > > state + '.required') > > > > errors = errors + [(field_name, '%s is required' % field_name) > > for field_name in required_fields > > if self._is_empty(ticket[field_name])] > > > > return errors > > > > > > I get : > > TypeError: cannot concatenate 'str' and 'list' objects > > > > On the line : > > > > if self._is_not_integer(ticket[field_name])] > > > > I get the feeling this is just a python problem of mine and not something > intrinsic to TRAC, but I thought I’d ask you guys anyways. > > > > Thanks in advance.
Probably need to see the rest of the code to be sure what the actual problem is. Also, your _is_not_integer() and _is_emtpy() methods seem unnecessary. The former can be replaced with `not ticket[field_name].isdigit()` and the latter with `not ticket[field_name]`, at least as far as I can tell from how they're being used. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Trac Users" group. To post to this group, send email to trac-users@googlegroups.com To unsubscribe from this group, send email to trac-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/trac-users?hl=en -~----------~----~----~----~------~----~------~--~---