mirror of
https://github.com/jazzband/django-dbtemplates.git
synced 2026-03-16 22:20:28 +00:00
again: refactoring as a standalone application
git-svn-id: https://django-dbtemplates.googlecode.com/svn/trunk@13 cfb8ba98-e953-0410-9cff-959ffddf5974 committer: leidel <leidel@cfb8ba98-e953-0410-9cff-959ffddf5974> --HG-- extra : convert_revision : 7974964ff8ace563a81a23cd6308934a2461e5fb
This commit is contained in:
parent
bbc00a779b
commit
e59bb89f6c
8 changed files with 56 additions and 23 deletions
15
INSTALL
Normal file
15
INSTALL
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
To install it, run the following command inside this directory:
|
||||
|
||||
python setup.py install
|
||||
|
||||
Or if you'd prefer you can simply place the included ``dbtemplates``
|
||||
directory somewhere on your Python path, or symlink to it from
|
||||
somewhere on your Python path; this is useful if you're working from a
|
||||
Subversion checkout.
|
||||
|
||||
Note that this application requires Python 2.3 or later, and a recent
|
||||
Subversion checkout of Django. You can obtain Python from
|
||||
http://www.python.org/ and Django from http://www.djangoproject.com/.
|
||||
|
||||
This install notice was bluntly stolen from James Bennett's registration
|
||||
package, http://code.google.com/p/django-registration/
|
||||
4
MANIFEST.in
Normal file
4
MANIFEST.in
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
include INSTALL
|
||||
include LICENSE
|
||||
include MANIFEST.in
|
||||
include README
|
||||
16
README
16
README
|
|
@ -1,3 +1,4 @@
|
|||
===================================
|
||||
Database template loader for Django
|
||||
===================================
|
||||
|
||||
|
|
@ -8,11 +9,10 @@ How to use it in your own django application
|
|||
============================================
|
||||
|
||||
0. Get the source from the subversion repository
|
||||
1. Copy the "template" directory to your django project directory
|
||||
2. Edit your settings.py:
|
||||
1. Follow the instructions in the INSTALL file
|
||||
2. Edit the settings.py of your Django project:
|
||||
|
||||
# Add ``myapp.template`` to the ``INSTALLED_APPS`` where "myapp" is the
|
||||
name of your django project
|
||||
# Add ``dbtemplates`` to the ``INSTALLED_APPS`` of your django project
|
||||
|
||||
# Check if ``django.contrib.sites`` and ``django.contrib.admin`` are in
|
||||
``INSTALLED_APPS`` and add if necessary
|
||||
|
|
@ -26,19 +26,19 @@ How to use it in your own django application
|
|||
'django.contrib.sites',
|
||||
'django.contrib.admin',
|
||||
'django.contrib.flatpages',
|
||||
'dbtemplates',
|
||||
'myapp.blog',
|
||||
'myapp.template',
|
||||
)
|
||||
|
||||
# Add ``myapp.template.loaders.database.load_template_source`` to the
|
||||
``TEMPLATE_LOADERS`` where "myapp" is the name of your Django project
|
||||
# Add ``dbtemplates.loader.load_template_source`` to the
|
||||
``TEMPLATE_LOADERS`` list in the settings.py of your Django project
|
||||
|
||||
It should look something like this:
|
||||
|
||||
TEMPLATE_LOADERS = (
|
||||
'django.template.loaders.filesystem.load_template_source',
|
||||
'django.template.loaders.app_directories.load_template_source',
|
||||
'myapp.template.loaders.database.load_template_source',
|
||||
'dbtemplates.loader.load_template_source',
|
||||
)
|
||||
|
||||
3. Sync your database via shell (hint: "./manage.py syncdb" within project dir)
|
||||
|
|
|
|||
|
|
@ -1,8 +1,9 @@
|
|||
from django.conf import settings
|
||||
from django.template import TemplateDoesNotExist
|
||||
from django.contrib.dbtemplates.models import Template
|
||||
from django.contrib.sites.models import Site
|
||||
|
||||
from dbtemplates.models import Template
|
||||
|
||||
try:
|
||||
site = Site.objects.get_current()
|
||||
except:
|
||||
|
|
|
|||
|
|
@ -1,14 +1,11 @@
|
|||
"""
|
||||
Creates the default database template objects.
|
||||
Don't know if it works.
|
||||
"""
|
||||
""" Creates the default database template objects. """
|
||||
|
||||
from django.dispatch import dispatcher
|
||||
from django.db.models import signals
|
||||
from django.contrib.sites.models import Site
|
||||
|
||||
from template.models import Template
|
||||
from template import models as template_app
|
||||
from dbtemplates.models import Template
|
||||
from dbtemplates import models as template_app
|
||||
|
||||
def create_default_templates(app, created_models, verbosity):
|
||||
try:
|
||||
|
|
|
|||
|
|
@ -47,7 +47,7 @@ __test__ = {'API_TESTS':"""
|
|||
[<Template: base.html>, <Template: sub.html>]
|
||||
>>> t2.sites.all()
|
||||
[<Site: example.com>]
|
||||
>>> from django.contrib.dbtemplates.loader import load_template_source
|
||||
>>> from dbtemplates.loader import load_template_source
|
||||
>>> loader.template_source_loaders = [load_template_source]
|
||||
>>> loader.get_template("base.html").render(Context({'title':'MainPage'}))
|
||||
'<html><head></head><body>Welcome at MainPage</body></html>'
|
||||
|
|
|
|||
|
|
@ -1,12 +1,7 @@
|
|||
"""
|
||||
Helper function for syncing templates in TEMPLATES_DIRS with the dbtemplates
|
||||
contrib app.
|
||||
"""
|
||||
|
||||
from django.conf import settings
|
||||
from django.template import TemplateDoesNotExist
|
||||
from django.contrib.dbtemplates.models import Template
|
||||
from django.contrib.sites.models import Site
|
||||
from dbtemplates.models import Template
|
||||
|
||||
import os
|
||||
import sys
|
||||
|
|
@ -76,5 +71,8 @@ def synctemplates(extension=".html", overwrite=False):
|
|||
for _tried in tried:
|
||||
print _tried
|
||||
|
||||
def main():
|
||||
synctemplates()
|
||||
|
||||
if __name__ == "__main__":
|
||||
synctemplates()
|
||||
main()
|
||||
18
setup.py
Normal file
18
setup.py
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
from distutils.core import setup
|
||||
|
||||
setup(name='dbtemplates',
|
||||
version='0.2',
|
||||
description='Template loader for database stored templates',
|
||||
author='Jannis Leidel',
|
||||
author_email='jannis@leidel.info',
|
||||
url='http://code.google.com/p/django-databasetemplateloader/',
|
||||
packages=['dbtemplates'],
|
||||
package_dir={ 'dbtemplates': 'dbtemplates' },
|
||||
classifiers=['Development Status :: 4 - Beta',
|
||||
'Environment :: Web Environment',
|
||||
'Intended Audience :: Developers',
|
||||
'License :: OSI Approved :: BSD License',
|
||||
'Operating System :: OS Independent',
|
||||
'Programming Language :: Python',
|
||||
'Topic :: Utilities'],
|
||||
)
|
||||
Loading…
Reference in a new issue