google-code-export / google-app-engine-django

Automatically exported from code.google.com/p/google-app-engine-django
Apache License 2.0
1 stars 0 forks source link

Support changing the location of appstore data #103

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
I would like to be able to set the location of appstore data much the same
way you can using the dev_appserver.py with the manage.py commands. This
would enable saving/using appstore data in locations other than /tmp on
*nix systems where the data might be deleted at any point.

There are two possible solutions that could be implemented (preferrably both):

1. Enabling the --datastore_path and --history_path command line options in
manage.py commands (runserver, shell etc.)
2. Enabling you to set the datastore path and history path via the settings
module. This would require that the --settings command line option 
   be enabled in order for this to be useful (which would require
appengine_django to support changing the DJANGO_SETTINGS_MODULE environment 
   variable as overriding the DJANGO_SETTINGS_MODULE is all that the
--settings option does).

Original issue reported on code.google.com by IanMLe...@gmail.com on 18 Jan 2009 at 11:08

GoogleCodeExporter commented 9 years ago
This is a valid feature request, would you be willing to provide a patch?

Original comment by mattbrow...@gmail.com on 17 Apr 2009 at 5:36

GoogleCodeExporter commented 9 years ago
Here's a patch for runserver.  Please let me know if this is acceptable.

svn diff appengine_django/management/commands/runserver.py 
Index: appengine_django/management/commands/runserver.py
===================================================================
--- appengine_django/management/commands/runserver.py   (revision 100)
+++ appengine_django/management/commands/runserver.py   (working copy)
@@ -35,7 +35,7 @@
   # hack __main__ so --help in dev_appserver_main works OK.
   sys.modules['__main__'] = dev_appserver_main
   # Set bind ip/port if specified.
-  if len(sys.argv) > 2:
+  if len(sys.argv) > 2 and not sys.argv[2].startswith("--"):
     addrport = sys.argv[2]
     try:
       addr, port = addrport.split(":")
@@ -62,8 +62,18 @@

   # Pass the application specific datastore location to the server.
   p = get_datastore_paths()
-  args.extend(["--datastore_path", p[0], "--history_path", p[1]])
+  datastore_path = p[0]
+  history_path = p[1]

+  if len(sys.argv) > 2:
+    for arg in sys.argv[2:]:
+      if arg.startswith("--datastore_path="):
+        datastore_path=arg[arg.index("=")+1:]
+      elif arg.startswith("--history_path="):
+        history_path = arg[arg.index("=")+1:]
+
+  args.extend(["--datastore_path", datastore_path, "--history_path", 
history_path])
+
   # Append the current working directory to the arguments.
   dev_appserver_main.main([progname] + args + [os.getcwdu()])

Original comment by dherbst on 2 Jan 2010 at 8:38

GoogleCodeExporter commented 9 years ago
At first glance, it looks like this patch is only valid for the runserver.py 
command.
But the feature request was for the ability to run this for other manage.py 
commands.
I for one could really use this in 'shell' and 'startapp'. 

Original comment by AllTheGo...@gmail.com on 16 Apr 2010 at 10:49

GoogleCodeExporter commented 9 years ago
I'll look at shell.  Why does startapp need a datastore?  I haven't had any 
issues
using startapp without my datastore location.  What issues are you running into?

Original comment by dherbst on 16 Apr 2010 at 11:35

GoogleCodeExporter commented 9 years ago
You're right, apologies, that was a mistake. I can't see a need for startapp.

Original comment by AllTheGo...@gmail.com on 16 Apr 2010 at 11:40

GoogleCodeExporter commented 9 years ago
I checked my patch for shell in my fork here:
http://code.google.com/p/dherbst-app-engine-django/source/detail?r=3fea1cacf20d1
5601abda7e0c6deee13497a6370

It may not be the most elegant way to do it, but it works for me.

usage: python manage.py shell --datastore_path=/abs/path/to/file.name

Original comment by dherbst on 20 Apr 2010 at 1:14