#NEWLINE# @ classmethod #NEWLINE# def create( cls , redis_conn , signature , event = None ) : #NEWLINE# #INDENT# 'Adds category metadata.\n\n        Args:\n            redis_conn: Redis connection to use.\n            signature: Signature of the new category.\n            event: Optional. Event to save under the new category.\n\n        This method will set 3 metadata fields for the category hash:\n        * category is the full text of the original cateory.\n        * verbose_name is the human readable name for this category (used for\n            display purposes)\n        * threshold is the custom threshold for this category\n\n        The key values are in the form {category_hash}:{metadata_name} e.g.\n        a909ede39c09d84ed1839c5ca0f9b9876113770b:category\n        ' #NEWLINE# redis_conn . zadd ( 'categories' , signature , 0 ) #NEWLINE# cat_id = cls . construct_cat_id ( signature ) #NEWLINE# cat_fields = ( ( cls . SIGNATURE_KEY , signature ) , ( cls . HUMAN_NAME_KEY , cat_id ) , ( cls . THRESHOLD_KEY , '' ) ) #NEWLINE# for ( key , value ) in cat_fields : #NEWLINE# #INDENT# redis_conn . hset ( cls . CAT_META_HASH , ( '%s:%s' % ( cat_id , key ) ) , value ) #NEWLINE# #UNINDENT# kwargs = { #NEWLINE# #INDENT# 'cat_id' : cat_id , #NEWLINE# #UNINDENT# } #NEWLINE# if event : #NEWLINE# #INDENT# kwargs [ 'event' ] = event #NEWLINE# #UNINDENT# return cls ( redis_conn , ** kwargs )