From 85981abf58a7645bafdd8670c5e1ed4cffd6bc46 Mon Sep 17 00:00:00 2001 From: Hidden Z Date: Wed, 6 Oct 2010 19:02:08 +0000 Subject: [PATCH] postkey/views.py: add docstrings --- web/postkey/views.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/web/postkey/views.py b/web/postkey/views.py index e243da2..4a92a0f 100644 --- a/web/postkey/views.py +++ b/web/postkey/views.py @@ -8,6 +8,10 @@ from web.postkey.models import i2phost import re class AddForm(ModelForm): + """ + This is our class for host-add form. It's based on django's ModelForm + and uses our model "i2phost" (see postkey/models.py) + """ class Meta: model = i2phost fields = ('name', 'b64hash', 'description') @@ -17,6 +21,10 @@ class AddForm(ModelForm): 'description': forms.Textarea(attrs={'rows': '2', 'cols': '72'}) } def clean_name(self): + """ + Here we do additional hostname validation as described in + http://www.i2p2.i2p/naming.html + """ data = self.cleaned_data['name'] # convert hostname to lowercase data = data.lower() @@ -46,6 +54,9 @@ class AddForm(ModelForm): raise forms.ValidationError('Trying to use reserved hostname') return data def clean_b64hash(self): + """ + Base64 hash validation + """ data = self.cleaned_data['b64hash'] # Minimum key length 516 bytes if len(data) < 516: