Russell Keith-Magee wrote: > On Mon, Oct 27, 2008 at 6:05 AM, Andrew Chapman <[EMAIL PROTECTED]> wrote: > >> Russell Keith-Magee wrote: >> >>> On Sat, Oct 25, 2008 at 3:55 AM, Andrew Chapman <[EMAIL PROTECTED]> wrote: >>> >>> >>>> My question is how to package up and deploy the Django python code for >>>> external tools to access the database? I'm hoping to have the Django app >>>> sitting on the web server, with the source tree inaccessible to a bunch >>>> of workstations. ... >>>> >>> If you just want the Django database API, then put the Django code >>> (i.e., django.*) on the workstations, and just write your tools to >>> import that code, setting up DJANGO_SETTINGS_MODULE as required. >>> >>> If you also want your model definitions, then you're going to have to >>> deploy those too... >>> ...the model layer will work fine if the views are missing - >>> strictly, the only part of your code that should need to exist on the >>> workstation are the model definitions. Managing an extraction of a >>> partial checkout of your project code is left as an exercise for the >>> reader... >>> *Obviously, the easiest way to get all the required code is to do a >>> full checkout of your web application on the workstation...* >>> >> Ok, thanks. >> I just wanted to confirm that duplicating the web app out to the >> workstations just so they can access the database API was the expected >> course of action in this scenario. >> It feels dirty to me! >> > > No - that isn't what I said at all. > > What I said is that you will need _pieces_ of the web app - > specifically the model definitions, plus the main configuration > file. I expect that the model definitions will also have some > dependencies, but I can't tell what those are without seeing your > code. > > The _easiest_ way to know you have satisfied all internal dependencies > is to copy the full web app. However, this is not the _only_ way, and > if you're willing to handle the configuration management issues, you > could provide a partial checkout and achieve the same outcome. > > Here's a specific example of a piece of code that uses a web app's models. It should get you started - just dive in and write some code! The tricky bit is providing the settings without using a "settings" module. I can't remember who I got this code from, but the kudos belongs to them, not me. Enjoy.
regards Steve from django.conf import settings settings.configure( DATABASE_ENGINE="postgresql_psycopg2", DATABASE_NAME ="PyTeach", DATABASE_USER='django', DATABASE_PASSWORD='djangopw', DATABASE_HOST='localhost', DATABASE_PORT='', INSTALLED_APPS=('info', 'invoicing', 'training')) from invoicing.models import (Address, Organization, Person, Project, Task) # I've chopped a lot of code that created and saves instances of other models hweb = Organization( name="Holden Web, LLC", notes="""A tidy little company that works with Django""") hweb.save() --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~----------~----~----~----~------~----~------~--~---