#17320: Sites.domain should not contain whitespace
-------------------------------------+-------------------------------------
Reporter: jnovinger | Owner:
Type: | krzysiumed
Cleanup/optimization | Status: assigned
Component: contrib.sites | Version: 1.3
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by krzysiumed):
* owner: nobody => krzysiumed
* needs_better_patch: 1 => 0
* status: new => assigned
Comment:
I'd implemented `clean` method instead of `clean_fields` - it's much more
simpler (you've not to call parent).
Another issue is that my implementation check if domain doesn't contain
spaces, but it doesn't check other whitespaces (for example '`\r`'). Is it
necessary?
If it is, we can do it in a few ways:
{{{
if self.domain != (self.domain.translate(None, string.whitespace)):
}}}
or
{{{
if all(map(lambda whitespace: whitespace not in self.domain,
string.whitespace)):
}}}
or
{{{
if all(map(lambda whitespace: self.domain.find(whitespace) == -1,
string.whitespaces)):
}}}
or
{{{
if re.search('\s', self.domain):
}}}
The first three are ugly. The last one is the best, but it's slow (the
pattern '\s' must be compiled each time - the solution is to cache
compiled pattern).
--
Ticket URL: <https://code.djangoproject.com/ticket/17320#comment:3>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--
You received this message because you are subscribed to the Google Groups
"Django updates" 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/django-updates?hl=en.