Opened 10 years ago
Closed 10 years ago
#12156 closed defect (fixed)
object of type 'datetime.datetime' has no len()
Reported by: | Owned by: | Ryan J Ollos | |
---|---|---|---|
Priority: | normal | Component: | TicketValidatorPlugin |
Severity: | normal | Keywords: | time date |
Cc: | Trac Release: | 1.0 |
Description (last modified by )
Oops… Trac detected an internal error:
TypeError: object of type 'datetime.datetime' has no len()
This is probably a local installation issue. You should a ticket at the admin Trac to report the issue. Found a bug in Trac?
If you think this should work and you can reproduce the problem, you should consider creating a bug report.
Note that the TicketValidator plugin seems to be involved. Please report this issue to the plugin maintainer.
Before you do that, though, please first try searching for similar issues, as it is quite likely that this problem has been reported before. For questions about installation and configuration of Trac or its plugins, please try the mailing list instead of creating a ticket.
Otherwise, please a new bug report describing the problem and explain how to reproduce it.
Python Traceback Most recent call last:
File "build/bdist.linux-x86_64/egg/trac/web/main.py", line 551, in _dispatch_request dispatcher.dispatch(req) File "build/bdist.linux-x86_64/egg/trac/web/main.py", line 225, in dispatch resp = chosen_handler.process_request(req) File "build/bdist.linux-x86_64/egg/trac/ticket/web_ui.py", line 175, in process_request return self._process_ticket_request(req) File "build/bdist.linux-x86_64/egg/trac/ticket/web_ui.py", line 656, in _process_ticket_request valid = self._validate_ticket(req, ticket, not valid) and valid File "build/bdist.linux-x86_64/egg/trac/ticket/web_ui.py", line 1363, in _validate_ticket for field, message in manipulator.validate_ticket(req, ticket): File "build/bdist.linux-x86_64/egg/ticketvalidator/core.py", line 48, in validate_ticket if self._is_empty(ticket[field_name])] File "build/bdist.linux-x86_64/egg/ticketvalidator/core.py", line 28, in _is_empty if len(value) == 0:
Attachments (0)
Change History (15)
comment:1 Changed 10 years ago by
Description: | modified (diff) |
---|
comment:2 Changed 10 years ago by
comment:3 Changed 10 years ago by
I am running Trac 1.1.3dev.
After looking through your code and my environment, it appears that there is an interesting issue with regard to the date/time formatting. In lue of an actual fix for the issue : Code of issue :
class RequiredFieldValidator(Component): """Basic ticket validator for required fields""" implements(ITicketManipulator) def _is_empty(self, value): """Check if 'value' is empty. :param value: the value to check :type value: object""" if value is None: return True if len(value) == 0: return True return False
Change I made in order to allow the date/time format currently being used :
class RequiredFieldValidator(Component): """Basic ticket validator for required fields""" implements(ITicketManipulator) def _is_empty(self, value): """Check if 'value' is empty. :param value: the value to check :type value: object""" if value is None: return True # if len(value) == 0: # return True return False
Once commented out, there are no additional issues whatsoever, I've spent the better part of the night testing, and found no instance in which it was an issue.
comment:5 Changed 10 years ago by
Owner: | changed from Max Stewart to Ryan J Ollos |
---|---|
Priority: | highest → normal |
Severity: | critical → normal |
Status: | new → accepted |
comment:8 Changed 10 years ago by
By removing the method, it appears to work correctly, however does not actually function as expected. It does no validation and allows for null required fields which is not the intended action. removing the len(value) however allows for validation with both plan text and date/time formatted input, which I think is the actual problem, since len(value) expects an integer, it doesn't see the date/time as anything but a "0" so returns true.
comment:9 Changed 10 years ago by
Personally speaking, I'd love this function to be a part of the core Trac ticketing system, however, it doesn't appear that it will ever be, which I think, is to there detriment. There should be "required" input give the status of a particular ticket.
comment:12 Changed 10 years ago by
After extensive testing, your changes work very well. date/time validation and/or select field input combination works really great. I've changed the template interface a bit locally, and will post the changes here, it just looks better and is more easily understood with what I've changed. feel free to use them if you'd like. And again, thank you very much for your assistance.
Original Template Code :
<legend>Rules</legend> <p class="hint"> State is the 'status' of the ticket when the specified fields are required. Fields is a comma separated list of required ticket properties. </p> <table> <thead> <tr> <th>State</th> <th>Fields</th>
Modified Template code :
<legend>Validator Rules</legend> <p class="hint"> <b>Status Change To</b> -- Is the 'status' of the ticket when the specified ticket properties, field(s) are to be required.</p> <p class="hint"> <b>Field(s) Required</b> -- Can be a comma separated list of required ticket properties, field(s) or a single ticket property or field requirement. </p> <table> <thead> <tr> <th><u>Status Changes to</u></th> <th><u>Field(s) Required</u></th>
comment:13 Changed 10 years ago by
Thanks, I'll look into your template changes. Do you know if #12121 is fixed now as well?
For future reference in creating patches, please see trac:TracDev/SubmittingPatches.
comment:15 Changed 10 years ago by
Resolution: | → fixed |
---|---|
Status: | accepted → closed |
Are you really running Trac 1.0? Or are you perhaps running 1.1.x?
What is the content of your
[ticketvalidator]
section in trac.ini?