Skip to content
Snippets Groups Projects
Commit 57dc0a95 authored by Sagar Kohli's avatar Sagar Kohli
Browse files

updated listname error

updated the error apearing at the time of creating a new list, checks the listname_chars from the mailman core over REST, depends on two MRs, one in the mailman core and second in the mailmanclient.
parent 80ce3d92
No related branches found
No related tags found
No related merge requests found
......@@ -24,6 +24,7 @@ from django.core.validators import validate_email
from django.utils.encoding import smart_text
from django.utils.translation import ugettext_lazy as _
from django.utils.version import get_complete_version
from django_mailman3.lib.mailman import get_mailman_client
from django.contrib.sites.models import Site
import re
......@@ -176,7 +177,10 @@ class ListNew(forms.Form):
# "before you will be able to create a list")
def clean_listname(self):
_valid_listname = re.compile('[-_.0-9a-z]', re.IGNORECASE)
client = get_mailman_client()
_listname_chars = client.configuration['mailman'].get('listname_chars')
print (_listname_chars)
_valid_listname = re.compile(_listname_chars, re.IGNORECASE)
  • Sagar Kohli @sagar-kohli ·
    Author

    @msapiro Writing the whole bunch of code all over again is not giving me nice feeling, so what i was thinking is why not re.complie only with [-_.+=!$*{}~0-9a-z] chars and let mailman do the other validation check at the time of list creation, the same way it respond the error Mailing list exists. We just need to create one more exception InvalidListNameError in AllLists class at rest/lists.py in mailman core. What do you think?

    And sir what errors could be possible other than Mailing list exist and invalid list name at the time creation of list.?

    Edited by Sagar Kohli
  • Sagar Kohli @sagar-kohli ·
    Author

    and if i let the changes remain the same as before in postorius and make core changes that u did. and then make a new list sagar/kohli, Im getting an HTTP Error 500: A server error occurred. Please contact the administrator. error . which doesnt seems to be appropriate.

    Edited by Sagar Kohli
  • Owner

    With respect to your first point, I said in the begining the the thing to do is create the list and let core respond that it can't be done without trying to second-guess what core will or won't accept.

    As far as what core can say, the docstring at mailman/app/lifecycle.py under create_list says

        :raises BadDomainSpecificationError: when the hostname part of
            `fqdn_listname` does not exist.
        :raises ListAlreadyExistsError: when the mailing list already exists.
        :raises InvalidEmailAddressError: when the fqdn email address is invalid.
        :raises InvalidListNameError: when the fqdn email address is valid but the
            listname contains disallowed characters.

    As you point out, my MR is incomplete in that there are now two possible exceptions that aren't caught in rest.lists.AllLists, namely InvalidEmailAddressError and InvalidListNameError. I will update my MR. I expect the fact that neither is caught is probably the reason for your 500 error which we clearly don't want.

    Edited by Mark Sapiro
  • Owner

    I have updated mailman!248 (merged). With that installed in core, you should see reasonable errors, not 500's for bad list names.

  • Sagar Kohli @sagar-kohli ·
    Author

    @msapiro thanx for clearing my doubt, sir its quite a nice learning experience with you.

  • Sagar Kohli @sagar-kohli ·
    Author

    @msapiro please check nw. Nw i think this should be perfect.
    Covers:
    .

    1. Help_text
    2. valid Error displayed at the form site
    3. removed invalid characters that should not be supported by mailman
    Edited by Sagar Kohli
  • Please register or sign in to reply
if len(_valid_listname.sub('', self.cleaned_data['listname']))>0:
raise forms.ValidationError(_('List name must not contain spaces or anything other than letters, '
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment