def getProvider(request=None, url=None): if(not url): url = getReferer(request) if(not url): return None c = CraigslistProvider(url) if(c.accept()): return c """ m = BaseProvider.__module__ for attr in dir(m): p = getattr(m, attr) if(p in BaseProvider.__subclasses__()) : pinstance = p(url) if(pinstance.accept()): return pinstance """ return None
def _getPostId(req): # get it from referer pd = provider.getProvider(req) if(pd): post_id = pd.getId() if(not post_id): raise Exception("Missing invitation ID and could not infer from referer %s provider: %s" %(getReferer(req), pd)) logger.debug("Obtained post id from referer %s" %post_id) return post_id