As I was looking through my settings.py file in my current project, I realized I wasn't too sure what was really going on under the hood with python in terms of os.path.join
I tried looking it up, but its a bit confusing - and seems a bit esoteric when you delve deep.
So lets take the following example:
os.path.join(PROJECT_DIR, 'templates'),
Some points I'd like answered from this example:
1. What exactly is os.path.join doing here? What exactly is being joined?
2.What is PROJECT_DIR? Where was PROJECT_DIR set and how does PROJECT_DIR itself point to the project directory all the time, regardless of its location(on a server, locally, etc)?
Now lets consider this example (which I took from my friend), that makes it the case that when I run on a server(ON_OPENSHIFT seems to be my host) I use a particular static directory:
if ON_OPENSHIFT:
STATICFILES_DIRS = (
# Put strings here, like "/home/html/static" or "C:/www/django/static".
# Always use forward slashes, even on Windows.
# Don't forget to use absolute paths, not relative paths.
)
else:
STATICFILES_DIRS = (
# Put strings here, like "/home/html/static" or "C:/www/django/static".
# Always use forward slashes, even on Windows.
# Don't forget to use absolute paths, not relative paths.
'/Users/tom/candycode/wsgi/static',
)
Some questions I'd like answered from this example:
Where is ON_OPENSHIFT defined?
How come on local (the else part of the statement) there seems to be a local directory absolue path, but why not use some type of dynamically ascertained path (like the os.path.join stuff)?
Why does the ON_OPENSHIFT not need to specify a static directory? How does it just "know"? Seems like some type of magic is going on.