Tuesday, November 30, 2010

Re: Where's the form value set for comments framework/app

I looked into the code again and think I've found where the values
come from.

class CommentFormNode(BaseCommentNode):
"""Insert a form for the comment model into the context."""
...
return comments.get_form()
(ctype.get_object_for_this_type(pk=object_pk))

The comments.get_form() will return a CommentForm, which is a child
class of CommentSecurityForm from django.contrib.comments.form

class CommentSecurityForm(forms.Form):
...
def generate_security_data(self):
...
security_dict = {
'content_type' : str(self.target_object._meta),
'object_pk' : str(self.target_object._get_pk_val()),
'timestamp' : str(timestamp),
'security_hash' : self.initial_security_hash(timestamp),
}

So the content_type value is from target_object._meta

On Nov 30, 4:31 pm, photon <photo...@gmail.com> wrote:
> Mostly I followed the instruction ofhttp://docs.djangoproject.com/en/dev/ref/contrib/comments/

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to django-users+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

No comments:

Post a Comment