Commits

Young King  committed 5d03294

change flask skeleton

  • Participants
  • Parent commits 58f7138

Comments (0)

Files changed (7)

File docs/index.rst

         -d, --directory               string    .
         --no-verbose
 
-                
+      generate_secret_key:
+          creates a new secret key
+
+              -l, --length                  integer   32
 
       runfcgi:
         run application use flup

File flaskext/actions/flask_admin.py

 import random
 import string
 from werkzeug import script
-import utils
+from flaskext.actions import utils
 
 def preprocess_file(path, **values):
     f = open(path, 'r')
 
     # Update configuration file
     key = utils.generate_secret_key()
+    preprocess_file(path_join('manage.py'), project=proj_name)
+    preprocess_file(path_join('__init__.py'), project=proj_name)
     preprocess_file(path_join('settings.py'), project=proj_name,secretkey=key)
-
+    sub_proj_dir = path_join(proj_name)
+    os.mkdir(sub_proj_dir)
+    shutil.move(path_join('__init__.py'),sub_proj_dir)
+    shutil.move(path_join('views'),sub_proj_dir)
     os.chmod(path_join('manage.py'),
              os.stat(path_join('manage.py')).st_mode |
              stat.S_IXUSR | stat.S_IXGRP | stat.S_IXOTH)

File flaskext/actions/project_template/__init__.py_tmpl

+# -*- encoding:utf-8 -*-
+from flask import Flask
+from %(project)s.views.frontend import frontend
+
+app = Flask(__name__)
+app.register_module(frontend)
+

File flaskext/actions/project_template/manage.py_tmpl

 from flask import Flask
 from flaskext.actions import Manager
 import settings
+from %(project)s import app
 
-app = Flask(__name__)
 app.config.from_object(settings)
 manager = Manager(app)
 

File flaskext/actions/project_template/views/__init__.py

+# -*- encoding:utf-8 -*-
+
+
+
+
+

File flaskext/actions/project_template/views/frontend.py

+# -*- encoding:utf-8 -*-
+from flask import Module
+
+frontend = Module(__name__)
+
+@frontend.route('/')
+def index():
+    return "Hello,world"

File flaskext/actions/utils.py

 KEY_CHARS = string.letters + string.digits + string.punctuation
 
 def generate_secret_key(length=32):
-    return  ''.join(random.choice(KEY_CHARS) for _ in xrange(length))
+    return  repr(''.join(random.choice(KEY_CHARS) for _ in xrange(length)))