<s> import logging <EOL> from django . conf import settings <EOL> from django . core import management <EOL> from django . contrib . contenttypes . models import ContentType <EOL> logger = logging . getLogger ( __name__ ) <EOL> try : <EOL> from celery import shared_task <EOL> except ImportError : <EOL> raise ImportError ( "<STR_LIT>" ) <EOL> @ shared_task ( ) <EOL> def publish_object ( content_type_pk , obj_pk ) : <EOL> """<STR_LIT>""" <EOL> ct = ContentType . objects . get_for_id ( content_type_pk ) <EOL> obj = ct . get_object_for_this_type ( pk = obj_pk ) <EOL> try : <EOL> logger . info ( "<STR_LIT>" % obj ) <EOL> obj . build ( ) <EOL> if not getattr ( settings , '<STR_LIT>' , True ) : <EOL> logger . info ( "<STR_LIT>" ) <EOL> else : <EOL> management . call_command ( "<STR_LIT>" ) <EOL> except Exception : <EOL> logger . error ( "<STR_LIT>" , exc_info = True ) <EOL> @ shared_task ( ) <EOL> def unpublish_object ( content_type_pk , obj_pk ) : <EOL> """<STR_LIT>""" <EOL> ct = ContentType . objects . get_for_id ( content_type_pk ) <EOL> obj = ct . get_object_for_this_type ( pk = obj_pk ) <EOL> try : <EOL> logger . info ( "<STR_LIT>" % obj ) <EOL> obj . unbuild ( ) <EOL> if not getattr ( settings , '<STR_LIT>' , True ) : <EOL> logger . info ( "<STR_LIT>" ) <EOL> else : <EOL> management . call_command ( "<STR_LIT>" ) <EOL> except Exception : <EOL> logger . error ( "<STR_LIT>" , exc_info = True ) </s>
