当前位置: 首页>>代码示例>>Python>>正文


Python IMasterStore.date_created方法代码示例

本文整理汇总了Python中lp.services.database.interfaces.IMasterStore.date_created方法的典型用法代码示例。如果您正苦于以下问题:Python IMasterStore.date_created方法的具体用法?Python IMasterStore.date_created怎么用?Python IMasterStore.date_created使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在lp.services.database.interfaces.IMasterStore的用法示例。


在下文中一共展示了IMasterStore.date_created方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_headers

# 需要导入模块: from lp.services.database.interfaces import IMasterStore [as 别名]
# 或者: from lp.services.database.interfaces.IMasterStore import date_created [as 别名]
    def test_headers(self):
        client = LibrarianClient()

        # Upload a file so we can retrieve it.
        sample_data = 'blah'
        file_alias_id = client.addFile(
            'sample', len(sample_data), StringIO(sample_data),
            contentType='text/plain')
        url = client.getURLForAlias(file_alias_id)

        # Change the date_created to a known value that doesn't match
        # the disk timestamp. The timestamp on disk cannot be trusted.
        file_alias = IMasterStore(LibraryFileAlias).get(
            LibraryFileAlias, file_alias_id)
        file_alias.date_created = datetime(
            2001, 01, 30, 13, 45, 59, tzinfo=pytz.utc)

        # Commit so the file is available from the Librarian.
        self.commit()

        # Fetch the file via HTTP, recording the interesting headers
        result = urlopen(url)
        last_modified_header = result.info()['Last-Modified']
        cache_control_header = result.info()['Cache-Control']

        # URLs point to the same content for ever, so we have a hardcoded
        # 1 year max-age cache policy.
        self.failUnlessEqual(cache_control_header, 'max-age=31536000, public')

        # And we should have a correct Last-Modified header too.
        self.failUnlessEqual(
            last_modified_header, 'Tue, 30 Jan 2001 13:45:59 GMT')
开发者ID:pombreda,项目名称:UnnaturalCodeFork,代码行数:34,代码来源:test_web.py

示例2: test_restricted_file_headers

# 需要导入模块: from lp.services.database.interfaces import IMasterStore [as 别名]
# 或者: from lp.services.database.interfaces.IMasterStore import date_created [as 别名]
 def test_restricted_file_headers(self):
     fileAlias, url = self.get_restricted_file_and_public_url()
     token = TimeLimitedToken.allocate(url)
     url = url + "?token=%s" % token
     # Change the date_created to a known value for testing.
     file_alias = IMasterStore(LibraryFileAlias).get(
         LibraryFileAlias, fileAlias)
     file_alias.date_created = datetime(
         2001, 01, 30, 13, 45, 59, tzinfo=pytz.utc)
     # Commit the update.
     self.commit()
     # Fetch the file via HTTP, recording the interesting headers
     result = urlopen(url)
     last_modified_header = result.info()['Last-Modified']
     cache_control_header = result.info()['Cache-Control']
     # No caching for restricted files.
     self.failUnlessEqual(cache_control_header, 'max-age=0, private')
     # And we should have a correct Last-Modified header too.
     self.failUnlessEqual(
         last_modified_header, 'Tue, 30 Jan 2001 13:45:59 GMT')
开发者ID:pombreda,项目名称:UnnaturalCodeFork,代码行数:22,代码来源:test_web.py


注:本文中的lp.services.database.interfaces.IMasterStore.date_created方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。