def initiate():
"""
1. step
Initiate app installation
"""
args = request.args
# get shop url from args
shop_url = args.get('shop')
# TODO: validate HMAC, so we know that request really is from shopify
if not current_user.is_authenticated:
return redirect(url_for('main.signup', next=url_join(request.host_url,
url_for('shopify.initiate',
shop=shop_url))))
api_key = current_app.config['SHOPIFY_API_KEY']
secret = current_app.config['SHOPIFY_API_SECRET']
url = get_permission_url(shop_url, api_key, secret)
return redirect(url)
python类url_join()的实例源码
def test_url_joining(self):
self.assert_strict_equal(urls.url_join('/foo', '/bar'), '/bar')
self.assert_strict_equal(urls.url_join('http://example.com/foo', '/bar'),
'http://example.com/bar')
self.assert_strict_equal(urls.url_join('file:///tmp/', 'test.html'),
'file:///tmp/test.html')
self.assert_strict_equal(urls.url_join('file:///tmp/x', 'test.html'),
'file:///tmp/test.html')
self.assert_strict_equal(urls.url_join('file:///tmp/x', '../../../x.html'),
'file:///x.html')