本文整理汇总了Python中MaKaC.conference.LocalFile.setPDFConversionRequestDate方法的典型用法代码示例。如果您正苦于以下问题:Python LocalFile.setPDFConversionRequestDate方法的具体用法?Python LocalFile.setPDFConversionRequestDate怎么用?Python LocalFile.setPDFConversionRequestDate使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MaKaC.conference.LocalFile
的用法示例。
在下文中一共展示了LocalFile.setPDFConversionRequestDate方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _addMaterialType
# 需要导入模块: from MaKaC.conference import LocalFile [as 别名]
# 或者: from MaKaC.conference.LocalFile import setPDFConversionRequestDate [as 别名]
def _addMaterialType(self, text, user):
from MaKaC.common.fossilize import fossilize
from MaKaC.fossils.conference import ILocalFileExtendedFossil, ILinkFossil
Logger.get("requestHandler").debug("Adding %s - request %s" % (self._uploadType, request))
mat, newlyCreated = self._getMaterial()
# if the material still doesn't exist, create it
if newlyCreated:
protectedAtResourceLevel = False
else:
protectedAtResourceLevel = True
resources = []
if self._uploadType in ["file", "link"]:
if self._uploadType == "file":
for fileEntry in self._files:
resource = LocalFile()
resource.setFileName(fileEntry["fileName"])
resource.setFilePath(fileEntry["filePath"])
resource.setDescription(self._description)
if self._displayName == "":
resource.setName(resource.getFileName())
else:
resource.setName(self._displayName)
if not isinstance(self._target, Category):
log_msg = u"Added file {}{}".format(to_unicode(fileEntry["fileName"]), to_unicode(text))
self._target.getConference().log(
EventLogRealm.management, EventLogKind.positive, u"Material", log_msg, session.user
)
resources.append(resource)
# in case of db conflict we do not want to send the file to conversion again, nor re-store the file
elif self._uploadType == "link":
for link in self._links:
resource = Link()
resource.setURL(link["url"])
resource.setDescription(self._description)
if self._displayName == "":
resource.setName(resource.getURL())
else:
resource.setName(self._displayName)
if not isinstance(self._target, Category):
log_msg = u"Added link {}{}".format(to_unicode(resource.getURL()), to_unicode(text))
self._target.getConference().log(
EventLogRealm.management, EventLogKind.positive, u"Material", log_msg, session.user
)
resources.append(resource)
status = "OK"
info = resources
else:
status = "ERROR"
info = "Unknown upload type"
return mat, status, info
# forcedFileId - in case there is a conflict, use the file that is
# already stored
repoIDs = []
for i, resource in enumerate(resources):
if self._repositoryIds:
mat.addResource(resource, forcedFileId=self._repositoryIds[i])
else:
mat.addResource(resource, forcedFileId=None)
# apply conversion
if self._topdf and not isinstance(resource, Link):
file_ext = os.path.splitext(resource.getFileName())[1].strip().lower()
if fileConverter.CDSConvFileConverter.hasAvailableConversionsFor(file_ext):
fileConverter.CDSConvFileConverter.convert(resource.getFilePath(), "pdf", mat)
resource.setPDFConversionRequestDate(nowutc())
# store the repo id, for files
if isinstance(resource, LocalFile) and self._repositoryIds is None:
repoIDs.append(resource.getRepositoryId())
if protectedAtResourceLevel:
protectedObject = resource
else:
protectedObject = mat
mat.setHidden(self._visibility)
mat.setAccessKey(self._password)
protectedObject.setProtection(self._statusSelection)
for principal in map(principal_from_fossil, self._userList):
protectedObject.grantAccess(principal)
self._topdf = False
if self._repositoryIds is None:
self._repositoryIds = repoIDs
return (
mat,
status,
#.........这里部分代码省略.........
示例2: _addMaterialType
# 需要导入模块: from MaKaC.conference import LocalFile [as 别名]
# 或者: from MaKaC.conference.LocalFile import setPDFConversionRequestDate [as 别名]
def _addMaterialType(self, text, user):
from MaKaC.common.fossilize import fossilize
from MaKaC.fossils.conference import ILocalFileExtendedFossil, ILinkFossil
Logger.get('requestHandler').debug('Adding %s - request %s' % (self._uploadType, request))
mat, newlyCreated = self._getMaterial()
# if the material still doesn't exist, create it
if newlyCreated:
protectedAtResourceLevel = False
else:
protectedAtResourceLevel = True
resources = []
if self._uploadType in ['file','link']:
if self._uploadType == "file":
for fileEntry in self._files:
resource = LocalFile()
resource.setFileName(fileEntry["fileName"])
resource.setFilePath(fileEntry["filePath"])
resource.setDescription(self._description)
if self._displayName == "":
resource.setName(resource.getFileName())
else:
resource.setName(self._displayName)
if not type(self._target) is Category:
log_info = {"subject":"Added file %s%s" % (fileEntry["fileName"], text)}
self._target.getConference().getLogHandler().logAction(log_info, log.ModuleNames.MATERIAL)
resources.append(resource)
# in case of db conflict we do not want to send the file to conversion again, nor re-store the file
elif self._uploadType == "link":
for link in self._links:
resource = Link()
resource.setURL(link["url"])
resource.setDescription(self._description)
if self._displayName == "":
resource.setName(resource.getURL())
else:
resource.setName(self._displayName)
if not type(self._target) is Category:
log_info = {"subject":"Added link %s%s" % (resource.getURL(), text)}
self._target.getConference().getLogHandler().logAction(log_info, log.ModuleNames.MATERIAL)
resources.append(resource)
status = "OK"
info = resources
else:
status = "ERROR"
info = "Unknown upload type"
return mat, status, info
# forcedFileId - in case there is a conflict, use the file that is
# already stored
repoIDs = []
for i, resource in enumerate(resources):
if self._repositoryIds:
mat.addResource(resource, forcedFileId=self._repositoryIds[i])
else:
mat.addResource(resource, forcedFileId=None)
#apply conversion
if self._topdf and not isinstance(resource, Link):
file_ext = os.path.splitext(resource.getFileName())[1].strip().lower()
if fileConverter.CDSConvFileConverter.hasAvailableConversionsFor(file_ext):
# Logger.get('conv').debug('Queueing %s for conversion' % resource.getFilePath())
fileConverter.CDSConvFileConverter.convert(resource.getFilePath(), 'pdf', mat)
resource.setPDFConversionRequestDate(nowutc())
# store the repo id, for files
if isinstance(resource, LocalFile) and self._repositoryIds is None:
repoIDs.append(resource.getRepositoryId())
if protectedAtResourceLevel:
protectedObject = resource
else:
protectedObject = mat
mat.setHidden(self._visibility)
mat.setAccessKey(self._password)
protectedObject.setProtection(self._statusSelection)
for userElement in self._userList:
if 'isGroup' in userElement and userElement['isGroup']:
avatar = GroupHolder().getById(userElement['id'])
else:
avatar = AvatarHolder().getById(userElement['id'])
protectedObject.grantAccess(avatar)
self._topdf = False
if self._repositoryIds is None:
self._repositoryIds = repoIDs
return mat, status, fossilize(info, {"MaKaC.conference.Link": ILinkFossil,
"MaKaC.conference.LocalFile": ILocalFileExtendedFossil})