<s> import settings <EOL> from django import template <EOL> from django . contrib . comments . templatetags . comments import BaseCommentNode , CommentFormNode <EOL> register = template . Library ( ) <EOL> DEFAULT_UNAUTH_COMMENT_MESSAGE = getattr ( settings , '<STR_LIT>' , None ) or """<STR_LIT>""" <EOL> class RenderAuthCommentFormNode ( CommentFormNode ) : <EOL> """<STR_LIT>""" <EOL> def handle_token ( cls , parser , token ) : <EOL> """<STR_LIT>""" <EOL> tokens = token . contents . split ( ) <EOL> if tokens [ <NUM_LIT:1> ] != '<STR_LIT>' : <EOL> raise template . TemplateSyntaxError ( "<STR_LIT>" % tokens [ <NUM_LIT:0> ] ) <EOL> if len ( tokens ) == <NUM_LIT:3> : <EOL> return cls ( object_expr = parser . compile_filter ( tokens [ <NUM_LIT:2> ] ) ) <EOL> elif len ( tokens ) == <NUM_LIT:4> : <EOL> return cls ( <EOL> ctype = BaseCommentNode . lookup_content_type ( tokens [ <NUM_LIT:2> ] , tokens [ <NUM_LIT:0> ] ) , <EOL> object_pk_expr = parser . compile_filter ( tokens [ <NUM_LIT:3> ] ) <EOL> ) <EOL> handle_token = classmethod ( handle_token ) <EOL> def render ( self , context ) : <EOL> ctype , object_pk = self . get_target_ctype_pk ( context ) <EOL> if object_pk : <EOL> return """<STR_LIT>""" % ( ctype . app_label , ctype . model , <EOL> object_pk , DEFAULT_UNAUTH_COMMENT_MESSAGE ) <EOL> else : <EOL> return '<STR_LIT>' <EOL> def render_auth_comment_form ( parser , token ) : <EOL> """<STR_LIT>""" <EOL> return RenderAuthCommentFormNode . handle_token ( parser , token ) <EOL> register . tag ( render_auth_comment_form ) </s>
