Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
D
django-pyfs
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
OpenEdx
django-pyfs
Commits
59a472a0
Commit
59a472a0
authored
Sep 26, 2017
by
Brian Mesick
Committed by
GitHub
Sep 26, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Move model import down into methods (#11)
Work around import issues in Django 1.11 when djpyfs is imported early.
parent
9cb3dde2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
7 additions
and
7 deletions
+7
-7
djpyfs/djpyfs.py
+6
-6
setup.py
+1
-1
No files found.
djpyfs/djpyfs.py
View file @
59a472a0
...
@@ -5,8 +5,8 @@ functionality:
...
@@ -5,8 +5,8 @@ functionality:
1) Django configuration. This can go to Amazon S3 or a static
1) Django configuration. This can go to Amazon S3 or a static
filesystem.
filesystem.
2) The ability to get URLs for objects stored on the filesystem.
2) The ability to get URLs for objects stored on the filesystem.
3) The ability to create objects with a limited lifetime. A
3) The ability to create objects with a limited lifetime. A
task can garbage-collect those objects.
task can garbage-collect those objects.
"""
"""
from
__future__
import
absolute_import
from
__future__
import
absolute_import
...
@@ -20,14 +20,12 @@ from django.conf import settings
...
@@ -20,14 +20,12 @@ from django.conf import settings
from
fs.osfs
import
OSFS
from
fs.osfs
import
OSFS
from
fs.s3fs
import
S3FS
from
fs.s3fs
import
S3FS
from
.models
import
FSExpirations
if
hasattr
(
settings
,
'DJFS'
):
if
hasattr
(
settings
,
'DJFS'
):
DJFS_SETTINGS
=
settings
.
DJFS
# pragma: no cover
DJFS_SETTINGS
=
settings
.
DJFS
# pragma: no cover
else
:
else
:
DJFS_SETTINGS
=
{
'type'
:
'osfs'
,
DJFS_SETTINGS
=
{
'type'
:
'osfs'
,
'directory_root'
:
'django-pyfs/static/django-pyfs'
,
'directory_root'
:
'django-pyfs/static/django-pyfs'
,
'url_root'
:
'/static/django-pyfs'
}
'url_root'
:
'/static/django-pyfs'
}
# Global to hold the active S3 connection. Prevents needing to reconnect
# Global to hold the active S3 connection. Prevents needing to reconnect
...
@@ -56,6 +54,7 @@ def expire_objects():
...
@@ -56,6 +54,7 @@ def expire_objects():
"""
"""
Remove all obsolete objects from the file systems.
Remove all obsolete objects from the file systems.
"""
"""
from
.models
import
FSExpirations
objects
=
sorted
(
FSExpirations
.
expired
(),
key
=
lambda
x
:
x
.
module
)
objects
=
sorted
(
FSExpirations
.
expired
(),
key
=
lambda
x
:
x
.
module
)
fs
=
None
fs
=
None
module
=
None
module
=
None
...
@@ -97,6 +96,7 @@ def patch_fs(fs, namespace, url_method):
...
@@ -97,6 +96,7 @@ def patch_fs(fs, namespace, url_method):
Returns:
Returns:
None
None
"""
"""
from
.models
import
FSExpirations
FSExpirations
.
create_expiration
(
namespace
,
filename
,
seconds
,
days
=
days
,
expires
=
expires
)
FSExpirations
.
create_expiration
(
namespace
,
filename
,
seconds
,
days
=
days
,
expires
=
expires
)
fs
.
expire
=
types
.
MethodType
(
expire
,
fs
)
fs
.
expire
=
types
.
MethodType
(
expire
,
fs
)
...
@@ -153,7 +153,7 @@ def get_s3fs(namespace):
...
@@ -153,7 +153,7 @@ def get_s3fs(namespace):
"""
"""
global
S3CONN
global
S3CONN
try
:
try
:
if
not
S3CONN
:
if
not
S3CONN
:
S3CONN
=
S3Connection
(
aws_access_key_id
=
key_id
,
aws_secret_access_key
=
key_secret
)
S3CONN
=
S3Connection
(
aws_access_key_id
=
key_id
,
aws_secret_access_key
=
key_secret
)
return
S3CONN
.
generate_url
(
return
S3CONN
.
generate_url
(
...
...
setup.py
View file @
59a472a0
...
@@ -12,7 +12,7 @@ else:
...
@@ -12,7 +12,7 @@ else:
setup
(
setup
(
name
=
'django-pyfs'
,
name
=
'django-pyfs'
,
version
=
'1.0.
6
'
,
version
=
'1.0.
7
'
,
description
=
'Django pyfilesystem integration'
,
description
=
'Django pyfilesystem integration'
,
author
=
'Piotr Mitros'
,
author
=
'Piotr Mitros'
,
author_email
=
'pmitros@edx.org'
,
author_email
=
'pmitros@edx.org'
,
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment