def valid_subscribers(self, model, obj, using):
col_user_ids = {}<EOL>col_connection_ids = collections.defaultdict(set)<EOL>for sub in Subscription.objects.filter(<EOL>collections__model_name=model_name(model),<EOL>).prefetch_related('<STR_LIT>'):<EOL><INDENT>pub = self.get_pub_by_name(sub.publication)<EOL>try:<EOL><INDENT>queries = list(pub.user_queries(sub.user, *sub.params))<EOL><DEDENT>except Exception:<EOL><INDENT>queries = []<EOL><DEDENT>for qs, col in (<EOL>self.qs_and_collection(qs)<EOL>for qs<EOL>in queries<EOL>):<EOL><INDENT>if qs.model is not model:<EOL><INDENT>continue  <EOL><DEDENT>if not qs.filter(pk=obj.pk).exists():<EOL><INDENT>continue  <EOL><DEDENT>try:<EOL><INDENT>user_ids = col_user_ids[col.__class__]<EOL><DEDENT>except KeyError:<EOL><INDENT>user_ids = col_user_ids[col.__class__] =col.user_ids_for_object(obj)<EOL><DEDENT>if user_ids is None:<EOL><INDENT>pass  <EOL><DEDENT>elif sub.user_id not in user_ids:<EOL><INDENT>continue  <EOL><DEDENT>col_connection_ids[col].add(sub.connection_id)<EOL><DEDENT><DEDENT>return col_connection_ids<EOL>
Calculate valid subscribers (connections) for obj.