本文整理汇总了Python中requests.Session.cookies['_session_id']方法的典型用法代码示例。如果您正苦于以下问题:Python Session.cookies['_session_id']方法的具体用法?Python Session.cookies['_session_id']怎么用?Python Session.cookies['_session_id']使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类requests.Session
的用法示例。
在下文中一共展示了Session.cookies['_session_id']方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: read
# 需要导入模块: from requests import Session [as 别名]
# 或者: from requests.Session import cookies['_session_id'] [as 别名]
def read(self, sg):
"""Read the raw public and private schemas from Shotgun.
:param sg: The ``shotgun_api3.Shotgun`` instance to read the schema from.
This reads the schema via ``Shotgun.schema_read()`` and
``Shotgun.schema_entity_read()``, as well as the "private" schema
embedded into the Javascript of the Shotgun website.
The raw schemas are then reduced, retaining only data types, and
other info required for SGSchema's operations. It may be required
to re-read (and cache) schema data as SGSchema is improved.
"""
# Most of the time we don't need this, so don't bother importing.
from requests import Session
# SG.schema_field_read() is the same data per-entity as SG.schema_read().
# SG.schema_entity_read() contains global name and visibility of each
# entity type, but the visibility is likely to just be True for everything.
self.raw_fields = sg.schema_read()
self.raw_entities = sg.schema_entity_read()
# We also want the private schema which drives the website.
# See <http://mikeboers.com/blog/2015/07/21/a-complete-shotgun-schema>.
session = Session()
session.cookies['_session_id'] = sg.get_session_token()
js = session.get(sg.base_url + '/page/schema').text
encoded = js.splitlines()[0]
m = re.match(r'^SG\.schema = new SG\.Schema\((.+)\);\s*$', encoded)
if not m:
raise ValueError('schema does not appear to be at %s/page/schema' % sg.base_url)
self.raw_private = json.loads(m.group(1))
self._reduce_raw()