I would like to propose a patch to add a modules section to the admin
app. It would have create, upload, edit and delete. It would add a
generic set of import statements to a newly created file.
Also I would like to change the admin upload behavior to use the
filename from the upload if a 'rename' value isn't provided. The
patch would look something like this:
Index: applications/admin/controllers/default.py
===================================================================
--- applications/admin/controllers/default.py (revision 618)
+++ applications/admin/controllers/default.py (working copy)
@@ -430,10 +430,12 @@
if items: extend[c]=items[0][1]
items=regex_include.findall(data)
include[c]=[i[1] for i in items]
+ modules=listdir(apath('%s/modules/' % app), '.*\.py$')
+ modules.sort()
statics=listdir(apath('%s/static/' % app),'[^\.#].*')
statics.sort()
languages=listdir(apath('%s/languages/' % app), '[\w-]*\.py')
- return dict
(app=app,models=models,defines=defines,controllers=controllers,functions=functions,views=views,extend=extend,include=include,statics=statics,languages=languages)
+ return dict
(app=app,models=models,defines=defines,controllers=controllers,functions=functions,views=views,modules=modules,extend=extend,include=include,statics=statics,languages=languages)
def create_file():
@@ -461,6 +463,12 @@
if len(filename)==5: raise SyntaxError
text="{{extend 'layout.html'}}\n<h1>%s</h1>\n{{=BEAUTIFY
(response._vars)}}" % \
T('This is the %(filename)s template',dict
(filename=filename))
+ elif path[-9:]=='/modules/':
+ if not filename[-3:]=='.py': filename+='.py'
+ if len(filename)==3: raise SyntaxError
+ text="from gluon.storage import Storage\nfrom gluon.html
import *\nfrom gluon.http import *\n"
+ text+="from gluon.validators import *\nfrom gluon.sqlhtml
import *\nfrom gluon.contrib.markdown import WIKI\n"
+ text+="try: from gluon.contrib.gql import SQLTable
\nexcept ImportError: from gluon.sql import SQLTable\nimport
traceback"
elif path[-8:]=='/static/':
text=""
else:
@@ -480,7 +488,8 @@
""" admin controller function """
try:
path=apath(request.vars.location)
- filename=re.sub('[^\w\./]+','_',request.vars.filename)
+ if request.vars.filename: filename=re.sub('[^\w\./]
+','_',request.vars.filename)
+ else: filename=os.path.split(request.vars.file.filename)[-1]
if path[-8:]=='/models/' and not filename[-3:]=='.py':
filename+='.py'
if path[-13:]=='/controllers/' and not filename[-3:]=='.py':
filename+='.py'
if path[-7:]=='/views/' and not filename[-5:]=='.html':
filename+='.html'
Index: applications/admin/views/default/design.html
===================================================================
--- applications/admin/views/default/design.html (revision 618)
+++ applications/admin/views/default/design.html (working copy)
@@ -30,6 +30,7 @@
[ <a href="#models">models</a>
| <a href="#controllers">controllers</a>
| <a href="#views">views</a>
+| <a href="#modules">modules</a>
| <a href="#languages">languages</a>
| <a href="#static">static</a> ]</div>
<br/>
@@ -85,6 +86,22 @@
</ul>
</div>
+<h2 id="modules" onclick="collapse('modules_inner');">Modules</h2>
+<div id="modules_inner"><i>additional code for your application</i>
+<br/><br/>
+{{if not modules:}}
+There are no modules
+{{pass}}
+<ul>
+{{for m in modules:}}<li>{{=peekfile('modules',m)}}
+[ {{=editfile('modules',m)}} |
+<a href="/{{=request.application}}/default/delete/{{=app}}/modules/
{{=m}}?sender={{=request.function}}/{{=app}}">delete</a> ]
+</li>{{pass}}
+<li>{{=file_create_form('%s/modules/' % app)}}</li>
+<li>{{=file_upload_form('%s/modules/' % app)}}</li>
+</ul>
+</div>
+
<h2 id="languages" onclick="collapse('languages_inner');">Languages</
h2>
<div id="languages_inner"><i>translation strings for the application</
i>
<br/><br/>
If Chuck Norris did web development, he would use web2py.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"web2py Web Framework" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/web2py?hl=en
-~----------~----~----~----~------~----~------~--~---