本文整理汇总了Python中tendenci.libs.boto_s3.utils.set_s3_file_permission函数的典型用法代码示例。如果您正苦于以下问题:Python set_s3_file_permission函数的具体用法?Python set_s3_file_permission怎么用?Python set_s3_file_permission使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了set_s3_file_permission函数的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: save
def save(self, *args, **kwargs):
if not self.id:
self.guid = str(uuid.uuid1())
self.assign_release_dt_local()
photo_upload = kwargs.pop('photo', None)
super(News, self).save(*args, **kwargs)
if photo_upload and self.pk:
image = NewsImage(
object_id=self.pk,
creator=self.creator,
creator_username=self.creator_username,
owner=self.owner,
owner_username=self.owner_username
)
photo_upload.file.seek(0)
image.file.save(photo_upload.name, photo_upload) # save file row
image.save() # save image row
if self.thumbnail:
self.thumbnail.delete() # delete image and file row
self.thumbnail = image # set image
self.save()
if self.thumbnail:
if self.is_public():
set_s3_file_permission(self.thumbnail.file, public=True)
else:
set_s3_file_permission(self.thumbnail.file, public=False)
开发者ID:MariusCC,项目名称:tendenci,代码行数:31,代码来源:models.py
示例2: save
def save(self, *args, **kwargs):
super(NewsletterTemplate, self).save(*args, **kwargs)
if self.html_file:
set_s3_file_permission(self.html_file.file, public=True)
if self.zip_file:
set_s3_file_permission(self.zip_file.file, public=True)
#extract and serve files in zip
extract_files(self)
开发者ID:dco5,项目名称:tendenci,代码行数:8,代码来源:models.py
示例3: save
def save(self, *args, **kwargs):
if not self.guid:
self.guid = str(uuid.uuid1())
super(BasePage, self).save(*args, **kwargs)
if self.header_image:
if self.is_public():
set_s3_file_permission(self.header_image.file, public=True)
else:
set_s3_file_permission(self.header_image.file, public=False)
开发者ID:repos-python,项目名称:tendenci,代码行数:9,代码来源:models.py
示例4: save
def save(self, *args, **kwargs):
if not self.id:
self.guid = str(uuid.uuid1())
super(Image, self).save(*args, **kwargs)
# # clear the cache
# caching.instance_cache_clear(self, self.pk)
# caching.cache_clear(PHOTOS_KEYWORDS_CACHE, key=self.pk)
# # re-add instance to the cache
# caching.instance_cache_add(self, self.pk)
if not self.is_public_photo() or not self.is_public_photoset():
set_s3_file_permission(self.image.file, public=False)
cache_set = cache.get("photos_cache_set.%s" % self.pk)
if cache_set is not None:
# TODO remove cached images
cache.delete_many(cache.get("photos_cache_set.%s" % self.pk))
cache.delete("photos_cache_set.%s" % self.pk)
开发者ID:eltonhoxha,项目名称:tendenci,代码行数:18,代码来源:models.py
示例5: save
def save(self, *args, **kwargs):
created = False
if not self.id:
self.guid = str(uuid.uuid4())
created = True
self.f_type = self.type()
if not self.group:
self.group_id = get_default_group()
super(File, self).save(*args, **kwargs)
if self.is_public_file():
set_s3_file_permission(self.file, public=True)
else:
set_s3_file_permission(self.file, public=False)
cache_set = cache.get("files_cache_set.%s" % self.pk)
if cache_set is not None:
# TODO remove cached images
cache.delete_many(cache.get("files_cache_set.%s" % self.pk))
cache.delete("files_cache_set.%s" % self.pk)
# send notification to administrator(s) and module recipient(s)
if created:
recipients = get_notice_recipients('module', 'files', 'filerecipients')
site_display_name = get_setting('site', 'global', 'sitedisplayname')
site_url = get_setting('site', 'global', 'siteurl')
if recipients and notification:
notification_params = {
'object': self,
'SITE_GLOBAL_SITEDISPLAYNAME': site_display_name,
'SITE_GLOBAL_SITEURL': site_url,
}
if self.owner:
notification_params['author'] = self.owner.get_full_name() or self.owner
notification.send_emails(recipients, 'file_added', notification_params)
开发者ID:tendenci,项目名称:tendenci,代码行数:40,代码来源:models.py
示例6: handle
def handle(self, *apps, **kwargs):
from tendenci.core.files.models import File as tFile
from tendenci.libs.boto_s3.utils import set_s3_file_permission
files = tFile.objects.all()
count = 0
for tfile in files:
if tfile.file:
if tfile.allow_anonymous_view:
perm = 'public'
else:
perm = 'private'
print 'Setting %s to %s' % (tfile.file.name,
perm)
set_s3_file_permission(tfile.file.name,
public=(perm == 'public'))
count += 1
print 'Done'
print 'Total files processed', count
开发者ID:DeepInTheCode,项目名称:tendenci,代码行数:22,代码来源:set_media_files_perms.py
示例7: details
#.........这里部分代码省略.........
# if string and digit convert to integer
if isinstance(quality, basestring) and quality.isdigit():
quality = int(quality)
# get image binary
try:
data = file.file.read()
file.file.close()
except IOError: # no such file or directory
raise Http404
if download: # log download
attachment = u'attachment;'
EventLog.objects.log(**{
'event_id': 185000,
'event_data': '%s %s (%d) dowloaded by %s' % (file.type(), file._meta.object_name, file.pk, request.user),
'description': '%s downloaded' % file._meta.object_name,
'user': request.user,
'request': request,
'instance': file,
})
else: # log view
attachment = u''
if file.type() != 'image':
EventLog.objects.log(**{
'event_id': 186000,
'event_data': '%s %s (%d) viewed by %s' % (file.type(), file._meta.object_name, file.pk, request.user),
'description': '%s viewed' % file._meta.object_name,
'user': request.user,
'request': request,
'instance': file,
})
# if image size specified
if file.type() == 'image' and size: # if size specified
if file.ext() in ('.tif', '.tiff'):
raise Http404 # tifs cannot (currently) be viewed via browsers
size = [int(s) if s.isdigit() else 0 for s in size.split('x')]
size = aspect_ratio(file.image_dimensions(), size, constrain)
# check for dimensions
# greater than zero
if not all(size):
raise Http404
# gets resized image from cache or rebuilds
image = get_image(file.file, size, FILE_IMAGE_PRE_KEY, cache=True, crop=crop, quality=quality, unique_key=None)
response = HttpResponse(content_type=file.mime_type())
response['Content-Disposition'] = '%s filename=%s' % (attachment, file.get_name())
params = {'quality': quality}
if image.format == 'GIF':
params['transparency'] = 0
image.save(response, image.format, **params)
if file.is_public_file():
file_name = "%s%s" % (file.get_name(), ".jpg")
file_path = 'cached%s%s' % (request.path, file_name)
default_storage.delete(file_path)
default_storage.save(file_path, ContentFile(response.content))
full_file_path = "%s%s" % (settings.MEDIA_URL, file_path)
cache.set(cache_key, full_file_path)
cache_group_key = "files_cache_set.%s" % file.pk
cache_group_list = cache.get(cache_group_key)
if cache_group_list is None:
cache.set(cache_group_key, [cache_key])
else:
cache_group_list += [cache_key]
cache.set(cache_group_key, cache_group_list)
return response
if file.is_public_file():
cache.set(cache_key, file.get_file_public_url())
set_s3_file_permission(file.file, public=True)
cache_group_key = "files_cache_set.%s" % file.pk
cache_group_list = cache.get(cache_group_key)
if cache_group_list is None:
cache.set(cache_group_key, [cache_key])
else:
cache_group_list += cache_key
cache.set(cache_group_key, cache_group_list)
# set mimetype
if file.mime_type():
response = HttpResponse(data, content_type=file.mime_type())
else:
raise Http404
# return response
if file.get_name().endswith(file.ext()):
response['Content-Disposition'] = '%s filename=%s' % (attachment, file.get_name())
else:
response['Content-Disposition'] = '%s filename=%s' % (attachment, file.get_name_ext())
return response
开发者ID:BIGGANI,项目名称:tendenci,代码行数:101,代码来源:views.py
示例8: save
def save(self, *args, **kwargs):
super(Template, self).save(*args, **kwargs)
if self.html_file:
set_s3_file_permission(self.html_file.file, public=True)
if self.zip_file:
set_s3_file_permission(self.zip_file.file, public=True)
开发者ID:repos-python,项目名称:tendenci,代码行数:6,代码来源:models.py
注:本文中的tendenci.libs.boto_s3.utils.set_s3_file_permission函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论