def handle_pingback_request(source_uri, target_uri): """This method is exported via XMLRPC as `pingback.ping` by the pingback API. """ app = get_application() # next we check if the source URL does indeed exist try: response = open_url(source_uri) except NetException: raise Fault(16, "The source URL does not exist.") # we only accept pingbacks for links below our blog URL blog_url = app.cfg["blog_url"] if not blog_url.endswith("/"): blog_url += "/" if not target_uri.startswith(blog_url): raise Fault(32, "The specified target URL does not exist.") path_info = target_uri[len(blog_url) :] handler = endpoint = values = None while 1: try: endpoint, values = app.url_adapter.match(path_info) except RequestRedirect, e: path_info = e.new_url[len(blog_url) :] except NotFound, e: break
def handle_pingback_request(source_uri, target_uri): """This method is exported via XMLRPC as `pingback.ping` by the pingback API. """ app = get_application() # next we check if the source URL does indeed exist try: response = open_url(source_uri) except NetException: raise Fault(16, 'The source URL does not exist.') # we only accept pingbacks for links below our blog URL blog_url = app.cfg['blog_url'] if not blog_url.endswith('/'): blog_url += '/' if not target_uri.startswith(blog_url): raise Fault(32, 'The specified target URL does not exist.') path_info = target_uri[len(blog_url):] handler = endpoint = values = None while 1: try: endpoint, values = app.url_adapter.match(path_info) except RequestRedirect, e: path_info = e.new_url[len(blog_url):] except NotFound, e: break
def get_analytics_account(): """Return the Google Analytics account id for the current application or `None` if there is no key or the key is invalid. """ app = get_application() key = app.cfg['analytics/account'] if key and check(is_valid_account_id, key, memorize=True): return key
def validate(form, account): # TODO: cache the account id by querying google analytics itself # to make sure account is valid blog_url = get_application().cfg['blog_url'] cachekey = (account, blog_url) if cachekey in _verified_accounts: return if not account: raise ValidationError(message) if memorize: _verified_accounts.add(cachekey)