├── .gitignore ├── CHANGES.txt ├── MANIFEST.in ├── README.txt ├── bootstrap.py ├── buildout.cfg ├── development.ini ├── docs ├── .gitignore ├── Makefile ├── conf.py └── index.txt ├── pyramid_formalchemy ├── __init__.py ├── actions.py ├── events.py ├── i18n.py ├── locale │ ├── de │ │ └── LC_MESSAGES │ │ │ ├── pyramid_formalchemy.mo │ │ │ └── pyramid_formalchemy.po │ ├── fr │ │ └── LC_MESSAGES │ │ │ ├── pyramid_formalchemy.mo │ │ │ └── pyramid_formalchemy.po │ ├── pt_BR │ │ └── LC_MESSAGES │ │ │ ├── pyramid_formalchemy.mo │ │ │ └── pyramid_formalchemy.po │ ├── pyramid_formalchemy.pot │ └── ru │ │ └── LC_MESSAGES │ │ ├── pyramid_formalchemy.mo │ │ └── pyramid_formalchemy.po ├── paster.py ├── paster_templates │ └── pyramid_fa │ │ ├── +package+ │ │ ├── faforms.py_tmpl │ │ ├── fainit.py_tmpl │ │ └── faroutes.py_tmpl │ │ └── README_FORMALCHEMY.txt ├── resources.py ├── static │ ├── add.png │ ├── admin.css │ ├── delete.png │ └── edit.png ├── templates │ ├── admin │ │ ├── edit.pt │ │ ├── edit.pt.py │ │ ├── listing.pt │ │ ├── listing.pt.py │ │ ├── master.pt │ │ ├── master.pt.py │ │ ├── models.pt │ │ ├── models.pt.py │ │ ├── new.pt │ │ ├── new.pt.py │ │ ├── show.pt │ │ └── show.pt.py │ └── forms │ │ ├── fieldset.pt │ │ ├── fieldset.pt.py │ │ ├── fieldset_readonly.pt │ │ ├── fieldset_readonly.pt.py │ │ ├── grid.pt │ │ ├── grid.pt.py │ │ ├── grid_readonly.pt │ │ └── grid_readonly.pt.py ├── utils.py └── views.py ├── pyramidapp ├── CHANGES.txt ├── README.txt ├── development.ini ├── jquery.ini ├── pyramidapp │ ├── __init__.py │ ├── events.py │ ├── forms.py │ ├── jquery.py │ ├── models.py │ ├── resources.py │ ├── security.py │ ├── static │ │ ├── favicon.ico │ │ ├── footerbg.png │ │ ├── headerbg.png │ │ ├── ie6.css │ │ ├── middlebg.png │ │ ├── pylons.css │ │ ├── pyramid-small.png │ │ ├── pyramid.png │ │ └── transparent.gif │ ├── templates │ │ ├── foolisting.pt │ │ ├── foolisting.pt.py │ │ ├── fooshow.pt │ │ ├── fooshow.pt.py │ │ ├── mytemplate.pt │ │ └── mytemplate.pt.py │ ├── tests.py │ └── views.py ├── security.ini ├── setup.cfg ├── setup.py └── test.ini ├── setup.cfg └── setup.py /.gitignore: -------------------------------------------------------------------------------- 1 | .Python 2 | bin/ 3 | lib/ 4 | dist/ 5 | eggs/ 6 | parts/ 7 | var/ 8 | develop-eggs/ 9 | docs/_build/ 10 | docs/modules/ 11 | include/ 12 | .installed.cfg 13 | *.egg-info 14 | *.egg 15 | *.swp 16 | *.pyc 17 | *.pyo 18 | *.log 19 | *.db 20 | -------------------------------------------------------------------------------- /CHANGES.txt: -------------------------------------------------------------------------------- 1 | 2 | 0.4.4 (unreleased) 3 | ------------------ 4 | 5 | - address pyramid compatibility issue #19 (vangheem) 6 | 7 | 8 | 0.4.3 (2011-12-26) 9 | ------------------ 10 | 11 | 12 | 0.4.2 (2011-11-03) 13 | ------------------ 14 | 15 | - Pyramid 1.1 compatibility (amleczko) 16 | 17 | - Adding IBeforeListingRenderEvent (amleczko) 18 | 19 | - Fix problem with formalchemy_model_view registration (amleczko) 20 | 21 | 22 | 0.4.1 (2011-07-01) 23 | ------------------ 24 | 25 | - Fix documentation urls (gawel) 26 | 27 | - Adding fallback for missing model_class on request (gawel) 28 | 29 | - Adding missing templates to egg (ConceitedCode, do3cc) 30 | 31 | 0.4 - aka CRUD Sprint (hosted by Red Turtle) release 32 | ---------------------------------------------------- 33 | 34 | - view customisation per model (amleczko) 35 | 36 | - autocomplete renderer for relations (amleczko) 37 | 38 | - various events hook (amleczko) 39 | 40 | - paster template for Akhet (do3cc) 41 | 42 | - permission check in model listing 43 | 44 | - customisable actions 45 | 46 | - i18n 47 | 48 | 49 | 0.2 50 | --- 51 | 52 | - Take care of permissions. You can now use an __acl__ attribute in your SA 53 | models to restrict access 54 | 55 | 0.1 56 | --- 57 | 58 | - Initial version 59 | -------------------------------------------------------------------------------- /MANIFEST.in: -------------------------------------------------------------------------------- 1 | include CHANGES.txt 2 | recursive-include pyramid_formalchemy *.pt.py 3 | recursive-include pyramid_formalchemy *.pt 4 | recursive-include pyramid_formalchemy *.css 5 | recursive-include pyramid_formalchemy *.js 6 | recursive-include pyramid_formalchemy *.gif 7 | recursive-include pyramid_formalchemy *.png 8 | recursive-include pyramid_formalchemy *.jpg 9 | recursive-include pyramid_formalchemy *.py_tmpl 10 | recursive-include pyramid_formalchemy *.txt 11 | recursive-include pyramid_formalchemy *.mo 12 | recursive-include pyramid_formalchemy *.po 13 | -------------------------------------------------------------------------------- /README.txt: -------------------------------------------------------------------------------- 1 | This module provide a set of utilities for using FormAlchemy_ with Pyramid 2 | 3 | .. _formalchemy: http://docs.formalchemy.org/ 4 | 5 | Have a look at the `Online demo 6 | `_ 7 | or at the `Documentation 8 | `_ 9 | 10 | Bug and feature request must be reported on the `github tracker 11 | `_ 12 | 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /bootstrap.py: -------------------------------------------------------------------------------- 1 | ############################################################################## 2 | # 3 | # Copyright (c) 2006 Zope Foundation and Contributors. 4 | # All Rights Reserved. 5 | # 6 | # This software is subject to the provisions of the Zope Public License, 7 | # Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution. 8 | # THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED 9 | # WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 10 | # WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS 11 | # FOR A PARTICULAR PURPOSE. 12 | # 13 | ############################################################################## 14 | """Bootstrap a buildout-based project 15 | 16 | Simply run this script in a directory containing a buildout.cfg. 17 | The script accepts buildout command-line options, so you can 18 | use the -c option to specify an alternate configuration file. 19 | """ 20 | 21 | import os, shutil, sys, tempfile, textwrap, urllib, urllib2, subprocess 22 | from optparse import OptionParser 23 | 24 | if sys.platform == 'win32': 25 | def quote(c): 26 | if ' ' in c: 27 | return '"%s"' % c # work around spawn lamosity on windows 28 | else: 29 | return c 30 | else: 31 | quote = str 32 | 33 | # See zc.buildout.easy_install._has_broken_dash_S for motivation and comments. 34 | stdout, stderr = subprocess.Popen( 35 | [sys.executable, '-Sc', 36 | 'try:\n' 37 | ' import ConfigParser\n' 38 | 'except ImportError:\n' 39 | ' print 1\n' 40 | 'else:\n' 41 | ' print 0\n'], 42 | stdout=subprocess.PIPE, stderr=subprocess.PIPE).communicate() 43 | has_broken_dash_S = bool(int(stdout.strip())) 44 | 45 | # In order to be more robust in the face of system Pythons, we want to 46 | # run without site-packages loaded. This is somewhat tricky, in 47 | # particular because Python 2.6's distutils imports site, so starting 48 | # with the -S flag is not sufficient. However, we'll start with that: 49 | if not has_broken_dash_S and 'site' in sys.modules: 50 | # We will restart with python -S. 51 | args = sys.argv[:] 52 | args[0:0] = [sys.executable, '-S'] 53 | args = map(quote, args) 54 | os.execv(sys.executable, args) 55 | # Now we are running with -S. We'll get the clean sys.path, import site 56 | # because distutils will do it later, and then reset the path and clean 57 | # out any namespace packages from site-packages that might have been 58 | # loaded by .pth files. 59 | clean_path = sys.path[:] 60 | import site 61 | sys.path[:] = clean_path 62 | for k, v in sys.modules.items(): 63 | if k in ('setuptools', 'pkg_resources') or ( 64 | hasattr(v, '__path__') and 65 | len(v.__path__)==1 and 66 | not os.path.exists(os.path.join(v.__path__[0],'__init__.py'))): 67 | # This is a namespace package. Remove it. 68 | sys.modules.pop(k) 69 | 70 | is_jython = sys.platform.startswith('java') 71 | 72 | setuptools_source = 'http://peak.telecommunity.com/dist/ez_setup.py' 73 | distribute_source = 'http://python-distribute.org/distribute_setup.py' 74 | 75 | # parsing arguments 76 | def normalize_to_url(option, opt_str, value, parser): 77 | if value: 78 | if '://' not in value: # It doesn't smell like a URL. 79 | value = 'file://%s' % ( 80 | urllib.pathname2url( 81 | os.path.abspath(os.path.expanduser(value))),) 82 | if opt_str == '--download-base' and not value.endswith('/'): 83 | # Download base needs a trailing slash to make the world happy. 84 | value += '/' 85 | else: 86 | value = None 87 | name = opt_str[2:].replace('-', '_') 88 | setattr(parser.values, name, value) 89 | 90 | usage = '''\ 91 | [DESIRED PYTHON FOR BUILDOUT] bootstrap.py [options] 92 | 93 | Bootstraps a buildout-based project. 94 | 95 | Simply run this script in a directory containing a buildout.cfg, using the 96 | Python that you want bin/buildout to use. 97 | 98 | Note that by using --setup-source and --download-base to point to 99 | local resources, you can keep this script from going over the network. 100 | ''' 101 | 102 | parser = OptionParser(usage=usage) 103 | parser.add_option("-v", "--version", dest="version", 104 | help="use a specific zc.buildout version") 105 | parser.add_option("-d", "--distribute", 106 | action="store_true", dest="use_distribute", default=False, 107 | help="Use Distribute rather than Setuptools.") 108 | parser.add_option("--setup-source", action="callback", dest="setup_source", 109 | callback=normalize_to_url, nargs=1, type="string", 110 | help=("Specify a URL or file location for the setup file. " 111 | "If you use Setuptools, this will default to " + 112 | setuptools_source + "; if you use Distribute, this " 113 | "will default to " + distribute_source +".")) 114 | parser.add_option("--download-base", action="callback", dest="download_base", 115 | callback=normalize_to_url, nargs=1, type="string", 116 | help=("Specify a URL or directory for downloading " 117 | "zc.buildout and either Setuptools or Distribute. " 118 | "Defaults to PyPI.")) 119 | parser.add_option("--eggs", 120 | help=("Specify a directory for storing eggs. Defaults to " 121 | "a temporary directory that is deleted when the " 122 | "bootstrap script completes.")) 123 | parser.add_option("-t", "--accept-buildout-test-releases", 124 | dest='accept_buildout_test_releases', 125 | action="store_true", default=False, 126 | help=("Normally, if you do not specify a --version, the " 127 | "bootstrap script and buildout gets the newest " 128 | "*final* versions of zc.buildout and its recipes and " 129 | "extensions for you. If you use this flag, " 130 | "bootstrap and buildout will get the newest releases " 131 | "even if they are alphas or betas.")) 132 | parser.add_option("-c", None, action="store", dest="config_file", 133 | help=("Specify the path to the buildout configuration " 134 | "file to be used.")) 135 | 136 | options, args = parser.parse_args() 137 | 138 | # if -c was provided, we push it back into args for buildout's main function 139 | if options.config_file is not None: 140 | args += ['-c', options.config_file] 141 | 142 | if options.eggs: 143 | eggs_dir = os.path.abspath(os.path.expanduser(options.eggs)) 144 | else: 145 | eggs_dir = tempfile.mkdtemp() 146 | 147 | if options.setup_source is None: 148 | if options.use_distribute: 149 | options.setup_source = distribute_source 150 | else: 151 | options.setup_source = setuptools_source 152 | 153 | if options.accept_buildout_test_releases: 154 | args.append('buildout:accept-buildout-test-releases=true') 155 | args.append('bootstrap') 156 | 157 | try: 158 | import pkg_resources 159 | import setuptools # A flag. Sometimes pkg_resources is installed alone. 160 | if not hasattr(pkg_resources, '_distribute'): 161 | raise ImportError 162 | except ImportError: 163 | ez_code = urllib2.urlopen( 164 | options.setup_source).read().replace('\r\n', '\n') 165 | ez = {} 166 | exec ez_code in ez 167 | setup_args = dict(to_dir=eggs_dir, download_delay=0) 168 | if options.download_base: 169 | setup_args['download_base'] = options.download_base 170 | if options.use_distribute: 171 | setup_args['no_fake'] = True 172 | ez['use_setuptools'](**setup_args) 173 | if 'pkg_resources' in sys.modules: 174 | reload(sys.modules['pkg_resources']) 175 | import pkg_resources 176 | # This does not (always?) update the default working set. We will 177 | # do it. 178 | for path in sys.path: 179 | if path not in pkg_resources.working_set.entries: 180 | pkg_resources.working_set.add_entry(path) 181 | 182 | cmd = [quote(sys.executable), 183 | '-c', 184 | quote('from setuptools.command.easy_install import main; main()'), 185 | '-mqNxd', 186 | quote(eggs_dir)] 187 | 188 | if not has_broken_dash_S: 189 | cmd.insert(1, '-S') 190 | 191 | find_links = options.download_base 192 | if not find_links: 193 | find_links = os.environ.get('bootstrap-testing-find-links') 194 | if find_links: 195 | cmd.extend(['-f', quote(find_links)]) 196 | 197 | if options.use_distribute: 198 | setup_requirement = 'distribute' 199 | else: 200 | setup_requirement = 'setuptools' 201 | ws = pkg_resources.working_set 202 | setup_requirement_path = ws.find( 203 | pkg_resources.Requirement.parse(setup_requirement)).location 204 | env = dict( 205 | os.environ, 206 | PYTHONPATH=setup_requirement_path) 207 | 208 | requirement = 'zc.buildout' 209 | version = options.version 210 | if version is None and not options.accept_buildout_test_releases: 211 | # Figure out the most recent final version of zc.buildout. 212 | import setuptools.package_index 213 | _final_parts = '*final-', '*final' 214 | def _final_version(parsed_version): 215 | for part in parsed_version: 216 | if (part[:1] == '*') and (part not in _final_parts): 217 | return False 218 | return True 219 | index = setuptools.package_index.PackageIndex( 220 | search_path=[setup_requirement_path]) 221 | if find_links: 222 | index.add_find_links((find_links,)) 223 | req = pkg_resources.Requirement.parse(requirement) 224 | if index.obtain(req) is not None: 225 | best = [] 226 | bestv = None 227 | for dist in index[req.project_name]: 228 | distv = dist.parsed_version 229 | if _final_version(distv): 230 | if bestv is None or distv > bestv: 231 | best = [dist] 232 | bestv = distv 233 | elif distv == bestv: 234 | best.append(dist) 235 | if best: 236 | best.sort() 237 | version = best[-1].version 238 | if version: 239 | requirement = '=='.join((requirement, version)) 240 | cmd.append(requirement) 241 | 242 | if is_jython: 243 | import subprocess 244 | exitcode = subprocess.Popen(cmd, env=env).wait() 245 | else: # Windows prefers this, apparently; otherwise we would prefer subprocess 246 | exitcode = os.spawnle(*([os.P_WAIT, sys.executable] + cmd + [env])) 247 | if exitcode != 0: 248 | sys.stdout.flush() 249 | sys.stderr.flush() 250 | print ("An error occurred when trying to install zc.buildout. " 251 | "Look above this message for any errors that " 252 | "were output by easy_install.") 253 | sys.exit(exitcode) 254 | 255 | ws.add_entry(eggs_dir) 256 | ws.require(requirement) 257 | import zc.buildout.buildout 258 | zc.buildout.buildout.main(args) 259 | if not options.eggs: # clean up temporary egg directory 260 | shutil.rmtree(eggs_dir) 261 | -------------------------------------------------------------------------------- /buildout.cfg: -------------------------------------------------------------------------------- 1 | [buildout] 2 | newest = false 3 | parts = eggs test 4 | develop = . pyramidapp ../fa.jquery ../formalchemy 5 | 6 | [eggs] 7 | recipe = zc.recipe.egg 8 | eggs = 9 | Mako>=0.3.6 10 | FormAlchemy>=1.4.1 11 | PasteScript>=1.7.4 12 | pyramid>=1.2.9 13 | pyramid_formalchemy 14 | pyramid_handlers 15 | pyramidapp 16 | fa.jquery 17 | WebTest 18 | coverage 19 | PasteScript 20 | Sphinx 21 | unittest2 22 | nose 23 | Babel 24 | lingua 25 | scripts= 26 | nosetests=tests 27 | pcreate=pcreate 28 | interpreter = python 29 | 30 | [test] 31 | recipe = zc.recipe.egg 32 | eggs = 33 | ${eggs:eggs} 34 | initialization = 35 | import os 36 | os.chdir(os.path.join('${buildout:directory}', 'pyramidapp')) 37 | scripts= 38 | nosetests=nosetests 39 | paster=paster_serve 40 | -------------------------------------------------------------------------------- /development.ini: -------------------------------------------------------------------------------- 1 | [app:pyramid_formalchemy] 2 | use = egg:pyramid_formalchemy 3 | reload_templates = true 4 | debug_authorization = false 5 | debug_notfound = false 6 | debug_routematch = false 7 | debug_templates = true 8 | default_locale_name = en 9 | 10 | [pipeline:main] 11 | pipeline = 12 | egg:WebError#evalerror 13 | pyramid_formalchemy 14 | 15 | [server:main] 16 | use = egg:Paste#http 17 | host = 0.0.0.0 18 | port = 6543 19 | 20 | # Begin logging configuration 21 | 22 | [loggers] 23 | keys = root 24 | 25 | [handlers] 26 | keys = console 27 | 28 | [formatters] 29 | keys = generic 30 | 31 | [logger_root] 32 | level = INFO 33 | handlers = console 34 | 35 | [handler_console] 36 | class = StreamHandler 37 | args = (sys.stderr,) 38 | level = NOTSET 39 | formatter = generic 40 | 41 | [formatter_generic] 42 | format = %(asctime)s %(levelname)-5.5s [%(name)s][%(threadName)s] %(message)s 43 | 44 | # End logging configuration 45 | -------------------------------------------------------------------------------- /docs/.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | .Python 3 | bin/ 4 | lib/ 5 | dist/ 6 | eggs/ 7 | parts/ 8 | var/ 9 | develop-eggs/ 10 | docs/_build/ 11 | docs/modules/ 12 | include/ 13 | .installed.cfg 14 | *.egg-info 15 | *.pt.py 16 | *.swp 17 | *.pyc 18 | *.pyo 19 | *.log 20 | *.db 21 | -------------------------------------------------------------------------------- /docs/Makefile: -------------------------------------------------------------------------------- 1 | # Makefile for Sphinx documentation 2 | # 3 | 4 | # You can set these variables from the command line. 5 | SPHINXOPTS = 6 | SPHINXBUILD = ../../bin/sphinx-build 7 | PAPER = 8 | BUILDDIR = _build 9 | 10 | # Internal variables. 11 | PAPEROPT_a4 = -D latex_paper_size=a4 12 | PAPEROPT_letter = -D latex_paper_size=letter 13 | ALLSPHINXOPTS = -d $(BUILDDIR)/doctrees $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) . 14 | 15 | .PHONY: help clean html dirhtml singlehtml pickle json htmlhelp qthelp devhelp epub latex latexpdf text man changes linkcheck doctest 16 | 17 | help: 18 | @echo "Please use \`make ' where is one of" 19 | @echo " html to make standalone HTML files" 20 | @echo " dirhtml to make HTML files named index.html in directories" 21 | @echo " singlehtml to make a single large HTML file" 22 | @echo " pickle to make pickle files" 23 | @echo " json to make JSON files" 24 | @echo " htmlhelp to make HTML files and a HTML help project" 25 | @echo " qthelp to make HTML files and a qthelp project" 26 | @echo " devhelp to make HTML files and a Devhelp project" 27 | @echo " epub to make an epub" 28 | @echo " latex to make LaTeX files, you can set PAPER=a4 or PAPER=letter" 29 | @echo " latexpdf to make LaTeX files and run them through pdflatex" 30 | @echo " text to make text files" 31 | @echo " man to make manual pages" 32 | @echo " changes to make an overview of all changed/added/deprecated items" 33 | @echo " linkcheck to check all external links for integrity" 34 | @echo " doctest to run all doctests embedded in the documentation (if enabled)" 35 | 36 | clean: 37 | -rm -rf $(BUILDDIR)/* 38 | 39 | html: 40 | $(SPHINXBUILD) -b html $(ALLSPHINXOPTS) $(BUILDDIR)/html 41 | @echo 42 | @echo "Build finished. The HTML pages are in $(BUILDDIR)/html." 43 | 44 | dirhtml: 45 | $(SPHINXBUILD) -b dirhtml $(ALLSPHINXOPTS) $(BUILDDIR)/dirhtml 46 | @echo 47 | @echo "Build finished. The HTML pages are in $(BUILDDIR)/dirhtml." 48 | 49 | singlehtml: 50 | $(SPHINXBUILD) -b singlehtml $(ALLSPHINXOPTS) $(BUILDDIR)/singlehtml 51 | @echo 52 | @echo "Build finished. The HTML page is in $(BUILDDIR)/singlehtml." 53 | 54 | pickle: 55 | $(SPHINXBUILD) -b pickle $(ALLSPHINXOPTS) $(BUILDDIR)/pickle 56 | @echo 57 | @echo "Build finished; now you can process the pickle files." 58 | 59 | json: 60 | $(SPHINXBUILD) -b json $(ALLSPHINXOPTS) $(BUILDDIR)/json 61 | @echo 62 | @echo "Build finished; now you can process the JSON files." 63 | 64 | htmlhelp: 65 | $(SPHINXBUILD) -b htmlhelp $(ALLSPHINXOPTS) $(BUILDDIR)/htmlhelp 66 | @echo 67 | @echo "Build finished; now you can run HTML Help Workshop with the" \ 68 | ".hhp project file in $(BUILDDIR)/htmlhelp." 69 | 70 | qthelp: 71 | $(SPHINXBUILD) -b qthelp $(ALLSPHINXOPTS) $(BUILDDIR)/qthelp 72 | @echo 73 | @echo "Build finished; now you can run "qcollectiongenerator" with the" \ 74 | ".qhcp project file in $(BUILDDIR)/qthelp, like this:" 75 | @echo "# qcollectiongenerator $(BUILDDIR)/qthelp/pyramid_formalchemy.qhcp" 76 | @echo "To view the help file:" 77 | @echo "# assistant -collectionFile $(BUILDDIR)/qthelp/pyramid_formalchemy.qhc" 78 | 79 | devhelp: 80 | $(SPHINXBUILD) -b devhelp $(ALLSPHINXOPTS) $(BUILDDIR)/devhelp 81 | @echo 82 | @echo "Build finished." 83 | @echo "To view the help file:" 84 | @echo "# mkdir -p $$HOME/.local/share/devhelp/pyramid_formalchemy" 85 | @echo "# ln -s $(BUILDDIR)/devhelp $$HOME/.local/share/devhelp/pyramid_formalchemy" 86 | @echo "# devhelp" 87 | 88 | epub: 89 | $(SPHINXBUILD) -b epub $(ALLSPHINXOPTS) $(BUILDDIR)/epub 90 | @echo 91 | @echo "Build finished. The epub file is in $(BUILDDIR)/epub." 92 | 93 | latex: 94 | $(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex 95 | @echo 96 | @echo "Build finished; the LaTeX files are in $(BUILDDIR)/latex." 97 | @echo "Run \`make' in that directory to run these through (pdf)latex" \ 98 | "(use \`make latexpdf' here to do that automatically)." 99 | 100 | latexpdf: 101 | $(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex 102 | @echo "Running LaTeX files through pdflatex..." 103 | make -C $(BUILDDIR)/latex all-pdf 104 | @echo "pdflatex finished; the PDF files are in $(BUILDDIR)/latex." 105 | 106 | text: 107 | $(SPHINXBUILD) -b text $(ALLSPHINXOPTS) $(BUILDDIR)/text 108 | @echo 109 | @echo "Build finished. The text files are in $(BUILDDIR)/text." 110 | 111 | man: 112 | $(SPHINXBUILD) -b man $(ALLSPHINXOPTS) $(BUILDDIR)/man 113 | @echo 114 | @echo "Build finished. The manual pages are in $(BUILDDIR)/man." 115 | 116 | changes: 117 | $(SPHINXBUILD) -b changes $(ALLSPHINXOPTS) $(BUILDDIR)/changes 118 | @echo 119 | @echo "The overview file is in $(BUILDDIR)/changes." 120 | 121 | linkcheck: 122 | $(SPHINXBUILD) -b linkcheck $(ALLSPHINXOPTS) $(BUILDDIR)/linkcheck 123 | @echo 124 | @echo "Link check complete; look for any errors in the above output " \ 125 | "or in $(BUILDDIR)/linkcheck/output.txt." 126 | 127 | doctest: 128 | $(SPHINXBUILD) -b doctest $(ALLSPHINXOPTS) $(BUILDDIR)/doctest 129 | @echo "Testing of doctests in the sources finished, look at the " \ 130 | "results in $(BUILDDIR)/doctest/output.txt." 131 | -------------------------------------------------------------------------------- /docs/conf.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # 3 | # pyramid_formalchemy documentation build configuration file, created by 4 | # sphinx-quickstart on Sat Jan 15 20:18:53 2011. 5 | # 6 | # This file is execfile()d with the current directory set to its containing dir. 7 | # 8 | # Note that not all possible configuration values are present in this 9 | # autogenerated file. 10 | # 11 | # All configuration values have a default; values that are commented out 12 | # serve to show the default. 13 | 14 | import sys, os 15 | 16 | # If extensions (or modules to document with autodoc) are in another directory, 17 | # add these directories to sys.path here. If the directory is relative to the 18 | # documentation root, use os.path.abspath to make it absolute, like shown here. 19 | #sys.path.insert(0, os.path.abspath('.')) 20 | 21 | # -- General configuration ----------------------------------------------------- 22 | 23 | # If your documentation needs a minimal Sphinx version, state it here. 24 | #needs_sphinx = '1.0' 25 | 26 | # Add any Sphinx extension module names here, as strings. They can be extensions 27 | # coming with Sphinx (named 'sphinx.ext.*') or your custom ones. 28 | extensions = ['sphinx.ext.autodoc', 'sphinx.ext.doctest', 'sphinx.ext.intersphinx'] 29 | 30 | # Add any paths that contain templates here, relative to this directory. 31 | templates_path = ['_templates'] 32 | 33 | # The suffix of source filenames. 34 | source_suffix = '.txt' 35 | 36 | # The encoding of source files. 37 | #source_encoding = 'utf-8-sig' 38 | 39 | # The master toctree document. 40 | master_doc = 'index' 41 | 42 | # General information about the project. 43 | project = u'pyramid_formalchemy' 44 | copyright = u'2011, Gael Pasgrimaud' 45 | 46 | # The version info for the project you're documenting, acts as replacement for 47 | # |version| and |release|, also used in various other places throughout the 48 | # built documents. 49 | # 50 | # The short X.Y version. 51 | version = '0.1' 52 | # The full version, including alpha/beta/rc tags. 53 | release = version 54 | 55 | # The language for content autogenerated by Sphinx. Refer to documentation 56 | # for a list of supported languages. 57 | #language = None 58 | 59 | # There are two options for replacing |today|: either, you set today to some 60 | # non-false value, then it is used: 61 | #today = '' 62 | # Else, today_fmt is used as the format for a strftime call. 63 | #today_fmt = '%B %d, %Y' 64 | 65 | # List of patterns, relative to source directory, that match files and 66 | # directories to ignore when looking for source files. 67 | exclude_patterns = ['_build'] 68 | 69 | # The reST default role (used for this markup: `text`) to use for all documents. 70 | #default_role = None 71 | 72 | # If true, '()' will be appended to :func: etc. cross-reference text. 73 | #add_function_parentheses = True 74 | 75 | # If true, the current module name will be prepended to all description 76 | # unit titles (such as .. function::). 77 | #add_module_names = True 78 | 79 | # If true, sectionauthor and moduleauthor directives will be shown in the 80 | # output. They are ignored by default. 81 | #show_authors = False 82 | 83 | # The name of the Pygments (syntax highlighting) style to use. 84 | pygments_style = 'sphinx' 85 | 86 | # A list of ignored prefixes for module index sorting. 87 | #modindex_common_prefix = [] 88 | 89 | 90 | # -- Options for HTML output --------------------------------------------------- 91 | 92 | # The theme to use for HTML and HTML Help pages. See the documentation for 93 | # a list of builtin themes. 94 | html_theme = 'default' 95 | 96 | # Theme options are theme-specific and customize the look and feel of a theme 97 | # further. For a list of options available for each theme, see the 98 | # documentation. 99 | #html_theme_options = {} 100 | 101 | # Add any paths that contain custom themes here, relative to this directory. 102 | #html_theme_path = [] 103 | 104 | # The name for this set of Sphinx documents. If None, it defaults to 105 | # " v documentation". 106 | #html_title = None 107 | 108 | # A shorter title for the navigation bar. Default is the same as html_title. 109 | #html_short_title = None 110 | 111 | # The name of an image file (relative to this directory) to place at the top 112 | # of the sidebar. 113 | #html_logo = None 114 | 115 | # The name of an image file (within the static path) to use as favicon of the 116 | # docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32 117 | # pixels large. 118 | #html_favicon = None 119 | 120 | # Add any paths that contain custom static files (such as style sheets) here, 121 | # relative to this directory. They are copied after the builtin static files, 122 | # so a file named "default.css" will overwrite the builtin "default.css". 123 | html_static_path = ['_static'] 124 | 125 | # If not '', a 'Last updated on:' timestamp is inserted at every page bottom, 126 | # using the given strftime format. 127 | #html_last_updated_fmt = '%b %d, %Y' 128 | 129 | # If true, SmartyPants will be used to convert quotes and dashes to 130 | # typographically correct entities. 131 | #html_use_smartypants = True 132 | 133 | # Custom sidebar templates, maps document names to template names. 134 | #html_sidebars = {} 135 | 136 | # Additional templates that should be rendered to pages, maps page names to 137 | # template names. 138 | #html_additional_pages = {} 139 | 140 | # If false, no module index is generated. 141 | #html_domain_indices = True 142 | 143 | # If false, no index is generated. 144 | #html_use_index = True 145 | 146 | # If true, the index is split into individual pages for each letter. 147 | #html_split_index = False 148 | 149 | # If true, links to the reST sources are added to the pages. 150 | #html_show_sourcelink = True 151 | 152 | # If true, "Created using Sphinx" is shown in the HTML footer. Default is True. 153 | #html_show_sphinx = True 154 | 155 | # If true, "(C) Copyright ..." is shown in the HTML footer. Default is True. 156 | #html_show_copyright = True 157 | 158 | # If true, an OpenSearch description file will be output, and all pages will 159 | # contain a tag referring to it. The value of this option must be the 160 | # base URL from which the finished HTML is served. 161 | #html_use_opensearch = '' 162 | 163 | # This is the file name suffix for HTML files (e.g. ".xhtml"). 164 | #html_file_suffix = None 165 | 166 | # Output file base name for HTML help builder. 167 | htmlhelp_basename = 'pyramid_formalchemydoc' 168 | 169 | 170 | # -- Options for LaTeX output -------------------------------------------------- 171 | 172 | # The paper size ('letter' or 'a4'). 173 | #latex_paper_size = 'letter' 174 | 175 | # The font size ('10pt', '11pt' or '12pt'). 176 | #latex_font_size = '10pt' 177 | 178 | # Grouping the document tree into LaTeX files. List of tuples 179 | # (source start file, target name, title, author, documentclass [howto/manual]). 180 | latex_documents = [ 181 | ('index', 'pyramid_formalchemy.tex', u'pyramid\\_formalchemy Documentation', 182 | u'Gael Pasgrimaud', 'manual'), 183 | ] 184 | 185 | # The name of an image file (relative to this directory) to place at the top of 186 | # the title page. 187 | #latex_logo = None 188 | 189 | # For "manual" documents, if this is true, then toplevel headings are parts, 190 | # not chapters. 191 | #latex_use_parts = False 192 | 193 | # If true, show page references after internal links. 194 | #latex_show_pagerefs = False 195 | 196 | # If true, show URL addresses after external links. 197 | #latex_show_urls = False 198 | 199 | # Additional stuff for the LaTeX preamble. 200 | #latex_preamble = '' 201 | 202 | # Documents to append as an appendix to all manuals. 203 | #latex_appendices = [] 204 | 205 | # If false, no module index is generated. 206 | #latex_domain_indices = True 207 | 208 | 209 | # -- Options for manual page output -------------------------------------------- 210 | 211 | # One entry per manual page. List of tuples 212 | # (source start file, name, description, authors, manual section). 213 | man_pages = [ 214 | ('index', 'pyramid_formalchemy', u'pyramid_formalchemy Documentation', 215 | [u'Gael Pasgrimaud'], 1) 216 | ] 217 | 218 | 219 | # Example configuration for intersphinx: refer to the Python standard library. 220 | intersphinx_mapping = { 221 | 'pyramid': ('http://docs.pylonsproject.org/projects/pyramid/1.0', None), 222 | 'formalchemy': ('http://docs.formalchemy.org/formalchemy/', None), 223 | } 224 | 225 | html_theme = 'nature' 226 | rstctl_exclude = ['fa.jquery.app', 'fa.jquery.pylons'] 227 | 228 | import rstctl 229 | extensions.append('rstctl.sphinx') 230 | del rstctl 231 | 232 | from os import path 233 | pkg_dir = path.abspath(__file__).split('/docs')[0] 234 | setup = path.join(pkg_dir, 'setup.py') 235 | if path.isfile(setup): 236 | for line_ in open(setup): 237 | if line_.startswith("version"): 238 | version = line_.split('=')[-1] 239 | version = version.strip() 240 | version = version.strip("'\"") 241 | release = version 242 | break 243 | del pkg_dir, setup, path 244 | 245 | -------------------------------------------------------------------------------- /docs/index.txt: -------------------------------------------------------------------------------- 1 | .. pyramid_formalchemy documentation master file, created by 2 | sphinx-quickstart on Sat Jan 15 20:18:53 2011. 3 | You can adapt this file completely to your liking, but it should at least 4 | contain the root `toctree` directive. 5 | 6 | =============================================== 7 | Welcome to pyramid_formalchemy's documentation! 8 | =============================================== 9 | 10 | About 11 | ===== 12 | 13 | ``pyramid_formalchemy`` provides a CRUD interface for ``pyramid`` based on ``FormAlchemy`` 14 | 15 | It also allows to use ``FormAlchemy`` to render forms in your application. 16 | 17 | Installation 18 | ============ 19 | 20 | pyramid_formalchemy must be a dependency of you application, so you 21 | must add "pyramid_formalchemy" as a dependency in your setup.py under 22 | install_requires. You must now update your environment, in case of 23 | buildout, by running a new buildout. If you want nicer jquery 24 | functionality also add a dependency for ``fa.jquery``. 25 | 26 | pyramid_formalchemy also provides a pyramid scaffold. It can be used to 27 | add a skeleton to an existing project or to create a new project. If you 28 | create a new project, you must first install pyramid_formalchemy in 29 | your python environment, either with pip:: 30 | 31 | $ pip install pyramid_formalchemy pyramid_fanstatic fa.jquery 32 | 33 | or with easy_install:: 34 | 35 | $ easy_install pyramid_formalchemy pyramid_fanstatic fa.jquery 36 | 37 | Only after that, the pyramid scaffold becomes available. 38 | The template was made with the idea that it can be used to extend 39 | existing applications. It does not create an app for you. For 40 | bootstrapping your app, you need another pyramid scaffold. The provided 41 | template works well with ``alchemy``, ``Akhet``. To bootstrap an application, 42 | call paster like that:: 43 | 44 | $ pcreate -s alchemy -s pyramid_fa myapp 45 | 46 | Or for ``Akhet``:: 47 | 48 | $ pcreate -s akhet -s pyramid_fa myapp 49 | 50 | The application is created by akhet, akhet does not know about 51 | pyramid_formalchemy, and pyramid_formalchemy cannot modify the app 52 | configuration. So you have to do this by hand. First, you must add the 53 | install dependency like explained earlier. Second, you must add the 54 | following line in the main method 55 | that returns the wsgi app, directly after Configurator has been 56 | created (The example assumes that the Configurator instance is stored 57 | under the name "config"):: 58 | 59 | ... 60 | config.include('myapp.fainit') 61 | ... 62 | 63 | More details are explained in ``myapp/README_FORMALCHEMY.txt``. 64 | The process is the same for other templates. For the pyramid ones 65 | there are additional changes necessary that are also explained in fareadme.txt 66 | 67 | To add the minimum configuration to an existing application, you 68 | should be able to run:: 69 | 70 | $ pcreate -s pyramid_fa myapp 71 | 72 | All files that paster creates are prefixed with fa, and should not 73 | interfere with existing code. The other customizations described for 74 | fresh applications are also valid for existing apps. 75 | 76 | Basic usage 77 | ============ 78 | 79 | Add an empty ``forms.py`` module at the root of your project. 80 | 81 | Now you just need to include two lines of configuration in the ``__init__.main()`` function of your project. 82 | Here is the one used for testing: 83 | 84 | .. literalinclude:: ../pyramidapp/pyramidapp/__init__.py 85 | 86 | This will render the **basic** formalchemy interface. 87 | 88 | It's better to enable the jquery features like this: 89 | 90 | .. literalinclude:: ../pyramidapp/pyramidapp/jquery.py 91 | :pyobject: main 92 | 93 | 94 | That's it. Now launch your app, browse ``/admin/`` and enjoy it ! 95 | 96 | 97 | About Models 98 | ============= 99 | 100 | Here is a typical model to use full features of pyramid_formalchemy. Notice 101 | that the fields are defined using :py:func:`formalchemy.Column`: 102 | 103 | .. literalinclude:: ../../formalchemy_project/models.py 104 | :pyobject: User 105 | 106 | See also :mod:`pyramid_formalchemy.actions` to customize form buttons per model. 107 | 108 | Advanced usage 109 | =============== 110 | 111 | Custom view, factory, forms 112 | ---------------------------- 113 | 114 | In the toward examples we just pass a ``package`` parameter to 115 | :func:`~pyramid_formalchemy.configure`. By default the function will try to 116 | load ``package.models``, ``package.models.DBSession`` and ``package.forms`` but 117 | you can override this. In this case you don't need to specify a package:: 118 | 119 | 120 | config.formalchemy_admin(config, 121 | forms='formalchemy_project.forms', 122 | models='formalchemy_project.mymodels', 123 | session_factory='formalchemy_project.session.Session', 124 | ) 125 | 126 | You can also change the path ``prefix`` used. pyramid_formalchemy will use 127 | ``/admin/`` by default. See :func:`~pyramid_formalchemy.configure`. 128 | 129 | Having fun with the query_factory parameter 130 | ------------------------------------------- 131 | 132 | .. literalinclude:: ../../formalchemy_project/__init__.py 133 | :pyobject: main 134 | 135 | Custom views per model 136 | ---------------------- 137 | 138 | You can also register custom CRUD views per ModelListing:: 139 | 140 | 141 | config.formalchemy_model_view('admin', 142 | model='pyramidapp.models.Foo', 143 | context='pyramid_formalchemy.resources.ModelListing', 144 | renderer='templates/foolisting.pt', 145 | attr='listing', 146 | request_method='GET', 147 | permission='view') 148 | 149 | and per Model:: 150 | 151 | 152 | config.formalchemy_model_view('admin', 153 | model='pyramidapp.models.Foo', 154 | context='pyramid_formalchemy.resources.Model', 155 | name='', 156 | renderer='templates/fooshow.pt', 157 | attr='show', 158 | request_method='GET', 159 | permission='view') 160 | 161 | Events 162 | ======= 163 | 164 | pyramid_formalchemy got some hooks to help you to customize things. See :mod:`pyramid_formalchemy.events`. 165 | 166 | Actions 167 | ======= 168 | 169 | pyramid_formalchemy allow you to customize links and actions of your views. See :mod:`pyramid_formalchemy.actions`. 170 | 171 | Setting permissions 172 | =================== 173 | 174 | pyramid_formalchemy takes care of some ``__acl__`` attributes. 175 | 176 | Setting permissions for the global interface 177 | --------------------------------------------- 178 | 179 | You just need to subclass the default factory in your application: 180 | 181 | .. literalinclude:: ../pyramidapp/pyramidapp/security.py 182 | 183 | Setting permissions per model 184 | ----------------------------- 185 | 186 | You can also add an ``__acl__`` attribute to your model class: 187 | 188 | .. literalinclude:: ../pyramidapp/pyramidapp/models.py 189 | :pyobject: Bar 190 | 191 | Api 192 | === 193 | 194 | .. toctree:: 195 | :maxdepth: 2 196 | 197 | modules/index.txt 198 | 199 | Indices and tables 200 | ================== 201 | 202 | * :ref:`genindex` 203 | * :ref:`modindex` 204 | * :ref:`search` 205 | 206 | -------------------------------------------------------------------------------- /pyramid_formalchemy/__init__.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | from pyramid.httpexceptions import HTTPFound 3 | from pyramid_formalchemy.resources import Models 4 | 5 | 6 | def includeme(config): 7 | """include formalchemy's zcml""" 8 | config.add_translation_dirs('formalchemy:i18n_resources/', 9 | 'pyramid_formalchemy:locale/') 10 | config.add_static_view('fa_admin', 'pyramid_formalchemy:static') 11 | config.add_directive('formalchemy_admin', 12 | 'pyramid_formalchemy.formalchemy_admin') 13 | config.add_directive('formalchemy_model', 14 | 'pyramid_formalchemy.formalchemy_model') 15 | config.add_directive('formalchemy_model_view', 16 | 'pyramid_formalchemy.formalchemy_model_view') 17 | config.registry.pyramid_formalchemy_views = {} 18 | 19 | config.add_route('set_language', '/set_language') 20 | config.add_view('pyramid_formalchemy.views.set_language', 21 | route_name='set_language') 22 | config.add_route('set_theme', '/set_theme') 23 | config.add_view('pyramid_formalchemy.views.set_theme', 24 | route_name='set_theme') 25 | 26 | 27 | def formalchemy_model_view(config, route_name, 28 | model=None, 29 | name='', 30 | view='pyramid_formalchemy.views.ModelView', 31 | context='pyramid_formalchemy.resources.Model', 32 | **kwargs): 33 | """custom model view registration""" 34 | 35 | model = config.maybe_dotted(model) 36 | context = config.maybe_dotted(context) 37 | mixin_name = '%sCustom%s_%s_%s_%s' % (model.__name__, context.__name__, 38 | route_name, name, 39 | kwargs.get('request_method', 'GET')) 40 | 41 | factory = type(mixin_name, (context,), {}) 42 | config.registry.pyramid_formalchemy_views[factory.__name__] = factory 43 | 44 | kw = dict(route_name=route_name, view=view) 45 | kw.update(kwargs) 46 | 47 | config.add_view(context=factory, 48 | name=name, 49 | **kw) 50 | 51 | 52 | def formalchemy_model(config, route_name, 53 | factory='pyramid_formalchemy.resources.ModelListing', 54 | view='pyramid_formalchemy.views.ModelView', model=None, 55 | **kwargs): 56 | model = config.maybe_dotted(model) 57 | return formalchemy_admin(config, route_name, factory=factory, 58 | view=view, models=[model], model=model, **kwargs) 59 | 60 | 61 | def formalchemy_admin(config, route_name, 62 | factory='pyramid_formalchemy.resources.Models', 63 | view='pyramid_formalchemy.views.ModelView', 64 | package=None, models=None, forms=None, 65 | session_factory=None, 66 | query_factory=None, **kwargs): 67 | """configure formalchemy's admin interface""" 68 | 69 | route_name = route_name.strip('/') 70 | 71 | kw = dict(route_name=route_name, view=view) 72 | 73 | if models: 74 | models = config.maybe_dotted(models) 75 | if forms: 76 | forms = config.maybe_dotted(forms) 77 | 78 | if session_factory: 79 | session_factory = config.maybe_dotted(session_factory) 80 | 81 | if package: 82 | if not models: 83 | models = config.maybe_dotted('%s.models' % package) 84 | if not forms: 85 | forms = config.maybe_dotted('%s.forms' % package) 86 | if not session_factory: 87 | session_factory = config.maybe_dotted( 88 | '%s.models.DBSession' % package) 89 | 90 | if not query_factory: 91 | def query_factory(request, query, id=None): 92 | if id is not None: 93 | return query.get(id) 94 | else: 95 | return query 96 | 97 | factory_args = { 98 | '__forms__': forms, 99 | '__models__': models, 100 | '__model_class__': kwargs.get('model'), 101 | '__session_factory__': session_factory, 102 | '__query_factory__': staticmethod(query_factory), 103 | '__fa_route_name__': route_name, 104 | } 105 | 106 | factory = config.maybe_dotted(factory) 107 | 108 | factory = type('%s_%s' % (factory.__name__, route_name), (factory,), 109 | factory_args) 110 | 111 | def redirect(request): 112 | """redirect /route_name to /route_name/""" 113 | matchdict = request.matchdict.copy() 114 | url = request.route_url(route_name, traverse=(), **matchdict) 115 | return HTTPFound(location=url) 116 | 117 | config.add_route('%s_redirect' % route_name, route_name) 118 | config.add_view(redirect, route_name='%s_redirect' % route_name) 119 | 120 | config.add_route(route_name, '%s/*traverse' % route_name, 121 | factory=factory) 122 | 123 | if issubclass(factory, Models): 124 | # don't want all models 125 | config.add_view( 126 | context=factory, 127 | renderer='pyramid_formalchemy:templates/admin/models.pt', 128 | attr='models', 129 | request_method='GET', 130 | permission='view', 131 | **kw) 132 | 133 | config.add_view(context='pyramid_formalchemy.resources.ModelListing', 134 | renderer='pyramid_formalchemy:templates/admin/listing.pt', 135 | attr='listing', 136 | request_method='GET', 137 | permission='view', 138 | **kw) 139 | 140 | config.add_view(context='pyramid_formalchemy.resources.ModelListing', 141 | renderer='pyramid_formalchemy:templates/admin/new.pt', 142 | name='new', 143 | attr='new', 144 | request_method='GET', 145 | permission='new', 146 | **kw) 147 | 148 | config.add_view(context='pyramid_formalchemy.resources.ModelListing', 149 | renderer='pyramid_formalchemy:templates/admin/new.pt', 150 | attr='create', 151 | request_method='POST', 152 | permission='new', 153 | **kw) 154 | 155 | config.add_view(context='pyramid_formalchemy.resources.Model', 156 | renderer='pyramid_formalchemy:templates/admin/edit.pt', 157 | name='edit', 158 | attr='edit', 159 | request_method='GET', 160 | permission='edit', 161 | **kw) 162 | 163 | config.add_view(context='pyramid_formalchemy.resources.Model', 164 | renderer='pyramid_formalchemy:templates/admin/edit.pt', 165 | name='edit', 166 | attr='update', 167 | request_method='POST', 168 | permission='edit', 169 | **kw) 170 | 171 | config.add_view(context='pyramid_formalchemy.resources.Model', 172 | renderer='json', 173 | name='', 174 | attr='update', 175 | request_method='POST', 176 | permission='edit', 177 | **kw) 178 | 179 | config.add_view(context='pyramid_formalchemy.resources.Model', 180 | renderer='pyramid_formalchemy:templates/admin/edit.pt', 181 | name='delete', 182 | attr='delete', 183 | request_method='POST', 184 | permission='delete', 185 | **kw) 186 | 187 | config.add_view(context='pyramid_formalchemy.resources.Model', 188 | renderer='pyramid_formalchemy:templates/admin/edit.pt', 189 | attr='delete', 190 | request_method='DELETE', 191 | permission='delete', 192 | **kw) 193 | 194 | config.add_view(context='pyramid_formalchemy.resources.Model', 195 | renderer='pyramid_formalchemy:templates/admin/show.pt', 196 | request_method='GET', 197 | permission='view', 198 | name='', 199 | attr='show', 200 | **kw) 201 | 202 | config.add_view(context='pyramid_formalchemy.resources.ModelListing', 203 | attr='autocomplete', 204 | name='autocomplete', 205 | request_method='GET', 206 | permission='view', 207 | **kw) 208 | -------------------------------------------------------------------------------- /pyramid_formalchemy/events.py: -------------------------------------------------------------------------------- 1 | import zope.component 2 | __doc__ = """ 3 | Event subscription 4 | ================== 5 | 6 | ``pyramid_formalchemy`` provides four events: ``IBeforeValidateEvent``, 7 | ``IAfterSyncEvent``, ``IBeforeDeleteEvent`` and ``IBeforeRenderEvent``. 8 | There are also two more specific render evnts: ``IBeforeShowRenderEvent`` 9 | and ``IBeforeEditRenderEvent``. You can use ``pyramid_formalchemy.events.subscriber`` 10 | decorator to subscribe: 11 | 12 | .. literalinclude:: ../../pyramidapp/pyramidapp/events.py 13 | 14 | """ 15 | 16 | 17 | class IBeforeValidateEvent(zope.component.interfaces.IObjectEvent): 18 | """A model will be validated""" 19 | 20 | 21 | class IAfterSyncEvent(zope.component.interfaces.IObjectEvent): 22 | """A model was synced with DB""" 23 | 24 | 25 | class IBeforeDeleteEvent(zope.component.interfaces.IObjectEvent): 26 | """A model will be deleted""" 27 | 28 | 29 | class IBeforeRenderEvent(zope.component.interfaces.IObjectEvent): 30 | """A model will rendered""" 31 | 32 | 33 | class IBeforeListingRenderEvent(IBeforeRenderEvent): 34 | """Listing will be rendered""" 35 | 36 | 37 | class IBeforeShowRenderEvent(IBeforeRenderEvent): 38 | """Show will be rendered""" 39 | 40 | 41 | class IBeforeEditRenderEvent(IBeforeRenderEvent): 42 | """Edit will be rendered""" 43 | 44 | 45 | class BeforeValidateEvent(zope.component.interfaces.ObjectEvent): 46 | """A model will be validated""" 47 | zope.interface.implements(IBeforeValidateEvent) 48 | 49 | def __init__(self, object, fs, request): 50 | self.object = object 51 | self.fs = fs 52 | self.request = request 53 | 54 | 55 | class AfterSyncEvent(zope.component.interfaces.ObjectEvent): 56 | """A model was synced with DB""" 57 | zope.interface.implements(IAfterSyncEvent) 58 | 59 | def __init__(self, object, fs, request): 60 | self.object = object 61 | self.fs = fs 62 | self.request = request 63 | 64 | class BeforeDeleteEvent(zope.component.interfaces.ObjectEvent): 65 | """A model will be deleted""" 66 | zope.interface.implements(IBeforeDeleteEvent) 67 | 68 | def __init__(self, object, request): 69 | self.object = object 70 | self.request = request 71 | 72 | 73 | class BeforeRenderEvent(zope.component.interfaces.ObjectEvent): 74 | """A model will rendered""" 75 | zope.interface.implements(IBeforeRenderEvent) 76 | 77 | def __init__(self, object, request, **kwargs): 78 | self.object = object 79 | self.request = request 80 | self.kwargs = kwargs 81 | 82 | class subscriber(object): 83 | """event subscriber decorator""" 84 | 85 | def __init__(self, ifaces): 86 | self.ifaces = ifaces 87 | 88 | def __call__(self, func): 89 | zope.component.provideHandler(func, self.ifaces) 90 | -------------------------------------------------------------------------------- /pyramid_formalchemy/i18n.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | from pyramid.i18n import TranslationStringFactory 3 | from pyramid.i18n import TranslationString 4 | from pyramid.i18n import get_localizer 5 | 6 | _ = TranslationStringFactory('pyramid_formalchemy') 7 | 8 | class I18NModel(object): 9 | 10 | def __init__(self, context, request): 11 | self.context = context 12 | self.request = request 13 | 14 | @property 15 | def label(self): 16 | return getattr(self.context, '__label__', self.context.__name__) 17 | 18 | @property 19 | def plural(self): 20 | value = getattr(self.context, '__plural__', None) 21 | if value: 22 | return value 23 | else: 24 | return self.label 25 | 26 | def __getattr__(self, attr): 27 | return getattr(self.context, attr) 28 | 29 | -------------------------------------------------------------------------------- /pyramid_formalchemy/locale/de/LC_MESSAGES/pyramid_formalchemy.mo: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FormAlchemy/pyramid_formalchemy/62919df6c88230e80b48c0e70932ddc115f0821c/pyramid_formalchemy/locale/de/LC_MESSAGES/pyramid_formalchemy.mo -------------------------------------------------------------------------------- /pyramid_formalchemy/locale/de/LC_MESSAGES/pyramid_formalchemy.po: -------------------------------------------------------------------------------- 1 | # Translations template for pyramid_formalchemy. 2 | # Copyright (C) 2011 ORGANIZATION 3 | # This file is distributed under the same license as the pyramid_formalchemy 4 | # project. 5 | # FIRST AUTHOR , 2011. 6 | # 7 | msgid "" 8 | msgstr "" 9 | "Project-Id-Version: pyramid_formalchemy 0.4.2dev\n" 10 | "Report-Msgid-Bugs-To: EMAIL@ADDRESS\n" 11 | "POT-Creation-Date: 2011-08-14 15:23+0200\n" 12 | "PO-Revision-Date: 2011-10-05 14:32+0100\n" 13 | "Last-Translator: Andreas Kaiser \n" 14 | "Language-Team: GERMAN \n" 15 | "MIME-Version: 1.0\n" 16 | "Content-Type: text/plain; charset=utf-8\n" 17 | "Content-Transfer-Encoding: 8bit\n" 18 | "Generated-By: Babel 0.9.6\n" 19 | "X-Poedit-Language: German\n" 20 | "X-Poedit-Country: GERMANY\n" 21 | "X-Poedit-SourceCharset: utf-8\n" 22 | 23 | #: pyramid_formalchemy/actions.py:327 24 | msgid "French" 25 | msgstr "Französisch" 26 | 27 | #: pyramid_formalchemy/actions.py:328 28 | msgid "English" 29 | msgstr "Englisch" 30 | 31 | #: pyramid_formalchemy/actions.py:329 32 | msgid "Brazilian" 33 | msgstr "Brasilianisch" 34 | 35 | #: pyramid_formalchemy/actions.py:391 36 | msgid "New ${model_label}" 37 | msgstr "Hinzufügen: ${model_label}" 38 | 39 | #: pyramid_formalchemy/actions.py:400 40 | msgid "Save" 41 | msgstr "Speichern" 42 | 43 | #: pyramid_formalchemy/actions.py:408 44 | msgid "Save and add another" 45 | msgstr "Speichern und weitere Hinzufügen" 46 | 47 | #: pyramid_formalchemy/actions.py:418 48 | msgid "Edit" 49 | msgstr "Bearbeiten" 50 | 51 | #: pyramid_formalchemy/actions.py:426 52 | msgid "Back" 53 | msgstr "Zurück" 54 | 55 | #: pyramid_formalchemy/actions.py:433 56 | msgid "Delete" 57 | msgstr "Löschen" 58 | 59 | #: pyramid_formalchemy/actions.py:444 60 | msgid "Cancel" 61 | msgstr "Abbrechen" 62 | 63 | -------------------------------------------------------------------------------- /pyramid_formalchemy/locale/fr/LC_MESSAGES/pyramid_formalchemy.mo: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FormAlchemy/pyramid_formalchemy/62919df6c88230e80b48c0e70932ddc115f0821c/pyramid_formalchemy/locale/fr/LC_MESSAGES/pyramid_formalchemy.mo -------------------------------------------------------------------------------- /pyramid_formalchemy/locale/fr/LC_MESSAGES/pyramid_formalchemy.po: -------------------------------------------------------------------------------- 1 | # French translations for pyramid_formalchemy. 2 | # Copyright (C) 2011 ORGANIZATION 3 | # This file is distributed under the same license as the pyramid_formalchemy 4 | # project. 5 | # FIRST AUTHOR , 2011. 6 | # 7 | msgid "" 8 | msgstr "" 9 | "Project-Id-Version: pyramid_formalchemy 0.3\n" 10 | "Report-Msgid-Bugs-To: EMAIL@ADDRESS\n" 11 | "POT-Creation-Date: 2011-08-14 15:23+0200\n" 12 | "PO-Revision-Date: 2011-06-21 16:44+0200\n" 13 | "Last-Translator: FULL NAME \n" 14 | "Language-Team: fr \n" 15 | "Plural-Forms: nplurals=2; plural=(n > 1)\n" 16 | "MIME-Version: 1.0\n" 17 | "Content-Type: text/plain; charset=utf-8\n" 18 | "Content-Transfer-Encoding: 8bit\n" 19 | "Generated-By: Babel 0.9.6\n" 20 | 21 | #: pyramid_formalchemy/actions.py:327 22 | msgid "French" 23 | msgstr "Français" 24 | 25 | #: pyramid_formalchemy/actions.py:328 26 | msgid "English" 27 | msgstr "Anglais" 28 | 29 | #: pyramid_formalchemy/actions.py:329 30 | msgid "Brazilian" 31 | msgstr "Brésilien" 32 | 33 | #: pyramid_formalchemy/actions.py:391 34 | msgid "New ${model_label}" 35 | msgstr "Nouveau ${model_label}" 36 | 37 | #: pyramid_formalchemy/actions.py:400 38 | msgid "Save" 39 | msgstr "Sauver" 40 | 41 | #: pyramid_formalchemy/actions.py:408 42 | msgid "Save and add another" 43 | msgstr "Sauver et ajouter un autre" 44 | 45 | #: pyramid_formalchemy/actions.py:418 46 | msgid "Edit" 47 | msgstr "Editer" 48 | 49 | #: pyramid_formalchemy/actions.py:426 50 | msgid "Back" 51 | msgstr "Retour" 52 | 53 | #: pyramid_formalchemy/actions.py:433 54 | msgid "Delete" 55 | msgstr "Supprimer" 56 | 57 | #: pyramid_formalchemy/actions.py:444 58 | msgid "Cancel" 59 | msgstr "Annuler" 60 | 61 | -------------------------------------------------------------------------------- /pyramid_formalchemy/locale/pt_BR/LC_MESSAGES/pyramid_formalchemy.mo: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FormAlchemy/pyramid_formalchemy/62919df6c88230e80b48c0e70932ddc115f0821c/pyramid_formalchemy/locale/pt_BR/LC_MESSAGES/pyramid_formalchemy.mo -------------------------------------------------------------------------------- /pyramid_formalchemy/locale/pt_BR/LC_MESSAGES/pyramid_formalchemy.po: -------------------------------------------------------------------------------- 1 | # Portuguese (Brazil) translations for pyramid_formalchemy. 2 | # Copyright (C) 2011 ORGANIZATION 3 | # This file is distributed under the same license as the pyramid_formalchemy 4 | # project. 5 | # FIRST AUTHOR , 2011. 6 | # 7 | msgid "" 8 | msgstr "" 9 | "Project-Id-Version: pyramid_formalchemy 0.4\n" 10 | "Report-Msgid-Bugs-To: EMAIL@ADDRESS\n" 11 | "POT-Creation-Date: 2011-08-14 15:23+0200\n" 12 | "PO-Revision-Date: 2011-08-01 20:48-0300\n" 13 | "Last-Translator: Rodrigo Ferreira de Souza \n" 14 | "Language-Team: pt_BR \n" 15 | "Plural-Forms: nplurals=2; plural=(n > 1)\n" 16 | "MIME-Version: 1.0\n" 17 | "Content-Type: text/plain; charset=utf-8\n" 18 | "Content-Transfer-Encoding: 8bit\n" 19 | "Generated-By: Babel 0.9.6\n" 20 | 21 | #: pyramid_formalchemy/actions.py:327 22 | msgid "French" 23 | msgstr "Francês" 24 | 25 | #: pyramid_formalchemy/actions.py:328 26 | msgid "English" 27 | msgstr "Inglês" 28 | 29 | #: pyramid_formalchemy/actions.py:329 30 | msgid "Brazilian" 31 | msgstr "" 32 | 33 | #: pyramid_formalchemy/actions.py:391 34 | msgid "New ${model_label}" 35 | msgstr "Novo ${model_label}" 36 | 37 | #: pyramid_formalchemy/actions.py:400 38 | msgid "Save" 39 | msgstr "Salvar" 40 | 41 | #: pyramid_formalchemy/actions.py:408 42 | msgid "Save and add another" 43 | msgstr "Salvar e adicionar mais um" 44 | 45 | #: pyramid_formalchemy/actions.py:418 46 | msgid "Edit" 47 | msgstr "Editar" 48 | 49 | #: pyramid_formalchemy/actions.py:426 50 | msgid "Back" 51 | msgstr "Voltar" 52 | 53 | #: pyramid_formalchemy/actions.py:433 54 | msgid "Delete" 55 | msgstr "Apagar" 56 | 57 | #: pyramid_formalchemy/actions.py:444 58 | msgid "Cancel" 59 | msgstr "Cancelar" 60 | 61 | -------------------------------------------------------------------------------- /pyramid_formalchemy/locale/pyramid_formalchemy.pot: -------------------------------------------------------------------------------- 1 | # Translations template for pyramid_formalchemy. 2 | # Copyright (C) 2011 ORGANIZATION 3 | # This file is distributed under the same license as the pyramid_formalchemy 4 | # project. 5 | # FIRST AUTHOR , 2011. 6 | # 7 | #, fuzzy 8 | msgid "" 9 | msgstr "" 10 | "Project-Id-Version: pyramid_formalchemy 0.4.2dev\n" 11 | "Report-Msgid-Bugs-To: EMAIL@ADDRESS\n" 12 | "POT-Creation-Date: 2011-08-14 15:23+0200\n" 13 | "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" 14 | "Last-Translator: FULL NAME \n" 15 | "Language-Team: LANGUAGE \n" 16 | "MIME-Version: 1.0\n" 17 | "Content-Type: text/plain; charset=utf-8\n" 18 | "Content-Transfer-Encoding: 8bit\n" 19 | "Generated-By: Babel 0.9.6\n" 20 | 21 | #: pyramid_formalchemy/actions.py:327 22 | msgid "French" 23 | msgstr "" 24 | 25 | #: pyramid_formalchemy/actions.py:328 26 | msgid "English" 27 | msgstr "" 28 | 29 | #: pyramid_formalchemy/actions.py:329 30 | msgid "Brazilian" 31 | msgstr "" 32 | 33 | #: pyramid_formalchemy/actions.py:391 34 | msgid "New ${model_label}" 35 | msgstr "" 36 | 37 | #: pyramid_formalchemy/actions.py:400 38 | msgid "Save" 39 | msgstr "" 40 | 41 | #: pyramid_formalchemy/actions.py:408 42 | msgid "Save and add another" 43 | msgstr "" 44 | 45 | #: pyramid_formalchemy/actions.py:418 46 | msgid "Edit" 47 | msgstr "" 48 | 49 | #: pyramid_formalchemy/actions.py:426 50 | msgid "Back" 51 | msgstr "" 52 | 53 | #: pyramid_formalchemy/actions.py:433 54 | msgid "Delete" 55 | msgstr "" 56 | 57 | #: pyramid_formalchemy/actions.py:444 58 | msgid "Cancel" 59 | msgstr "" 60 | 61 | -------------------------------------------------------------------------------- /pyramid_formalchemy/locale/ru/LC_MESSAGES/pyramid_formalchemy.mo: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FormAlchemy/pyramid_formalchemy/62919df6c88230e80b48c0e70932ddc115f0821c/pyramid_formalchemy/locale/ru/LC_MESSAGES/pyramid_formalchemy.mo -------------------------------------------------------------------------------- /pyramid_formalchemy/locale/ru/LC_MESSAGES/pyramid_formalchemy.po: -------------------------------------------------------------------------------- 1 | # Gujarati translations for pyramid_formalchemy. 2 | # Copyright (C) 2011 ORGANIZATION 3 | # This file is distributed under the same license as the pyramid_formalchemy 4 | # project. 5 | # FIRST AUTHOR , 2011. 6 | # 7 | msgid "" 8 | msgstr "" 9 | "Project-Id-Version: pyramid_formalchemy 0.4.2dev\n" 10 | "Report-Msgid-Bugs-To: EMAIL@ADDRESS\n" 11 | "POT-Creation-Date: 2011-08-14 15:23+0200\n" 12 | "PO-Revision-Date: 2012-05-04 10:30+0700\n" 13 | "Last-Translator: rda \n" 14 | "Language-Team: ru \n" 15 | "Plural-Forms: nplurals=2; plural=(n != 1)\n" 16 | "MIME-Version: 1.0\n" 17 | "Content-Type: text/plain; charset=utf-8\n" 18 | "Content-Transfer-Encoding: 8bit\n" 19 | "Generated-By: Babel 0.9.6\n" 20 | 21 | #: pyramid_formalchemy/actions.py:327 22 | msgid "French" 23 | msgstr "Французский" 24 | 25 | #: pyramid_formalchemy/actions.py:328 26 | msgid "English" 27 | msgstr "Английский" 28 | 29 | #: pyramid_formalchemy/actions.py:329 30 | msgid "Brazilian" 31 | msgstr "Бразильский" 32 | 33 | #: pyramid_formalchemy/actions.py:391 34 | msgid "New ${model_label}" 35 | msgstr "Добавить ${model_label}" 36 | 37 | #: pyramid_formalchemy/actions.py:400 38 | msgid "Save" 39 | msgstr "Сохранить" 40 | 41 | #: pyramid_formalchemy/actions.py:408 42 | msgid "Save and add another" 43 | msgstr "Сохранить и продолжить добавление" 44 | 45 | #: pyramid_formalchemy/actions.py:418 46 | msgid "Edit" 47 | msgstr "Редактировать" 48 | 49 | #: pyramid_formalchemy/actions.py:426 50 | msgid "Back" 51 | msgstr "Назад" 52 | 53 | #: pyramid_formalchemy/actions.py:433 54 | msgid "Delete" 55 | msgstr "Удалить" 56 | 57 | #: pyramid_formalchemy/actions.py:444 58 | msgid "Cancel" 59 | msgstr "Отмена" 60 | 61 | -------------------------------------------------------------------------------- /pyramid_formalchemy/paster.py: -------------------------------------------------------------------------------- 1 | try: # pyramid 1.0.X 2 | # "pyramid.paster.paste_script..." doesn't exist past 1.0.X 3 | from pyramid.paster import paste_script_template_renderer 4 | from pyramid.paster import PyramidTemplate 5 | except ImportError: 6 | try: # pyramid 1.1.X, 1.2.X 7 | # trying to import "paste_script_template_renderer" fails on 1.3.X 8 | from pyramid.scaffolds import paste_script_template_renderer 9 | from pyramid.scaffolds import PyramidTemplate 10 | except ImportError: # pyramid >=1.3a2 11 | paste_script_template_renderer = None 12 | from pyramid.scaffolds import PyramidTemplate 13 | 14 | 15 | class PyramidFormAlchemyTemplate(PyramidTemplate): 16 | _template_dir = ('pyramid_formalchemy', 'paster_templates/pyramid_fa') 17 | summary = "Pyramid application template to extend other templates with " 18 | "formalchemy" 19 | template_renderer = staticmethod(paste_script_template_renderer) 20 | -------------------------------------------------------------------------------- /pyramid_formalchemy/paster_templates/pyramid_fa/+package+/faforms.py_tmpl: -------------------------------------------------------------------------------- 1 | from formalchemy import forms 2 | from formalchemy import tables 3 | 4 | class FieldSet(forms.FieldSet): 5 | pass 6 | 7 | class Grid(tables.Grid): 8 | pass 9 | -------------------------------------------------------------------------------- /pyramid_formalchemy/paster_templates/pyramid_fa/+package+/fainit.py_tmpl: -------------------------------------------------------------------------------- 1 | from {{package}} import models, faforms 2 | import logging 3 | 4 | log = logging.getLogger(__name__) 5 | 6 | 7 | def includeme(config): 8 | config.include('pyramid_formalchemy') 9 | 10 | try: 11 | # Add fanstatic tween if available 12 | config.include('pyramid_fanstatic') 13 | except ImportError: 14 | log.warn('You should install pyramid_fanstatic or register a fanstatic' 15 | ' middleware by hand') 16 | 17 | try: 18 | # Adding the jquery libraries if available 19 | config.include('fa.jquery') 20 | except ImportError: 21 | model_view = 'pyramid_formalchemy.views.ModelView' 22 | else: 23 | model_view = 'fa.jquery.pyramid.ModelView' 24 | 25 | session_factory = getattr(models, "DBSession", None) 26 | if session_factory is not None: 27 | # pyramid_alchemy 28 | session_factory = '{{package}}.models.DBSession' 29 | else: 30 | # Akhet 31 | session_factory = '{{package}}.models.Session' 32 | 33 | # register session and model_view for later use 34 | settings = {'package': '{{package}}', 35 | 'view': model_view, 36 | 'session_factory': session_factory, 37 | } 38 | config.registry.settings['{{package}}.fa_config'] = settings 39 | 40 | config.formalchemy_admin("/admin", models=models, forms=faforms, 41 | **settings) 42 | 43 | # Adding the package specific routes 44 | config.include('{{package}}.faroutes') 45 | 46 | log.info('formalchemy_admin registered at /admin') 47 | -------------------------------------------------------------------------------- /pyramid_formalchemy/paster_templates/pyramid_fa/+package+/faroutes.py_tmpl: -------------------------------------------------------------------------------- 1 | from {{package}} import models 2 | import logging 3 | 4 | log = logging.getLogger(__name__) 5 | 6 | 7 | def includeme(config): 8 | settings = config.registry.settings.get('{{package}}.fa_settings}}', {}) 9 | 10 | # Example to add a specific model 11 | #config.formalchemy_model("/my_model", package='{{package}}', 12 | # model='{{package}}.models.MyModel') 13 | # **settings) 14 | 15 | log.info('{{package}}.faroutes loaded') 16 | -------------------------------------------------------------------------------- /pyramid_formalchemy/paster_templates/pyramid_fa/README_FORMALCHEMY.txt: -------------------------------------------------------------------------------- 1 | This script does not want to tell you how your app should be set up. 2 | As such, it does not set an app up for you. 3 | 4 | Please use this template together with other templates, like Akhet, 5 | pyramid_routesalchemy or pyramid_alchemy. 6 | 7 | You should add pyramid_fanstatic and fa.jquery as dependencies in your 8 | setup.py. 9 | 10 | To finally include FormAlchemy, modify your main method were you 11 | create the wsgi application, and include {{package}}.fainit to the 12 | configuration, like that: 13 | 14 | >>> config.include("{{package}}.fainit") 15 | 16 | If you are using pyramid_routesalchemy or pyramid_alchemy, 17 | you must modify the models.py. For FormAlchemy to be able to use the 18 | Model, the Model must have a constructer that can be called without 19 | any argument. 20 | So open up models.py and either remove the constructor of MyModel, 21 | or add default values. 22 | 23 | If you are using akhet, nothing special needs to be done. 24 | 25 | After this modifications, you should find the FormAlchemy Admin 26 | Interface under /admin 27 | 28 | 29 | -------------------------------------------------------------------------------- /pyramid_formalchemy/resources.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | from pyramid.exceptions import NotFound 3 | from pyramid_formalchemy import actions 4 | from sqlalchemy import exc as sqlalchemy_exceptions 5 | import logging 6 | 7 | log = logging.getLogger(__name__) 8 | 9 | class Base(object): 10 | """Base class used for all traversed class. 11 | Allow to access to some useful attributes via request:: 12 | 13 | - model_class 14 | - model_name 15 | - model_instance 16 | - model_id 17 | - fa_url 18 | """ 19 | 20 | def __init__(self, request, name): 21 | self.__name__ = name 22 | self.__parent__ = None 23 | self.request = request 24 | if hasattr(self, '__fa_route_name__'): 25 | request.session_factory = self.__session_factory__ 26 | request.query_factory = self.__query_factory__ 27 | request.route_name = self.__fa_route_name__ 28 | request.models = self.__models__ 29 | request.forms = self.__forms__ 30 | request.fa_url = self.fa_url 31 | request.model_instance = None 32 | request.model_class = None 33 | request.model_name = None 34 | request.model_id = None 35 | request.relation = None 36 | request.format = 'html' 37 | if self.__model_class__: 38 | request.model_class = self.__model_class__ 39 | request.model_name = self.__model_class__.__name__ 40 | request.actions = actions.RequestActions() 41 | langs = request.registry.settings.get('available_languages', '') 42 | if langs: 43 | if isinstance(langs, basestring): 44 | langs = langs.split() 45 | request.actions['languages'] = actions.Languages(*langs) 46 | themes = request.registry.settings.get('available_themes', '') 47 | if themes: 48 | if isinstance(themes, basestring): 49 | themes = themes.split() 50 | request.actions['themes'] = actions.Themes(*themes) 51 | 52 | def get_model(self): 53 | request = self.request 54 | if request.model_class: 55 | return request.model_class 56 | model_name = request.model_name 57 | model_class = None 58 | if isinstance(request.models, list): 59 | for model in request.models: 60 | if model.__name__ == model_name: 61 | model_class = model 62 | break 63 | elif hasattr(request.models, model_name): 64 | model_class = getattr(request.models, model_name) 65 | if model_class is None: 66 | raise NotFound(request.path) 67 | request.model_class = model_class 68 | return model_class 69 | 70 | def get_instance(self): 71 | model = self.get_model() 72 | session = self.request.session_factory() 73 | try: 74 | return session.query(model).get(self.request.model_id) 75 | except sqlalchemy_exceptions.InvalidRequestError: 76 | # pyramid 1.4 compat 77 | return session.query(model.context).get(self.request.model_id) 78 | 79 | def _fa_url(self, *args, **kwargs): 80 | matchdict = self.request.matchdict.copy() 81 | if 'traverse' in matchdict: 82 | del matchdict['traverse'] 83 | if kwargs: 84 | matchdict['_query'] = kwargs 85 | return self.request.route_url(self.__fa_route_name__, 86 | traverse=tuple([str(a) for a in args]), 87 | **matchdict) 88 | 89 | 90 | 91 | class Models(Base): 92 | """Root of the CRUD interface""" 93 | 94 | def __init__(self, request): 95 | Base.__init__(self, request, None) 96 | 97 | def fa_url(self, *args, **kwargs): 98 | return self._fa_url(*args, **kwargs) 99 | 100 | def __getitem__(self, item): 101 | if item in ('json', 'xhr'): 102 | self.request.format = item 103 | return self 104 | 105 | self.request.model_name = item 106 | model_class = self.get_model() 107 | mixin_name = '%sCustom%s_%s__%s' % (model_class.__name__, ModelListing.__name__, 108 | self.request.route_name, self.request.method) 109 | mixin = type(mixin_name, (ModelListing, ), {}) 110 | factory = self.request.registry.pyramid_formalchemy_views.get(mixin.__name__, mixin) 111 | model = factory(self.request, item) 112 | model.__parent__ = self 113 | if hasattr(model, '__acl__'): 114 | # propagate permissions to parent 115 | self.__acl__ = model.__acl__ 116 | return model 117 | 118 | class ModelListing(Base): 119 | """Context used for model classes""" 120 | 121 | def __init__(self, request, name=None): 122 | Base.__init__(self, request, name) 123 | if name is None: 124 | # request.model_class and request.model_name are already set 125 | model = request.model_class 126 | else: 127 | request.model_name = name 128 | model = self.get_model() 129 | if hasattr(model, '__acl__'): 130 | # get permissions from SA class 131 | self.__acl__ = model.__acl__ 132 | 133 | def fa_url(self, *args, **kwargs): 134 | return self._fa_url(*args[1:], **kwargs) 135 | 136 | def __getitem__(self, item): 137 | if item in ('json', 'xhr'): 138 | self.request.format = item 139 | return self 140 | 141 | name = self.request.path.split('/')[-1] #view name 142 | if name == item: 143 | name = '' 144 | 145 | mixin_name = '%sCustom%s_%s_%s_%s' % (self.request.model_class.__name__, Model.__name__, 146 | self.request.route_name, name, self.request.method) 147 | mixin = type(str(mixin_name), (Model, ), {}) 148 | factory = self.request.registry.pyramid_formalchemy_views.get(mixin.__name__, mixin) 149 | try: 150 | model = factory(self.request, item) 151 | except NotFound: 152 | raise KeyError() 153 | model.__parent__ = self 154 | return model 155 | 156 | class Model(Base): 157 | """Context used for model instances""" 158 | 159 | def fa_url(self, *args, **kwargs): 160 | return self._fa_url(*args[2:], **kwargs) 161 | 162 | def __init__(self, request, name): 163 | Base.__init__(self, request, name) 164 | query = request.session_factory.query(request.model_class) 165 | try: 166 | request.model_instance = request.query_factory(request, query, id=name) 167 | except sqlalchemy_exceptions.SQLAlchemyError, exc: 168 | log.exception(exc) 169 | request.session_factory().rollback() 170 | raise NotFound(request.path) 171 | 172 | if request.model_instance is None: 173 | raise NotFound(request.path) 174 | request.model_id = name 175 | 176 | -------------------------------------------------------------------------------- /pyramid_formalchemy/static/add.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FormAlchemy/pyramid_formalchemy/62919df6c88230e80b48c0e70932ddc115f0821c/pyramid_formalchemy/static/add.png -------------------------------------------------------------------------------- /pyramid_formalchemy/static/admin.css: -------------------------------------------------------------------------------- 1 | /** 2 | * Blue Box main CSS file 3 | * @version 1.0.0 4 | * @author Aaron D. Campbell http://xavisys.com/ 5 | */ 6 | 7 | html, body, div, span, applet, object, iframe, 8 | h1, h2, h3, h4, h5, h6, p, blockquote, pre, 9 | a, abbr, acronym, address, big, cite, code, 10 | del, dfn, em, font, img, ins, kbd, q, s, samp, 11 | small, strike, strong, sub, sup, tt, var, 12 | dl, dt, dd, ol, ul, li, 13 | fieldset, form, label, legend, 14 | table, caption, tbody, tfoot, thead, tr, th, td { 15 | border: 0; 16 | font-family: inherit; 17 | font-size: 100%; 18 | font-style: inherit; 19 | font-weight: inherit; 20 | margin: 0; 21 | outline: 0; 22 | padding: 0; 23 | vertical-align: baseline; 24 | } 25 | h1,h2,h3,h4,h5,h6 { 26 | font-weight:bold; 27 | } 28 | h1 { 29 | font-size:2em; 30 | } 31 | h2 { 32 | font-size:1.5em; 33 | } 34 | h3 { 35 | font-size:1.3em; 36 | } 37 | h4 { 38 | font-size:1.1em; 39 | } 40 | h5 { 41 | font-size:1em; 42 | } 43 | h6 { 44 | font-size:.8em; 45 | } 46 | 47 | body { 48 | background-color:#D5D6D7; 49 | color:#333; 50 | font:80% Verdana,"Trebuchet MS",Georgia,"Times New Roman",Times,serif; 51 | margin:20px; 52 | min-width:675px; 53 | padding:0pt; 54 | } 55 | 56 | table { 57 | margin:1em; 58 | } 59 | 60 | table, table tr { 61 | border-collapse:collapse; 62 | padding:0; 63 | } 64 | 65 | 66 | table th, 67 | table td { 68 | border:thin solid #D5D6D7; 69 | border-collapse:collapse; 70 | margin:0; 71 | padding:0.2em 0.5em; 72 | } 73 | 74 | table th { 75 | font-weight:bold; 76 | background:#EFEFEF; 77 | } 78 | 79 | td a { 80 | display:block; 81 | } 82 | 83 | tr.odd { 84 | background:#EFEFEF; 85 | } 86 | 87 | p { 88 | line-height:1.5em; 89 | margin:1em 0; 90 | } 91 | 92 | #header { 93 | background-color:#73A0C5; 94 | border:1px solid #666; 95 | border-bottom:none; 96 | height:70px; 97 | position:relative; 98 | } 99 | 100 | #title { 101 | float:left; 102 | margin:5px 0 0 1em; 103 | } 104 | 105 | #header h1 { 106 | font-size:2em; 107 | padding:0pt; 108 | } 109 | #header #tagline { 110 | color:#DDD; 111 | font-size:0.9em; 112 | font-style:italic; 113 | margin:0; 114 | text-align:right; 115 | } 116 | 117 | #header h1, 118 | #header h1 a, 119 | #header h1 a:hover, 120 | #header h1 a:visited { 121 | color:#FFF; 122 | text-decoration:none; 123 | } 124 | 125 | h1#header { 126 | color: white; 127 | height: 1.5em; 128 | padding: 0.3em 1em; 129 | } 130 | 131 | h1#header a { 132 | color: white; 133 | } 134 | 135 | .breadcrumb { float:right; font-size: 0.7em;} 136 | 137 | #nav { 138 | bottom:0; 139 | position:absolute; 140 | right:0; 141 | } 142 | 143 | #nav a { 144 | background-color:#EFEFEF; 145 | border:1px solid #666; 146 | border-bottom:0; 147 | color:#259; 148 | font-size:1.2em; 149 | font-weight:bold; 150 | margin:0 .1em; 151 | padding:.2em; 152 | padding-bottom:0; 153 | text-decoration:none; 154 | } 155 | 156 | #nav a:hover, 157 | #nav a.current { 158 | background-color:#FFF; 159 | } 160 | 161 | #content { 162 | background-color:#FFF; 163 | border:1px solid #666; 164 | border-width:0 1px; 165 | padding:1em; 166 | } 167 | #content ol { 168 | margin-left:2em; 169 | } 170 | #content ul { 171 | margin-left:1.5em; 172 | } 173 | #sidebar { 174 | float:right; 175 | margin:1em; 176 | width:260px; 177 | } 178 | #sidebar .box p { 179 | background-color:#F2F2F2; 180 | margin:.5em; 181 | } 182 | #sidebar .box ul li { 183 | border-bottom:1px solid #73A0C5; 184 | list-style-type:none; 185 | } 186 | #sidebar .box ul li a { 187 | display:block; 188 | padding:.5em; 189 | } 190 | #sidebar .box label { 191 | display:block; 192 | float:left; 193 | height:21px; 194 | margin-right:10px; 195 | width:70px; 196 | } 197 | #footer { 198 | background-color:#EFEFEF; 199 | border:1px solid #666; 200 | border-top:none; 201 | font-size:.8em; 202 | padding:1em; 203 | text-align:center; 204 | } 205 | #footer p { 206 | margin:0; 207 | } 208 | 209 | a, 210 | a:link { 211 | color:#06C; 212 | text-decoration:none; 213 | } 214 | a:visited { 215 | color:#147; 216 | } 217 | a:hover, 218 | a:active { 219 | color:#147; 220 | text-decoration:underline; 221 | } 222 | 223 | blockquote, 224 | code { 225 | background-color:#F2F2F2; 226 | border-left:4px solid #73A0C5; 227 | display:block; 228 | font-style:oblique; 229 | line-height:20px; 230 | margin:0 1em; 231 | padding:0 1em; 232 | } 233 | 234 | code { 235 | white-space:pre; 236 | } 237 | 238 | .box{ 239 | border:1px solid #999; 240 | margin:0 0 1em 0; 241 | overflow:auto; 242 | } 243 | .box p, 244 | .box ul, 245 | .box ol, 246 | .box div.cont, 247 | .box form { 248 | margin:.5em; 249 | } 250 | .box h1, 251 | .box h2, 252 | .box h3, 253 | .box h4, 254 | .box h5, 255 | .box h6 { 256 | background-color:#73A0C5; 257 | display:block; 258 | padding:0 5px; 259 | color:white; 260 | } 261 | .more { 262 | display:block; 263 | font-size:.8em; 264 | text-align:right; 265 | } 266 | 267 | /********* 268 | * Forms * 269 | *********/ 270 | .admin-flash, 271 | fieldset { 272 | color:#777; 273 | margin-top:15px; 274 | padding:10px; 275 | } 276 | 277 | .admin-flash { 278 | background:#EFEFEF; 279 | margin-bottom:15px; 280 | font-weight:bold; 281 | } 282 | 283 | .message, 284 | fieldset, 285 | input, 286 | button, 287 | fieldset textarea, 288 | fieldset select { 289 | border:1px solid #F5F5F5; 290 | border-left-color:#DDD; 291 | border-top-color:#DDD; 292 | } 293 | 294 | legend { 295 | color:#73A0C5; 296 | font-weight:bold; 297 | padding:5px 10px; 298 | } 299 | 300 | input, 301 | button, 302 | fieldset textarea, 303 | fieldset select { 304 | color:#777; 305 | font:90% Verdana; 306 | padding:4px; 307 | } 308 | 309 | fieldset textarea { 310 | width:430px; 311 | } 312 | 313 | option { 314 | padding:0 10px 0 5px; 315 | } 316 | fieldset label, 317 | fieldset p.label { 318 | color:#777; 319 | text-align:right; 320 | width:145px; 321 | } 322 | fieldset label { 323 | float:left; 324 | margin:5px 0; 325 | margin-right:10px; 326 | } 327 | 328 | fieldset p { 329 | margin:0; 330 | } 331 | fieldset div { 332 | padding:5px 0; 333 | position:relative; 334 | } 335 | fieldset div div { 336 | margin:0; 337 | } 338 | fieldset p.label { 339 | left:0; 340 | position:absolute; 341 | } 342 | 343 | .radio { 344 | margin-left:160px; 345 | } 346 | .radio label, 347 | .radio input { 348 | background:none; 349 | border:none; 350 | display:inline; 351 | float:none; 352 | vertical-align:middle; 353 | width:auto; 354 | } 355 | .radio div { 356 | clear:none; 357 | white-space:nowrap; 358 | } 359 | #sidebar form { 360 | margin:0 0 1em 0; 361 | } 362 | 363 | .submit, 364 | #sidebar .submit { 365 | text-align:right; 366 | } 367 | 368 | .ui-widget-link, 369 | .submit input, 370 | #sidebar .submit input { 371 | background-color:#F9F9F9; 372 | border:1px solid #F5F5F5; 373 | border-left-color:#DDD; 374 | border-top-color:#DDD; 375 | cursor:pointer; 376 | padding:0 21px; 377 | text-transform:lowercase; 378 | width:auto; 379 | } 380 | 381 | .ui-widget-link input { 382 | border:0px; 383 | background:transparent; 384 | } 385 | 386 | a.ui-widget-link { 387 | color:#777777; 388 | font-family:Verdana; 389 | } 390 | 391 | .ui-widget-link { 392 | cursor:pointer; 393 | margin-right:0.3em; 394 | } 395 | 396 | 397 | td form { text-align:center;} 398 | 399 | td input.ui-icon { 400 | background-color:transparent; 401 | border:0px; 402 | width:16px; 403 | height: 0px; 404 | overflow:hidden; 405 | padding-bottom:13px; 406 | cursor:pointer; 407 | } 408 | 409 | .ui-icon-pencil { 410 | background-image: url(./edit.png); 411 | } 412 | .ui-icon-circle-close { 413 | background-image: url(./delete.png); 414 | } 415 | 416 | #sidebar input { 417 | border:1px solid #DDD; 418 | border-bottom-color:#F5F5F5; 419 | border-right-color:#F5F5F5; 420 | width:100%; 421 | } 422 | 423 | #sidebar label { 424 | height:auto; 425 | margin-bottom:0; 426 | width:auto; 427 | } 428 | 429 | .button { 430 | width:auto; 431 | } 432 | 433 | .form_controls { 434 | margin-left:155px; 435 | } 436 | 437 | .icon { 438 | display:block; 439 | height:0px; 440 | padding-top:16px; 441 | width:16px; 442 | overflow:hidden; 443 | } 444 | 445 | input.icon { 446 | border:none; 447 | width:16px; 448 | height:16px; 449 | padding:0; 450 | cursor:pointer; 451 | } 452 | 453 | #pager { 454 | text-align: center; 455 | margin-top: 0.5em; 456 | } 457 | #pager a, #pager .pager_curpage { 458 | padding: 0 0.2em; 459 | border:thin solid #114477; 460 | background: #73A0C5; 461 | color: white; 462 | } 463 | 464 | #pager a:hover, #pager .pager_curpage { 465 | text-decoration:none; 466 | background:white; 467 | color:#114477; 468 | } 469 | 470 | /*****************************/ 471 | -------------------------------------------------------------------------------- /pyramid_formalchemy/static/delete.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FormAlchemy/pyramid_formalchemy/62919df6c88230e80b48c0e70932ddc115f0821c/pyramid_formalchemy/static/delete.png -------------------------------------------------------------------------------- /pyramid_formalchemy/static/edit.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FormAlchemy/pyramid_formalchemy/62919df6c88230e80b48c0e70932ddc115f0821c/pyramid_formalchemy/static/edit.png -------------------------------------------------------------------------------- /pyramid_formalchemy/templates/admin/edit.pt: -------------------------------------------------------------------------------- 1 | 2 | 3 |
4 |
5 |
6 | 7 |

8 |

9 | 10 |
11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /pyramid_formalchemy/templates/admin/edit.pt.py: -------------------------------------------------------------------------------- 1 | registry = dict(version=0) 2 | def bind(): 3 | from cPickle import loads as _loads 4 | _lookup_attr = _loads('cchameleon.core.codegen\nlookup_attr\np1\n.') 5 | _init_scope = _loads('cchameleon.core.utils\necontext\np1\n.') 6 | _attrs_4356242384 = _loads('(dp1\n.') 7 | _attrs_4356371600 = _loads('(dp1\n.') 8 | _init_stream = _loads('cchameleon.core.generation\ninitialize_stream\np1\n.') 9 | _attrs_4356243152 = _loads('(dp1\nVclass\np2\nVfa_field\np3\ns.') 10 | _init_default = _loads('cchameleon.core.generation\ninitialize_default\np1\n.') 11 | _attrs_4356370704 = _loads('(dp1\nVaction\np2\nV\nsVmethod\np3\nVPOST\np4\nsVenctype\np5\nVmultipart/form-data\np6\ns.') 12 | _attrs_4356239504 = _loads('(dp1\nVname\np2\nV_method\np3\nsVtype\np4\nVhidden\np5\nsVvalue\np6\nVPUT\np7\ns.') 13 | _init_tal = _loads('cchameleon.core.generation\ninitialize_tal\np1\n.') 14 | def render(econtext, rcontext=None): 15 | macros = econtext.get('macros') 16 | _translate = econtext.get('_translate') 17 | _slots = econtext.get('_slots') 18 | target_language = econtext.get('target_language') 19 | u'_init_stream()' 20 | (_out, _write, ) = _init_stream() 21 | u'_init_tal()' 22 | (_attributes, repeat, ) = _init_tal() 23 | u'_init_default()' 24 | _default = _init_default() 25 | u'None' 26 | default = None 27 | u'None' 28 | _domain = None 29 | u"main.macros['master']" 30 | _metal = _lookup_attr(econtext['main'], 'macros')['master'] 31 | def _callback_main(econtext, _repeat, _out=_out, _write=_write, _domain=_domain, **_ignored): 32 | if _repeat: 33 | repeat.update(_repeat) 34 | attrs = _attrs_4356371600 35 | _write(u'
\n ') 36 | attrs = _attrs_4356370704 37 | u"''" 38 | _write(u'
\n ') 39 | _default.value = default = '' 40 | u'fs.render()' 41 | _content = _lookup_attr(econtext['fs'], 'render')() 42 | attrs = _attrs_4356242384 43 | u'_content' 44 | _write(u'
') 45 | _tmp1 = _content 46 | _tmp = _tmp1 47 | if (_tmp.__class__ not in (str, unicode, int, float, )): 48 | try: 49 | _tmp = _tmp.__html__ 50 | except: 51 | _tmp = _translate(_tmp, domain=_domain, mapping=None, target_language=target_language, default=None) 52 | else: 53 | _tmp = _tmp() 54 | _write(_tmp) 55 | _tmp = None 56 | if (_tmp is not None): 57 | if not isinstance(_tmp, unicode): 58 | _tmp = str(_tmp) 59 | _write(_tmp) 60 | _write(u'
\n ') 61 | attrs = _attrs_4356239504 62 | u"u'\\n '" 63 | _write(u'\n ') 64 | _default.value = default = u'\n ' 65 | u'actions.buttons(request)' 66 | _content = _lookup_attr(econtext['actions'], 'buttons')(econtext['request']) 67 | attrs = _attrs_4356243152 68 | u'_content' 69 | _write(u'

') 70 | _tmp1 = _content 71 | _tmp = _tmp1 72 | if (_tmp.__class__ not in (str, unicode, int, float, )): 73 | try: 74 | _tmp = _tmp.__html__ 75 | except: 76 | _tmp = _translate(_tmp, domain=_domain, mapping=None, target_language=target_language, default=None) 77 | else: 78 | _tmp = _tmp() 79 | _write(_tmp) 80 | _tmp = None 81 | if (_tmp is not None): 82 | if not isinstance(_tmp, unicode): 83 | _tmp = str(_tmp) 84 | _write(_tmp) 85 | _write(u'

\n
\n
\n') 86 | u"{'main': _callback_main}" 87 | _tmp = {'main': _callback_main, } 88 | u"main.macros['master']" 89 | _metal.render(_tmp, _out=_out, _write=_write, _domain=_domain, econtext=econtext) 90 | return _out.getvalue() 91 | return render 92 | 93 | __filename__ = '/Users/gawel/py/formalchemy_project/pyramid_formalchemy/pyramid_formalchemy/templates/admin/edit.pt' 94 | registry[(None, True, '1488bdb950901f8f258549439ef6661a49aae984')] = bind() 95 | -------------------------------------------------------------------------------- /pyramid_formalchemy/templates/admin/listing.pt: -------------------------------------------------------------------------------- 1 | 2 | 3 |
4 |
5 | 6 |

7 |

8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /pyramid_formalchemy/templates/admin/listing.pt.py: -------------------------------------------------------------------------------- 1 | registry = dict(version=0) 2 | def bind(): 3 | from cPickle import loads as _loads 4 | _lookup_attr = _loads('cchameleon.core.codegen\nlookup_attr\np1\n.') 5 | _init_scope = _loads('cchameleon.core.utils\necontext\np1\n.') 6 | _attrs_4353960208 = _loads('(dp1\nVclass\np2\nVlayout-grid\np3\ns.') 7 | _attrs_4353960144 = _loads('(dp1\nVclass\np2\nVui-pager\np3\ns.') 8 | _init_stream = _loads('cchameleon.core.generation\ninitialize_stream\np1\n.') 9 | _attrs_4353960272 = _loads('(dp1\nVclass\np2\nVfa_field\np3\ns.') 10 | _init_default = _loads('cchameleon.core.generation\ninitialize_default\np1\n.') 11 | _attrs_4353960016 = _loads('(dp1\n.') 12 | _init_tal = _loads('cchameleon.core.generation\ninitialize_tal\np1\n.') 13 | def render(econtext, rcontext=None): 14 | macros = econtext.get('macros') 15 | _translate = econtext.get('_translate') 16 | _slots = econtext.get('_slots') 17 | target_language = econtext.get('target_language') 18 | u'_init_stream()' 19 | (_out, _write, ) = _init_stream() 20 | u'_init_tal()' 21 | (_attributes, repeat, ) = _init_tal() 22 | u'_init_default()' 23 | _default = _init_default() 24 | u'None' 25 | default = None 26 | u'None' 27 | _domain = None 28 | u"main.macros['master']" 29 | _metal = _lookup_attr(econtext['main'], 'macros')['master'] 30 | def _callback_main(econtext, _repeat, _out=_out, _write=_write, _domain=_domain, **_ignored): 31 | if _repeat: 32 | repeat.update(_repeat) 33 | attrs = _attrs_4353960016 34 | u"''" 35 | _write(u'
\n ') 36 | _default.value = default = '' 37 | u'pager' 38 | _content = econtext['pager'] 39 | attrs = _attrs_4353960144 40 | u'_content' 41 | _write(u'
') 42 | _tmp1 = _content 43 | _tmp = _tmp1 44 | if (_tmp.__class__ not in (str, unicode, int, float, )): 45 | try: 46 | _tmp = _tmp.__html__ 47 | except: 48 | _tmp = _translate(_tmp, domain=_domain, mapping=None, target_language=target_language, default=None) 49 | else: 50 | _tmp = _tmp() 51 | _write(_tmp) 52 | _tmp = None 53 | if (_tmp is not None): 54 | if not isinstance(_tmp, unicode): 55 | _tmp = str(_tmp) 56 | _write(_tmp) 57 | u"''" 58 | _write(u'
\n ') 59 | _default.value = default = '' 60 | u'fs.render()' 61 | _content = _lookup_attr(econtext['fs'], 'render')() 62 | attrs = _attrs_4353960208 63 | u'_content' 64 | _write(u'
') 65 | _tmp1 = _content 66 | _tmp = _tmp1 67 | if (_tmp.__class__ not in (str, unicode, int, float, )): 68 | try: 69 | _tmp = _tmp.__html__ 70 | except: 71 | _tmp = _translate(_tmp, domain=_domain, mapping=None, target_language=target_language, default=None) 72 | else: 73 | _tmp = _tmp() 74 | _write(_tmp) 75 | _tmp = None 76 | if (_tmp is not None): 77 | if not isinstance(_tmp, unicode): 78 | _tmp = str(_tmp) 79 | _write(_tmp) 80 | u"u'\\n '" 81 | _write(u'
\n ') 82 | _default.value = default = u'\n ' 83 | u'actions.buttons(request)' 84 | _content = _lookup_attr(econtext['actions'], 'buttons')(econtext['request']) 85 | attrs = _attrs_4353960272 86 | u'_content' 87 | _write(u'

') 88 | _tmp1 = _content 89 | _tmp = _tmp1 90 | if (_tmp.__class__ not in (str, unicode, int, float, )): 91 | try: 92 | _tmp = _tmp.__html__ 93 | except: 94 | _tmp = _translate(_tmp, domain=_domain, mapping=None, target_language=target_language, default=None) 95 | else: 96 | _tmp = _tmp() 97 | _write(_tmp) 98 | _tmp = None 99 | if (_tmp is not None): 100 | if not isinstance(_tmp, unicode): 101 | _tmp = str(_tmp) 102 | _write(_tmp) 103 | _write(u'

\n
\n') 104 | u"{'main': _callback_main}" 105 | _tmp = {'main': _callback_main, } 106 | u"main.macros['master']" 107 | _metal.render(_tmp, _out=_out, _write=_write, _domain=_domain, econtext=econtext) 108 | return _out.getvalue() 109 | return render 110 | 111 | __filename__ = '/Users/gawel/py/formalchemy_project/pyramid_formalchemy/pyramid_formalchemy/templates/admin/listing.pt' 112 | registry[(None, True, '1488bdb950901f8f258549439ef6661a49aae984')] = bind() 113 | -------------------------------------------------------------------------------- /pyramid_formalchemy/templates/admin/master.pt: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /pyramid_formalchemy/templates/admin/master.pt.py: -------------------------------------------------------------------------------- 1 | registry = dict(version=0) 2 | def bind(): 3 | from cPickle import loads as _loads 4 | _attrs_4353373456 = _loads('(dp1\nVrel\np2\nVstylesheet\np3\ns.') 5 | _lookup_attr = _loads('cchameleon.core.codegen\nlookup_attr\np1\n.') 6 | _init_scope = _loads('cchameleon.core.utils\necontext\np1\n.') 7 | _re_amp = _loads("cre\n_compile\np1\n(S'&(?!([A-Za-z]+|#[0-9]+);)'\np2\nI0\ntRp3\n.") 8 | _attrs_4353342480 = _loads('(dp1\n.') 9 | _attrs_4345507344 = _loads('(dp1\nVid\np2\nVheader\np3\nsVclass\np4\nVui-widget-header ui-corner-all\np5\ns.') 10 | _attrs_4353343184 = _loads('(dp1\nVclass\np2\nVbreadcrumb\np3\ns.') 11 | _attrs_4353342544 = _loads('(dp1\n.') 12 | _attrs_4353376016 = _loads('(dp1\n.') 13 | _init_stream = _loads('cchameleon.core.generation\ninitialize_stream\np1\n.') 14 | _attrs_4353376144 = _loads('(dp1\n.') 15 | _attrs_4353376208 = _loads('(dp1\n.') 16 | _attrs_4353372432 = _loads('(dp1\nVsrc\np2\nVhttps://ajax.googleapis.com/ajax/libs/jquery/1.6.1/jquery.min.js\np3\ns.') 17 | _init_default = _loads('cchameleon.core.generation\ninitialize_default\np1\n.') 18 | _attrs_4353372560 = _loads('(dp1\nVid\np2\nVcontent\np3\nsVclass\np4\nVui-admin ui-widget\np5\ns.') 19 | _attrs_4345507600 = _loads('(dp1\n.') 20 | _attrs_4353342352 = _loads('(dp1\n.') 21 | _attrs_4353413200 = _loads('(dp1\n.') 22 | _init_tal = _loads('cchameleon.core.generation\ninitialize_tal\np1\n.') 23 | def render(econtext, rcontext=None): 24 | macros = econtext.get('macros') 25 | _translate = econtext.get('_translate') 26 | _slots = econtext.get('_slots') 27 | target_language = econtext.get('target_language') 28 | u"%(scope)s['%(out)s'], %(scope)s['%(write)s']" 29 | (_out, _write, ) = (econtext['_out'], econtext['_write'], ) 30 | u'_init_tal()' 31 | (_attributes, repeat, ) = _init_tal() 32 | u'_init_default()' 33 | _default = _init_default() 34 | u'None' 35 | default = None 36 | u'None' 37 | _domain = None 38 | attrs = _attrs_4353376016 39 | _write(u'\n ') 40 | attrs = _attrs_4353376144 41 | u"''" 42 | _write(u'\n ') 43 | _default.value = default = '' 44 | u"request.model_name or 'root'" 45 | _content = (_lookup_attr(econtext['request'], 'model_name') or 'root') 46 | attrs = _attrs_4353413200 47 | u'_content' 48 | _write(u'') 49 | _tmp1 = _content 50 | _tmp = _tmp1 51 | if (_tmp.__class__ not in (str, unicode, int, float, )): 52 | try: 53 | _tmp = _tmp.__html__ 54 | except: 55 | _tmp = _translate(_tmp, domain=_domain, mapping=None, target_language=target_language, default=None) 56 | else: 57 | _tmp = _tmp() 58 | _write(_tmp) 59 | _tmp = None 60 | if (_tmp is not None): 61 | if not isinstance(_tmp, unicode): 62 | _tmp = str(_tmp) 63 | if ('&' in _tmp): 64 | if (';' in _tmp): 65 | _tmp = _re_amp.sub('&', _tmp) 66 | else: 67 | _tmp = _tmp.replace('&', '&') 68 | if ('<' in _tmp): 69 | _tmp = _tmp.replace('<', '<') 70 | if ('>' in _tmp): 71 | _tmp = _tmp.replace('>', '>') 72 | _write(_tmp) 73 | _write(u'\n ') 74 | attrs = _attrs_4353373456 75 | u"request.static_url('pyramid_formalchemy:static/admin.css')" 76 | _write(u'' in _tmp1): 94 | _tmp1 = _tmp1.replace('>', '>') 95 | if ('"' in _tmp1): 96 | _tmp1 = _tmp1.replace('"', '"') 97 | _write(((' href="' + _tmp1) + '"')) 98 | _write(u'>\n ') 99 | attrs = _attrs_4353372432 100 | _write(u'\n \n ') 101 | attrs = _attrs_4353376208 102 | _write(u'\n ') 103 | attrs = _attrs_4353372560 104 | _write(u'
\n ') 105 | attrs = _attrs_4345507344 106 | _write(u'

\n ') 107 | attrs = _attrs_4353343184 108 | u'breadcrumb' 109 | _write(u'\n ') 183 | _default.value = default = '' 184 | u"request.model_name or 'root'" 185 | _content = (_lookup_attr(econtext['request'], 'model_name') or 'root') 186 | attrs = _attrs_4353342352 187 | u'_content' 188 | _write(u'
') 189 | _tmp1 = _content 190 | _tmp = _tmp1 191 | if (_tmp.__class__ not in (str, unicode, int, float, )): 192 | try: 193 | _tmp = _tmp.__html__ 194 | except: 195 | _tmp = _translate(_tmp, domain=_domain, mapping=None, target_language=target_language, default=None) 196 | else: 197 | _tmp = _tmp() 198 | _write(_tmp) 199 | _tmp = None 200 | if (_tmp is not None): 201 | if not isinstance(_tmp, unicode): 202 | _tmp = str(_tmp) 203 | if ('&' in _tmp): 204 | if (';' in _tmp): 205 | _tmp = _re_amp.sub('&', _tmp) 206 | else: 207 | _tmp = _tmp.replace('&', '&') 208 | if ('<' in _tmp): 209 | _tmp = _tmp.replace('<', '<') 210 | if ('>' in _tmp): 211 | _tmp = _tmp.replace('>', '>') 212 | _write(_tmp) 213 | u"%(slots)s.get(u'main')" 214 | _write(u'
\n

\n ') 215 | _tmp = _slots.get(u'main') 216 | u'%(tmp)s is not None' 217 | _tmp1 = (_tmp is not None) 218 | if _tmp1: 219 | pass 220 | u'isinstance(%(tmp)s, basestring)' 221 | _tmp2 = isinstance(_tmp, basestring) 222 | if not _tmp2: 223 | pass 224 | econtext.update(dict(rcontext=rcontext, _domain=_domain)) 225 | _tmp(econtext, repeat) 226 | else: 227 | pass 228 | u'%(tmp)s' 229 | _tmp2 = _tmp 230 | _tmp = _tmp2 231 | if (_tmp.__class__ not in (str, unicode, int, float, )): 232 | try: 233 | _tmp = _tmp.__html__ 234 | except: 235 | _tmp = _translate(_tmp, domain=_domain, mapping=None, target_language=target_language, default=None) 236 | else: 237 | _tmp = _tmp() 238 | _write(_tmp) 239 | _tmp = None 240 | if (_tmp is not None): 241 | if not isinstance(_tmp, unicode): 242 | _tmp = str(_tmp) 243 | _write(_tmp) 244 | else: 245 | pass 246 | attrs = _attrs_4345507600 247 | _write(u'
\n
') 248 | _write(u'\n
\n \n') 249 | return 250 | return render 251 | 252 | __filename__ = '/Users/gawel/py/formalchemy_project/pyramid_formalchemy/pyramid_formalchemy/templates/admin/master.pt' 253 | registry[('master', False, '1488bdb950901f8f258549439ef6661a49aae984')] = bind() 254 | -------------------------------------------------------------------------------- /pyramid_formalchemy/templates/admin/models.pt: -------------------------------------------------------------------------------- 1 | 2 | 3 |
4 |
5 |
6 | 8 |
9 |
10 |
11 | 12 | 13 | -------------------------------------------------------------------------------- /pyramid_formalchemy/templates/admin/models.pt.py: -------------------------------------------------------------------------------- 1 | registry = dict(version=0) 2 | def bind(): 3 | from cPickle import loads as _loads 4 | _lookup_attr = _loads('cchameleon.core.codegen\nlookup_attr\np1\n.') 5 | _attrs_4358089040 = _loads('(dp1\n.') 6 | _init_scope = _loads('cchameleon.core.utils\necontext\np1\n.') 7 | _re_amp = _loads("cre\n_compile\np1\n(S'&(?!([A-Za-z]+|#[0-9]+);)'\np2\nI0\ntRp3\n.") 8 | _attrs_4358088464 = _loads('(dp1\n.') 9 | _init_stream = _loads('cchameleon.core.generation\ninitialize_stream\np1\n.') 10 | _attrs_4358088656 = _loads('(dp1\n.') 11 | _init_default = _loads('cchameleon.core.generation\ninitialize_default\np1\n.') 12 | _attrs_4358088848 = _loads('(dp1\n.') 13 | _init_tal = _loads('cchameleon.core.generation\ninitialize_tal\np1\n.') 14 | def render(econtext, rcontext=None): 15 | macros = econtext.get('macros') 16 | _translate = econtext.get('_translate') 17 | _slots = econtext.get('_slots') 18 | target_language = econtext.get('target_language') 19 | u'_init_stream()' 20 | (_out, _write, ) = _init_stream() 21 | u'_init_tal()' 22 | (_attributes, repeat, ) = _init_tal() 23 | u'_init_default()' 24 | _default = _init_default() 25 | u'None' 26 | default = None 27 | u'None' 28 | _domain = None 29 | u"main.macros['master']" 30 | _metal = _lookup_attr(econtext['main'], 'macros')['master'] 31 | def _callback_main(econtext, _repeat, _out=_out, _write=_write, _domain=_domain, **_ignored): 32 | if _repeat: 33 | repeat.update(_repeat) 34 | attrs = _attrs_4358088464 35 | u'models' 36 | _write(u'
\n ') 37 | _tmp1 = econtext['models'] 38 | item = None 39 | (_tmp1, _tmp2, ) = repeat.insert('item', _tmp1) 40 | for item in _tmp1: 41 | _tmp2 = (_tmp2 - 1) 42 | attrs = _attrs_4358088656 43 | _write(u'
\n ') 44 | attrs = _attrs_4358088848 45 | u"''" 46 | _write(u'
\n ') 47 | _default.value = default = '' 48 | u'item' 49 | _content = item 50 | attrs = _attrs_4358089040 51 | u'request.route_url(request.route_name, traverse=item)' 52 | _write(u'' in _tmp3): 70 | _tmp3 = _tmp3.replace('>', '>') 71 | if ('"' in _tmp3): 72 | _tmp3 = _tmp3.replace('"', '"') 73 | _write(((' href="' + _tmp3) + '"')) 74 | u'_content' 75 | _write('>') 76 | _tmp3 = _content 77 | _tmp = _tmp3 78 | if (_tmp.__class__ not in (str, unicode, int, float, )): 79 | try: 80 | _tmp = _tmp.__html__ 81 | except: 82 | _tmp = _translate(_tmp, domain=_domain, mapping=None, target_language=target_language, default=None) 83 | else: 84 | _tmp = _tmp() 85 | _write(_tmp) 86 | _tmp = None 87 | if (_tmp is not None): 88 | if not isinstance(_tmp, unicode): 89 | _tmp = str(_tmp) 90 | if ('&' in _tmp): 91 | if (';' in _tmp): 92 | _tmp = _re_amp.sub('&', _tmp) 93 | else: 94 | _tmp = _tmp.replace('&', '&') 95 | if ('<' in _tmp): 96 | _tmp = _tmp.replace('<', '<') 97 | if ('>' in _tmp): 98 | _tmp = _tmp.replace('>', '>') 99 | _write(_tmp) 100 | _write(u'\n
\n
') 101 | if (_tmp2 == 0): 102 | break 103 | _write(' ') 104 | _write(u'\n
\n') 105 | u"{'main': _callback_main}" 106 | _tmp = {'main': _callback_main, } 107 | u"main.macros['master']" 108 | _metal.render(_tmp, _out=_out, _write=_write, _domain=_domain, econtext=econtext) 109 | return _out.getvalue() 110 | return render 111 | 112 | __filename__ = '/Users/gawel/py/formalchemy_project/pyramid_formalchemy/pyramid_formalchemy/templates/admin/models.pt' 113 | registry[(None, True, '1488bdb950901f8f258549439ef6661a49aae984')] = bind() 114 | -------------------------------------------------------------------------------- /pyramid_formalchemy/templates/admin/new.pt: -------------------------------------------------------------------------------- 1 | 2 | 3 |
4 |
7 |
8 |

9 |

10 | 11 |
12 | 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /pyramid_formalchemy/templates/admin/new.pt.py: -------------------------------------------------------------------------------- 1 | registry = dict(version=0) 2 | def bind(): 3 | from cPickle import loads as _loads 4 | _lookup_attr = _loads('cchameleon.core.codegen\nlookup_attr\np1\n.') 5 | _init_scope = _loads('cchameleon.core.utils\necontext\np1\n.') 6 | _re_amp = _loads("cre\n_compile\np1\n(S'&(?!([A-Za-z]+|#[0-9]+);)'\np2\nI0\ntRp3\n.") 7 | _attrs_4356178128 = _loads('(dp1\n.') 8 | _attrs_4356132752 = _loads('(dp1\n.') 9 | _init_stream = _loads('cchameleon.core.generation\ninitialize_stream\np1\n.') 10 | _attrs_4356178000 = _loads('(dp1\nVmethod\np2\nVPOST\np3\nsVenctype\np4\nVmultipart/form-data\np5\ns.') 11 | _init_default = _loads('cchameleon.core.generation\ninitialize_default\np1\n.') 12 | _attrs_4356178192 = _loads('(dp1\nVclass\np2\nVfa_field\np3\ns.') 13 | _init_tal = _loads('cchameleon.core.generation\ninitialize_tal\np1\n.') 14 | def render(econtext, rcontext=None): 15 | macros = econtext.get('macros') 16 | _translate = econtext.get('_translate') 17 | _slots = econtext.get('_slots') 18 | target_language = econtext.get('target_language') 19 | u'_init_stream()' 20 | (_out, _write, ) = _init_stream() 21 | u'_init_tal()' 22 | (_attributes, repeat, ) = _init_tal() 23 | u'_init_default()' 24 | _default = _init_default() 25 | u'None' 26 | default = None 27 | u'None' 28 | _domain = None 29 | u"main.macros['master']" 30 | _metal = _lookup_attr(econtext['main'], 'macros')['master'] 31 | def _callback_main(econtext, _repeat, _out=_out, _write=_write, _domain=_domain, **_ignored): 32 | if _repeat: 33 | repeat.update(_repeat) 34 | attrs = _attrs_4356132752 35 | _write(u'
\n ') 36 | attrs = _attrs_4356178000 37 | u'request.fa_url(request.model_name)' 38 | _write(u'
' in _tmp1): 56 | _tmp1 = _tmp1.replace('>', '>') 57 | if ('"' in _tmp1): 58 | _tmp1 = _tmp1.replace('"', '"') 59 | _write(((' action="' + _tmp1) + '"')) 60 | u"''" 61 | _write(u'>\n ') 62 | _default.value = default = '' 63 | u'fs.render()' 64 | _content = _lookup_attr(econtext['fs'], 'render')() 65 | attrs = _attrs_4356178128 66 | u'_content' 67 | _write(u'
') 68 | _tmp1 = _content 69 | _tmp = _tmp1 70 | if (_tmp.__class__ not in (str, unicode, int, float, )): 71 | try: 72 | _tmp = _tmp.__html__ 73 | except: 74 | _tmp = _translate(_tmp, domain=_domain, mapping=None, target_language=target_language, default=None) 75 | else: 76 | _tmp = _tmp() 77 | _write(_tmp) 78 | _tmp = None 79 | if (_tmp is not None): 80 | if not isinstance(_tmp, unicode): 81 | _tmp = str(_tmp) 82 | _write(_tmp) 83 | u"u'\\n '" 84 | _write(u'
\n ') 85 | _default.value = default = u'\n ' 86 | u'actions.buttons(request)' 87 | _content = _lookup_attr(econtext['actions'], 'buttons')(econtext['request']) 88 | attrs = _attrs_4356178192 89 | u'_content' 90 | _write(u'

') 91 | _tmp1 = _content 92 | _tmp = _tmp1 93 | if (_tmp.__class__ not in (str, unicode, int, float, )): 94 | try: 95 | _tmp = _tmp.__html__ 96 | except: 97 | _tmp = _translate(_tmp, domain=_domain, mapping=None, target_language=target_language, default=None) 98 | else: 99 | _tmp = _tmp() 100 | _write(_tmp) 101 | _tmp = None 102 | if (_tmp is not None): 103 | if not isinstance(_tmp, unicode): 104 | _tmp = str(_tmp) 105 | _write(_tmp) 106 | _write(u'

\n
\n
\n') 107 | u"{'main': _callback_main}" 108 | _tmp = {'main': _callback_main, } 109 | u"main.macros['master']" 110 | _metal.render(_tmp, _out=_out, _write=_write, _domain=_domain, econtext=econtext) 111 | return _out.getvalue() 112 | return render 113 | 114 | __filename__ = '/Users/gawel/py/formalchemy_project/pyramid_formalchemy/pyramid_formalchemy/templates/admin/new.pt' 115 | registry[(None, True, '1488bdb950901f8f258549439ef6661a49aae984')] = bind() 116 | -------------------------------------------------------------------------------- /pyramid_formalchemy/templates/admin/show.pt: -------------------------------------------------------------------------------- 1 | 2 | 3 |
4 |
5 |
6 |

7 |

8 |
9 |
10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /pyramid_formalchemy/templates/admin/show.pt.py: -------------------------------------------------------------------------------- 1 | registry = dict(version=0) 2 | def bind(): 3 | from cPickle import loads as _loads 4 | _lookup_attr = _loads('cchameleon.core.codegen\nlookup_attr\np1\n.') 5 | _init_scope = _loads('cchameleon.core.utils\necontext\np1\n.') 6 | _attrs_4362312784 = _loads('(dp1\n.') 7 | _init_stream = _loads('cchameleon.core.generation\ninitialize_stream\np1\n.') 8 | _attrs_4362313104 = _loads('(dp1\n.') 9 | _init_default = _loads('cchameleon.core.generation\ninitialize_default\np1\n.') 10 | _attrs_4362312976 = _loads('(dp1\n.') 11 | _init_tal = _loads('cchameleon.core.generation\ninitialize_tal\np1\n.') 12 | _attrs_4362313296 = _loads('(dp1\nVclass\np2\nVfa_field\np3\ns.') 13 | def render(econtext, rcontext=None): 14 | macros = econtext.get('macros') 15 | _translate = econtext.get('_translate') 16 | _slots = econtext.get('_slots') 17 | target_language = econtext.get('target_language') 18 | u'_init_stream()' 19 | (_out, _write, ) = _init_stream() 20 | u'_init_tal()' 21 | (_attributes, repeat, ) = _init_tal() 22 | u'_init_default()' 23 | _default = _init_default() 24 | u'None' 25 | default = None 26 | u'None' 27 | _domain = None 28 | u"main.macros['master']" 29 | _metal = _lookup_attr(econtext['main'], 'macros')['master'] 30 | def _callback_main(econtext, _repeat, _out=_out, _write=_write, _domain=_domain, **_ignored): 31 | if _repeat: 32 | repeat.update(_repeat) 33 | attrs = _attrs_4362312784 34 | u"''" 35 | _write(u'
\n ') 36 | _default.value = default = '' 37 | u'fs.render()' 38 | _content = _lookup_attr(econtext['fs'], 'render')() 39 | attrs = _attrs_4362312976 40 | u'_content' 41 | _write(u'
') 42 | _tmp1 = _content 43 | _tmp = _tmp1 44 | if (_tmp.__class__ not in (str, unicode, int, float, )): 45 | try: 46 | _tmp = _tmp.__html__ 47 | except: 48 | _tmp = _translate(_tmp, domain=_domain, mapping=None, target_language=target_language, default=None) 49 | else: 50 | _tmp = _tmp() 51 | _write(_tmp) 52 | _tmp = None 53 | if (_tmp is not None): 54 | if not isinstance(_tmp, unicode): 55 | _tmp = str(_tmp) 56 | _write(_tmp) 57 | _write(u'
\n ') 58 | attrs = _attrs_4362313104 59 | u"u'\\n '" 60 | _write(u'
\n ') 61 | _default.value = default = u'\n ' 62 | u'actions.buttons(request)' 63 | _content = _lookup_attr(econtext['actions'], 'buttons')(econtext['request']) 64 | attrs = _attrs_4362313296 65 | u'_content' 66 | _write(u'

') 67 | _tmp1 = _content 68 | _tmp = _tmp1 69 | if (_tmp.__class__ not in (str, unicode, int, float, )): 70 | try: 71 | _tmp = _tmp.__html__ 72 | except: 73 | _tmp = _translate(_tmp, domain=_domain, mapping=None, target_language=target_language, default=None) 74 | else: 75 | _tmp = _tmp() 76 | _write(_tmp) 77 | _tmp = None 78 | if (_tmp is not None): 79 | if not isinstance(_tmp, unicode): 80 | _tmp = str(_tmp) 81 | _write(_tmp) 82 | _write(u'

\n
\n
\n') 83 | u"{'main': _callback_main}" 84 | _tmp = {'main': _callback_main, } 85 | u"main.macros['master']" 86 | _metal.render(_tmp, _out=_out, _write=_write, _domain=_domain, econtext=econtext) 87 | return _out.getvalue() 88 | return render 89 | 90 | __filename__ = '/Users/gawel/py/formalchemy_project/pyramid_formalchemy/pyramid_formalchemy/templates/admin/show.pt' 91 | registry[(None, True, '1488bdb950901f8f258549439ef6661a49aae984')] = bind() 92 | -------------------------------------------------------------------------------- /pyramid_formalchemy/templates/forms/fieldset.pt: -------------------------------------------------------------------------------- 1 | 2 |
3 |
4 |
5 | 6 | 7 |
8 |
9 |
11 |
13 |
16 |
17 |
18 |
19 |
20 |
22 |
23 | 27 | 28 | 29 | -------------------------------------------------------------------------------- /pyramid_formalchemy/templates/forms/fieldset.pt.py: -------------------------------------------------------------------------------- 1 | registry = dict(version=0) 2 | def bind(): 3 | from cPickle import loads as _loads 4 | _lookup_attr = _loads('cchameleon.core.codegen\nlookup_attr\np1\n.') 5 | _init_scope = _loads('cchameleon.core.utils\necontext\np1\n.') 6 | _re_amp = _loads("cre\n_compile\np1\n(S'&(?!([A-Za-z]+|#[0-9]+);)'\np2\nI0\ntRp3\n.") 7 | _attrs_4355399760 = _loads('(dp1\n.') 8 | _attrs_4355400208 = _loads('(dp1\nVclass\np2\nVfa_instructions ui-corner-all\np3\ns.') 9 | _attrs_4355399888 = _loads('(dp1\n.') 10 | _attrs_4355400144 = _loads('(dp1\nVclass\np2\nVlabel\np3\ns.') 11 | _init_stream = _loads('cchameleon.core.generation\ninitialize_stream\np1\n.') 12 | _init_default = _loads('cchameleon.core.generation\ninitialize_default\np1\n.') 13 | _attrs_4355400400 = _loads('(dp1\nVclass\np2\nVui-state-error ui-corner-all\np3\ns.') 14 | _attrs_4355400080 = _loads('(dp1\n.') 15 | _attrs_4355400464 = _loads('(dp1\nVclass\np2\nVfield_input\np3\ns.') 16 | _attrs_4355400528 = _loads('(dp1\n.') 17 | _attrs_4355400016 = _loads('(dp1\nVclass\np2\nVfa_field ui-widget\np3\ns.') 18 | _init_tal = _loads('cchameleon.core.generation\ninitialize_tal\np1\n.') 19 | _attrs_4355400272 = _loads('(dp1\n.') 20 | def render(econtext, rcontext=None): 21 | macros = econtext.get('macros') 22 | _translate = econtext.get('_translate') 23 | _slots = econtext.get('_slots') 24 | target_language = econtext.get('target_language') 25 | u'_init_stream()' 26 | (_out, _write, ) = _init_stream() 27 | u'_init_tal()' 28 | (_attributes, repeat, ) = _init_tal() 29 | u'_init_default()' 30 | _default = _init_default() 31 | u'None' 32 | default = None 33 | u'None' 34 | _domain = None 35 | u'False' 36 | focus_rendered = False 37 | u'fieldset.errors.get(None, False)' 38 | _write(u'\n') 39 | _tmp1 = _lookup_attr(_lookup_attr(econtext['fieldset'], 'errors'), 'get')(None, False) 40 | if _tmp1: 41 | pass 42 | attrs = _attrs_4355399760 43 | u"''" 44 | _write(u'
\n ') 45 | _default.value = default = '' 46 | u'fieldset.error.get(None)' 47 | _tmp1 = _lookup_attr(_lookup_attr(econtext['fieldset'], 'error'), 'get')(None) 48 | error = None 49 | (_tmp1, _tmp2, ) = repeat.insert('error', _tmp1) 50 | for error in _tmp1: 51 | _tmp2 = (_tmp2 - 1) 52 | u'error' 53 | _content = error 54 | attrs = _attrs_4355399888 55 | u'_content' 56 | _write(u'
') 57 | _tmp3 = _content 58 | _tmp = _tmp3 59 | if (_tmp.__class__ not in (str, unicode, int, float, )): 60 | try: 61 | _tmp = _tmp.__html__ 62 | except: 63 | _tmp = _translate(_tmp, domain=_domain, mapping=None, target_language=target_language, default=None) 64 | else: 65 | _tmp = _tmp() 66 | _write(_tmp) 67 | _tmp = None 68 | if (_tmp is not None): 69 | if not isinstance(_tmp, unicode): 70 | _tmp = str(_tmp) 71 | if ('&' in _tmp): 72 | if (';' in _tmp): 73 | _tmp = _re_amp.sub('&', _tmp) 74 | else: 75 | _tmp = _tmp.replace('&', '&') 76 | if ('<' in _tmp): 77 | _tmp = _tmp.replace('<', '<') 78 | if ('>' in _tmp): 79 | _tmp = _tmp.replace('>', '>') 80 | _write(_tmp) 81 | _write(u'
') 82 | if (_tmp2 == 0): 83 | break 84 | _write(' ') 85 | _write(u'\n
') 86 | u'fieldset.render_fields.itervalues()' 87 | _write(u'\n\n') 88 | _tmp1 = _lookup_attr(_lookup_attr(econtext['fieldset'], 'render_fields'), 'itervalues')() 89 | field = None 90 | (_tmp1, _tmp2, ) = repeat.insert('field', _tmp1) 91 | for field in _tmp1: 92 | _tmp2 = (_tmp2 - 1) 93 | _write(u'\n ') 94 | attrs = _attrs_4355400016 95 | u'field.requires_label' 96 | _write(u'
\n ') 97 | _tmp3 = _lookup_attr(field, 'requires_label') 98 | if _tmp3: 99 | pass 100 | attrs = _attrs_4355400144 101 | u"''" 102 | _write(u'
\n ') 103 | _default.value = default = '' 104 | u'isinstance(field.type, fatypes.Boolean)' 105 | _tmp3 = isinstance(_lookup_attr(field, 'type'), _lookup_attr(econtext['fatypes'], 'Boolean')) 106 | if _tmp3: 107 | pass 108 | u'field.render()' 109 | _content = _lookup_attr(field, 'render')() 110 | attrs = _attrs_4355400272 111 | u'_content' 112 | _write(u'
') 113 | _tmp3 = _content 114 | _tmp = _tmp3 115 | if (_tmp.__class__ not in (str, unicode, int, float, )): 116 | try: 117 | _tmp = _tmp.__html__ 118 | except: 119 | _tmp = _translate(_tmp, domain=_domain, mapping=None, target_language=target_language, default=None) 120 | else: 121 | _tmp = _tmp() 122 | _write(_tmp) 123 | _tmp = None 124 | if (_tmp is not None): 125 | if not isinstance(_tmp, unicode): 126 | _tmp = str(_tmp) 127 | _write(_tmp) 128 | _write(u'
') 129 | u"''" 130 | _write(u'\n ') 131 | _default.value = default = '' 132 | u'field.label_tag()' 133 | _content = _lookup_attr(field, 'label_tag')() 134 | u'_content' 135 | _tmp3 = _content 136 | _tmp = _tmp3 137 | if (_tmp.__class__ not in (str, unicode, int, float, )): 138 | try: 139 | _tmp = _tmp.__html__ 140 | except: 141 | _tmp = _translate(_tmp, domain=_domain, mapping=None, target_language=target_language, default=None) 142 | else: 143 | _tmp = _tmp() 144 | _write(_tmp) 145 | _tmp = None 146 | if (_tmp is not None): 147 | if not isinstance(_tmp, unicode): 148 | _tmp = str(_tmp) 149 | _write(_tmp) 150 | _write(u'\n
') 151 | u"u'\\n '" 152 | _write(u'\n ') 153 | _default.value = default = u'\n ' 154 | u"'instructions' in field.metadata" 155 | _tmp3 = ('instructions' in _lookup_attr(field, 'metadata')) 156 | if _tmp3: 157 | pass 158 | u"field.metadata['instructions']" 159 | _content = _lookup_attr(field, 'metadata')['instructions'] 160 | attrs = _attrs_4355400208 161 | u'_content' 162 | _write(u'
') 163 | _tmp3 = _content 164 | _tmp = _tmp3 165 | if (_tmp.__class__ not in (str, unicode, int, float, )): 166 | try: 167 | _tmp = _tmp.__html__ 168 | except: 169 | _tmp = _translate(_tmp, domain=_domain, mapping=None, target_language=target_language, default=None) 170 | else: 171 | _tmp = _tmp() 172 | _write(_tmp) 173 | _tmp = None 174 | if (_tmp is not None): 175 | if not isinstance(_tmp, unicode): 176 | _tmp = str(_tmp) 177 | if ('&' in _tmp): 178 | if (';' in _tmp): 179 | _tmp = _re_amp.sub('&', _tmp) 180 | else: 181 | _tmp = _tmp.replace('&', '&') 182 | if ('<' in _tmp): 183 | _tmp = _tmp.replace('<', '<') 184 | if ('>' in _tmp): 185 | _tmp = _tmp.replace('>', '>') 186 | _write(_tmp) 187 | _write(u'
') 188 | u'field.errors' 189 | _write(u'\n ') 190 | _tmp3 = _lookup_attr(field, 'errors') 191 | if _tmp3: 192 | pass 193 | attrs = _attrs_4355400400 194 | u"''" 195 | _write(u'
\n ') 196 | _default.value = default = '' 197 | u'field.errors' 198 | _tmp3 = _lookup_attr(field, 'errors') 199 | error = None 200 | (_tmp3, _tmp4, ) = repeat.insert('error', _tmp3) 201 | for error in _tmp3: 202 | _tmp4 = (_tmp4 - 1) 203 | u'error' 204 | _content = error 205 | attrs = _attrs_4355400528 206 | u'_content' 207 | _write(u'
') 208 | _tmp5 = _content 209 | _tmp = _tmp5 210 | if (_tmp.__class__ not in (str, unicode, int, float, )): 211 | try: 212 | _tmp = _tmp.__html__ 213 | except: 214 | _tmp = _translate(_tmp, domain=_domain, mapping=None, target_language=target_language, default=None) 215 | else: 216 | _tmp = _tmp() 217 | _write(_tmp) 218 | _tmp = None 219 | if (_tmp is not None): 220 | if not isinstance(_tmp, unicode): 221 | _tmp = str(_tmp) 222 | if ('&' in _tmp): 223 | if (';' in _tmp): 224 | _tmp = _re_amp.sub('&', _tmp) 225 | else: 226 | _tmp = _tmp.replace('&', '&') 227 | if ('<' in _tmp): 228 | _tmp = _tmp.replace('<', '<') 229 | if ('>' in _tmp): 230 | _tmp = _tmp.replace('>', '>') 231 | _write(_tmp) 232 | _write(u'
') 233 | if (_tmp4 == 0): 234 | break 235 | _write(' ') 236 | _write(u'\n
') 237 | u"''" 238 | _write(u'\n ') 239 | _default.value = default = '' 240 | u'not isinstance(field.type, fatypes.Boolean)' 241 | _tmp3 = not isinstance(_lookup_attr(field, 'type'), _lookup_attr(econtext['fatypes'], 'Boolean')) 242 | if _tmp3: 243 | pass 244 | u'field.render()' 245 | _content = _lookup_attr(field, 'render')() 246 | attrs = _attrs_4355400464 247 | u'_content' 248 | _write(u'
') 249 | _tmp3 = _content 250 | _tmp = _tmp3 251 | if (_tmp.__class__ not in (str, unicode, int, float, )): 252 | try: 253 | _tmp = _tmp.__html__ 254 | except: 255 | _tmp = _translate(_tmp, domain=_domain, mapping=None, target_language=target_language, default=None) 256 | else: 257 | _tmp = _tmp() 258 | _write(_tmp) 259 | _tmp = None 260 | if (_tmp is not None): 261 | if not isinstance(_tmp, unicode): 262 | _tmp = str(_tmp) 263 | _write(_tmp) 264 | _write(u'
') 265 | u'not field.is_readonly() and (fieldset.focus == field or fieldset.focus is True) and not focus_rendered' 266 | _write(u'\n
\n ') 267 | _tmp3 = (not _lookup_attr(field, 'is_readonly')() and ((_lookup_attr(econtext['fieldset'], 'focus') == field) or (_lookup_attr(econtext['fieldset'], 'focus') is True)) and not focus_rendered) 268 | if _tmp3: 269 | pass 270 | attrs = _attrs_4355400080 271 | u'True' 272 | _write(u'') 301 | _write(u'\n') 302 | if (_tmp2 == 0): 303 | break 304 | _write(' ') 305 | _write(u'') 306 | return _out.getvalue() 307 | return render 308 | 309 | __filename__ = '/Users/gawel/py/formalchemy_project/pyramid_formalchemy/pyramid_formalchemy/templates/forms/fieldset.pt' 310 | registry[(None, True, '1488bdb950901f8f258549439ef6661a49aae984')] = bind() 311 | -------------------------------------------------------------------------------- /pyramid_formalchemy/templates/forms/fieldset_readonly.pt: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 10 |   11 | 12 |
13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /pyramid_formalchemy/templates/forms/fieldset_readonly.pt.py: -------------------------------------------------------------------------------- 1 | registry = dict(version=0) 2 | def bind(): 3 | from cPickle import loads as _loads 4 | _lookup_attr = _loads('cchameleon.core.codegen\nlookup_attr\np1\n.') 5 | _init_scope = _loads('cchameleon.core.utils\necontext\np1\n.') 6 | _init_default = _loads('cchameleon.core.generation\ninitialize_default\np1\n.') 7 | _attrs_4355418576 = _loads('(dp1\nVstyle\np2\nVdisplay:none\np3\ns.') 8 | _attrs_4355401296 = _loads('(dp1\n.') 9 | _init_stream = _loads('cchameleon.core.generation\ninitialize_stream\np1\n.') 10 | _attrs_4355399952 = _loads('(dp1\n.') 11 | _attrs_4355441232 = _loads('(dp1\n.') 12 | _attrs_4355400784 = _loads('(dp1\n.') 13 | _attrs_4355400912 = _loads('(dp1\nVclass\np2\nVfield_readonly\np3\ns.') 14 | _init_tal = _loads('cchameleon.core.generation\ninitialize_tal\np1\n.') 15 | _attrs_4355400848 = _loads('(dp1\n.') 16 | def render(econtext, rcontext=None): 17 | macros = econtext.get('macros') 18 | _translate = econtext.get('_translate') 19 | _slots = econtext.get('_slots') 20 | target_language = econtext.get('target_language') 21 | u'_init_stream()' 22 | (_out, _write, ) = _init_stream() 23 | u'_init_tal()' 24 | (_attributes, repeat, ) = _init_tal() 25 | u'_init_default()' 26 | _default = _init_default() 27 | u'None' 28 | default = None 29 | u'None' 30 | _domain = None 31 | attrs = _attrs_4355441232 32 | u'fieldset.render_fields.itervalues()' 33 | _write(u'\n ') 34 | _tmp1 = _lookup_attr(_lookup_attr(econtext['fieldset'], 'render_fields'), 'itervalues')() 35 | field = None 36 | (_tmp1, _tmp2, ) = repeat.insert('field', _tmp1) 37 | for field in _tmp1: 38 | _tmp2 = (_tmp2 - 1) 39 | u'field.requires_label' 40 | _write(u'') 41 | _tmp3 = _lookup_attr(field, 'requires_label') 42 | if _tmp3: 43 | pass 44 | attrs = _attrs_4355401296 45 | _write(u'\n ') 46 | attrs = _attrs_4355400912 47 | u"''" 48 | _write(u'\n ') 49 | _default.value = default = '' 50 | u'field.label_tag()' 51 | _content = _lookup_attr(field, 'label_tag')() 52 | u'_content' 53 | _tmp3 = _content 54 | _tmp = _tmp3 55 | if (_tmp.__class__ not in (str, unicode, int, float, )): 56 | try: 57 | _tmp = _tmp.__html__ 58 | except: 59 | _tmp = _translate(_tmp, domain=_domain, mapping=None, target_language=target_language, default=None) 60 | else: 61 | _tmp = _tmp() 62 | _write(_tmp) 63 | _tmp = None 64 | if (_tmp is not None): 65 | if not isinstance(_tmp, unicode): 66 | _tmp = str(_tmp) 67 | _write(_tmp) 68 | u"''" 69 | _write(u'\n \n ') 70 | _default.value = default = '' 71 | u'field.render_readonly()' 72 | _content = _lookup_attr(field, 'render_readonly')() 73 | attrs = _attrs_4355400848 74 | u'_content' 75 | _write(u'') 76 | _tmp3 = _content 77 | _tmp = _tmp3 78 | if (_tmp.__class__ not in (str, unicode, int, float, )): 79 | try: 80 | _tmp = _tmp.__html__ 81 | except: 82 | _tmp = _translate(_tmp, domain=_domain, mapping=None, target_language=target_language, default=None) 83 | else: 84 | _tmp = _tmp() 85 | _write(_tmp) 86 | _tmp = None 87 | if (_tmp is not None): 88 | if not isinstance(_tmp, unicode): 89 | _tmp = str(_tmp) 90 | _write(_tmp) 91 | _write(u'\n ') 92 | _write(u'\n ') 93 | if (_tmp2 == 0): 94 | break 95 | _write(' ') 96 | _write(u'\n ') 97 | attrs = _attrs_4355418576 98 | _write(u'') 99 | attrs = _attrs_4355400784 100 | _write(u' ') 101 | attrs = _attrs_4355399952 102 | u'fieldset.render_fields.itervalues()' 103 | _write(u'\n ') 104 | _tmp1 = _lookup_attr(_lookup_attr(econtext['fieldset'], 'render_fields'), 'itervalues')() 105 | field = None 106 | (_tmp1, _tmp2, ) = repeat.insert('field', _tmp1) 107 | for field in _tmp1: 108 | _tmp2 = (_tmp2 - 1) 109 | u"''" 110 | _write(u'') 111 | _default.value = default = '' 112 | u'not field.requires_label' 113 | _tmp3 = not _lookup_attr(field, 'requires_label') 114 | if _tmp3: 115 | pass 116 | u'field.render_readonly()' 117 | _content = _lookup_attr(field, 'render_readonly')() 118 | u'_content' 119 | _tmp3 = _content 120 | _tmp = _tmp3 121 | if (_tmp.__class__ not in (str, unicode, int, float, )): 122 | try: 123 | _tmp = _tmp.__html__ 124 | except: 125 | _tmp = _translate(_tmp, domain=_domain, mapping=None, target_language=target_language, default=None) 126 | else: 127 | _tmp = _tmp() 128 | _write(_tmp) 129 | _tmp = None 130 | if (_tmp is not None): 131 | if not isinstance(_tmp, unicode): 132 | _tmp = str(_tmp) 133 | _write(_tmp) 134 | _write(u'\n ') 135 | if (_tmp2 == 0): 136 | break 137 | _write(' ') 138 | _write(u'\n \n \n') 139 | return _out.getvalue() 140 | return render 141 | 142 | __filename__ = '/Users/gawel/py/formalchemy_project/pyramid_formalchemy/pyramid_formalchemy/templates/forms/fieldset_readonly.pt' 143 | registry[(None, True, '1488bdb950901f8f258549439ef6661a49aae984')] = bind() 144 | -------------------------------------------------------------------------------- /pyramid_formalchemy/templates/forms/grid.pt: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 6 | 7 | 8 | 9 | 10 | 13 | 17 | 18 | 19 | 20 |
14 |
15 |
${error}
16 |
21 | 22 | -------------------------------------------------------------------------------- /pyramid_formalchemy/templates/forms/grid.pt.py: -------------------------------------------------------------------------------- 1 | registry = dict(version=0) 2 | def bind(): 3 | from cPickle import loads as _loads 4 | _lookup_attr = _loads('cchameleon.core.codegen\nlookup_attr\np1\n.') 5 | _init_scope = _loads('cchameleon.core.utils\necontext\np1\n.') 6 | _re_amp = _loads("cre\n_compile\np1\n(S'&(?!([A-Za-z]+|#[0-9]+);)'\np2\nI0\ntRp3\n.") 7 | _attrs_4361422096 = _loads('(dp1\nVclass\np2\nVlayout-grid\np3\ns.') 8 | _attrs_4361422992 = _loads('(dp1\n.') 9 | _attrs_4361422800 = _loads('(dp1\n.') 10 | _init_stream = _loads('cchameleon.core.generation\ninitialize_stream\np1\n.') 11 | _attrs_4361422352 = _loads('(dp1\n.') 12 | _init_default = _loads('cchameleon.core.generation\ninitialize_default\np1\n.') 13 | _attrs_4361422416 = _loads('(dp1\n.') 14 | _attrs_4361422480 = _loads('(dp1\nVclass\np2\nVui-widget-header\np3\ns.') 15 | _attrs_4361422608 = _loads('(dp1\n.') 16 | _attrs_4361423312 = _loads('(dp1\nVclass\np2\nVgrid_error\np3\ns.') 17 | _init_tal = _loads('cchameleon.core.generation\ninitialize_tal\np1\n.') 18 | def render(econtext, rcontext=None): 19 | macros = econtext.get('macros') 20 | _translate = econtext.get('_translate') 21 | _slots = econtext.get('_slots') 22 | target_language = econtext.get('target_language') 23 | u'_init_stream()' 24 | (_out, _write, ) = _init_stream() 25 | u'_init_tal()' 26 | (_attributes, repeat, ) = _init_tal() 27 | u'_init_default()' 28 | _default = _init_default() 29 | u'None' 30 | default = None 31 | u'None' 32 | _domain = None 33 | attrs = _attrs_4361422096 34 | _write(u'\n') 35 | attrs = _attrs_4361422352 36 | _write(u'\n ') 37 | attrs = _attrs_4361422480 38 | u"''" 39 | _write(u'\n ') 40 | _default.value = default = '' 41 | u'collection.render_fields.itervalues()' 42 | _tmp1 = _lookup_attr(_lookup_attr(econtext['collection'], 'render_fields'), 'itervalues')() 43 | field = None 44 | (_tmp1, _tmp2, ) = repeat.insert('field', _tmp1) 45 | for field in _tmp1: 46 | _tmp2 = (_tmp2 - 1) 47 | u'field.label()' 48 | _content = _lookup_attr(field, 'label')() 49 | attrs = _attrs_4361422608 50 | u'_content' 51 | _write(u'') 77 | if (_tmp2 == 0): 78 | break 79 | _write(' ') 80 | _write(u'\n \n\n') 81 | attrs = _attrs_4361422416 82 | u'collection.rows' 83 | _write(u'\n ') 84 | _tmp1 = _lookup_attr(econtext['collection'], 'rows') 85 | row = None 86 | (_tmp1, _tmp2, ) = repeat.insert('row', _tmp1) 87 | for row in _tmp1: 88 | _tmp2 = (_tmp2 - 1) 89 | u'collection._set_active(row)' 90 | _write(u'') 91 | dummy = _lookup_attr(econtext['collection'], '_set_active')(row) 92 | u'collection.get_errors(row)' 93 | row_errors = _lookup_attr(econtext['collection'], 'get_errors')(row) 94 | attrs = _attrs_4361422800 95 | u"ui-widget-${repeat.row.even and 'even' or 'odd'}" 96 | _write(u'' in _tmp3): 114 | _tmp3 = _tmp3.replace('>', '>') 115 | if ('"' in _tmp3): 116 | _tmp3 = _tmp3.replace('"', '"') 117 | _write(((' class="' + _tmp3) + '"')) 118 | u'collection.render_fields.itervalues()' 119 | _write(u'>\n ') 120 | _tmp3 = _lookup_attr(_lookup_attr(econtext['collection'], 'render_fields'), 'itervalues')() 121 | field = None 122 | (_tmp3, _tmp4, ) = repeat.insert('field', _tmp3) 123 | for field in _tmp3: 124 | _tmp4 = (_tmp4 - 1) 125 | attrs = _attrs_4361422992 126 | u"''" 127 | _write(u'') 186 | if (_tmp4 == 0): 187 | break 188 | _write(' ') 189 | _write(u'\n \n ') 190 | if (_tmp2 == 0): 191 | break 192 | _write(' ') 193 | _write(u'\n\n
') 52 | _tmp3 = _content 53 | _tmp = _tmp3 54 | if (_tmp.__class__ not in (str, unicode, int, float, )): 55 | try: 56 | _tmp = _tmp.__html__ 57 | except: 58 | _tmp = _translate(_tmp, domain=_domain, mapping=None, target_language=target_language, default=None) 59 | else: 60 | _tmp = _tmp() 61 | _write(_tmp) 62 | _tmp = None 63 | if (_tmp is not None): 64 | if not isinstance(_tmp, unicode): 65 | _tmp = str(_tmp) 66 | if ('&' in _tmp): 67 | if (';' in _tmp): 68 | _tmp = _re_amp.sub('&', _tmp) 69 | else: 70 | _tmp = _tmp.replace('&', '&') 71 | if ('<' in _tmp): 72 | _tmp = _tmp.replace('<', '<') 73 | if ('>' in _tmp): 74 | _tmp = _tmp.replace('>', '>') 75 | _write(_tmp) 76 | _write(u'
\n ') 128 | _default.value = default = '' 129 | u'field.render()' 130 | _content = _lookup_attr(field, 'render')() 131 | u'_content' 132 | _tmp5 = _content 133 | _tmp = _tmp5 134 | if (_tmp.__class__ not in (str, unicode, int, float, )): 135 | try: 136 | _tmp = _tmp.__html__ 137 | except: 138 | _tmp = _translate(_tmp, domain=_domain, mapping=None, target_language=target_language, default=None) 139 | else: 140 | _tmp = _tmp() 141 | _write(_tmp) 142 | _tmp = None 143 | if (_tmp is not None): 144 | if not isinstance(_tmp, unicode): 145 | _tmp = str(_tmp) 146 | _write(_tmp) 147 | u'row_errors.get(field, [])' 148 | _write(u'\n ') 149 | _tmp5 = _lookup_attr(row_errors, 'get')(field, []) 150 | error = None 151 | (_tmp5, _tmp6, ) = repeat.insert('error', _tmp5) 152 | for error in _tmp5: 153 | _tmp6 = (_tmp6 - 1) 154 | attrs = _attrs_4361423312 155 | u'error' 156 | _write(u'
') 157 | _tmp7 = error 158 | _tmp = _tmp7 159 | if (_tmp.__class__ not in (str, unicode, int, float, )): 160 | try: 161 | _tmp = _tmp.__html__ 162 | except: 163 | _tmp = _translate(_tmp, domain=_domain, mapping=None, target_language=target_language, default=None) 164 | else: 165 | _tmp = _tmp() 166 | _write(_tmp) 167 | _tmp = None 168 | if (_tmp is not None): 169 | if not isinstance(_tmp, unicode): 170 | _tmp = str(_tmp) 171 | if ('&' in _tmp): 172 | if (';' in _tmp): 173 | _tmp = _re_amp.sub('&', _tmp) 174 | else: 175 | _tmp = _tmp.replace('&', '&') 176 | if ('<' in _tmp): 177 | _tmp = _tmp.replace('<', '<') 178 | if ('>' in _tmp): 179 | _tmp = _tmp.replace('>', '>') 180 | _write(_tmp) 181 | _write(u'
') 182 | if (_tmp6 == 0): 183 | break 184 | _write(' ') 185 | _write(u'\n
') 194 | return _out.getvalue() 195 | return render 196 | 197 | __filename__ = '/Users/gawel/py/formalchemy_project/pyramid_formalchemy/pyramid_formalchemy/templates/forms/grid.pt' 198 | registry[(None, True, '1488bdb950901f8f258549439ef6661a49aae984')] = bind() 199 | -------------------------------------------------------------------------------- /pyramid_formalchemy/templates/forms/grid_readonly.pt: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 6 | 7 | 8 | 9 | 10 | 11 | 14 | 15 | 16 |
13 |
17 | 18 | -------------------------------------------------------------------------------- /pyramid_formalchemy/templates/forms/grid_readonly.pt.py: -------------------------------------------------------------------------------- 1 | registry = dict(version=0) 2 | def bind(): 3 | from cPickle import loads as _loads 4 | _lookup_attr = _loads('cchameleon.core.codegen\nlookup_attr\np1\n.') 5 | _init_scope = _loads('cchameleon.core.utils\necontext\np1\n.') 6 | _re_amp = _loads("cre\n_compile\np1\n(S'&(?!([A-Za-z]+|#[0-9]+);)'\np2\nI0\ntRp3\n.") 7 | _attrs_4356384400 = _loads('(dp1\nVclass\np2\nVui-widget-header\np3\ns.') 8 | _attrs_4356384336 = _loads('(dp1\n.') 9 | _attrs_4356384272 = _loads('(dp1\n.') 10 | _attrs_4356384528 = _loads('(dp1\n.') 11 | _init_stream = _loads('cchameleon.core.generation\ninitialize_stream\np1\n.') 12 | _attrs_4356384912 = _loads('(dp1\n.') 13 | _attrs_4356384720 = _loads('(dp1\n.') 14 | _init_default = _loads('cchameleon.core.generation\ninitialize_default\np1\n.') 15 | _attrs_4356384016 = _loads('(dp1\n.') 16 | _init_tal = _loads('cchameleon.core.generation\ninitialize_tal\np1\n.') 17 | def render(econtext, rcontext=None): 18 | macros = econtext.get('macros') 19 | _translate = econtext.get('_translate') 20 | _slots = econtext.get('_slots') 21 | target_language = econtext.get('target_language') 22 | u'_init_stream()' 23 | (_out, _write, ) = _init_stream() 24 | u'_init_tal()' 25 | (_attributes, repeat, ) = _init_tal() 26 | u'_init_default()' 27 | _default = _init_default() 28 | u'None' 29 | default = None 30 | u'None' 31 | _domain = None 32 | attrs = _attrs_4356384016 33 | _write(u'\n ') 34 | attrs = _attrs_4356384272 35 | _write(u'\n ') 36 | attrs = _attrs_4356384400 37 | u"''" 38 | _write(u'\n ') 39 | _default.value = default = '' 40 | u'collection.render_fields.itervalues()' 41 | _tmp1 = _lookup_attr(_lookup_attr(econtext['collection'], 'render_fields'), 'itervalues')() 42 | field = None 43 | (_tmp1, _tmp2, ) = repeat.insert('field', _tmp1) 44 | for field in _tmp1: 45 | _tmp2 = (_tmp2 - 1) 46 | u'field.label()' 47 | _content = _lookup_attr(field, 'label')() 48 | attrs = _attrs_4356384528 49 | u'_content' 50 | _write(u'') 76 | if (_tmp2 == 0): 77 | break 78 | _write(' ') 79 | _write(u'\n \n \n ') 80 | attrs = _attrs_4356384336 81 | u'collection.rows' 82 | _write(u'\n ') 83 | _tmp1 = _lookup_attr(econtext['collection'], 'rows') 84 | row = None 85 | (_tmp1, _tmp2, ) = repeat.insert('row', _tmp1) 86 | for row in _tmp1: 87 | _tmp2 = (_tmp2 - 1) 88 | u'collection._set_active(row)' 89 | _write(u'') 90 | dummy = _lookup_attr(econtext['collection'], '_set_active')(row) 91 | attrs = _attrs_4356384720 92 | u"ui-widget-${repeat.row.even and 'even' or 'odd'}" 93 | _write(u'' in _tmp3): 111 | _tmp3 = _tmp3.replace('>', '>') 112 | if ('"' in _tmp3): 113 | _tmp3 = _tmp3.replace('"', '"') 114 | _write(((' class="' + _tmp3) + '"')) 115 | u"''" 116 | _write(u'>\n ') 117 | _default.value = default = '' 118 | u'collection.render_fields.itervalues()' 119 | _tmp3 = _lookup_attr(_lookup_attr(econtext['collection'], 'render_fields'), 'itervalues')() 120 | field = None 121 | (_tmp3, _tmp4, ) = repeat.insert('field', _tmp3) 122 | for field in _tmp3: 123 | _tmp4 = (_tmp4 - 1) 124 | u'field.render_readonly()' 125 | _content = _lookup_attr(field, 'render_readonly')() 126 | attrs = _attrs_4356384912 127 | u'_content' 128 | _write(u'') 145 | if (_tmp4 == 0): 146 | break 147 | _write(' ') 148 | _write(u'\n \n ') 149 | if (_tmp2 == 0): 150 | break 151 | _write(' ') 152 | _write(u'\n \n
') 51 | _tmp3 = _content 52 | _tmp = _tmp3 53 | if (_tmp.__class__ not in (str, unicode, int, float, )): 54 | try: 55 | _tmp = _tmp.__html__ 56 | except: 57 | _tmp = _translate(_tmp, domain=_domain, mapping=None, target_language=target_language, default=None) 58 | else: 59 | _tmp = _tmp() 60 | _write(_tmp) 61 | _tmp = None 62 | if (_tmp is not None): 63 | if not isinstance(_tmp, unicode): 64 | _tmp = str(_tmp) 65 | if ('&' in _tmp): 66 | if (';' in _tmp): 67 | _tmp = _re_amp.sub('&', _tmp) 68 | else: 69 | _tmp = _tmp.replace('&', '&') 70 | if ('<' in _tmp): 71 | _tmp = _tmp.replace('<', '<') 72 | if ('>' in _tmp): 73 | _tmp = _tmp.replace('>', '>') 74 | _write(_tmp) 75 | _write(u'
') 129 | _tmp5 = _content 130 | _tmp = _tmp5 131 | if (_tmp.__class__ not in (str, unicode, int, float, )): 132 | try: 133 | _tmp = _tmp.__html__ 134 | except: 135 | _tmp = _translate(_tmp, domain=_domain, mapping=None, target_language=target_language, default=None) 136 | else: 137 | _tmp = _tmp() 138 | _write(_tmp) 139 | _tmp = None 140 | if (_tmp is not None): 141 | if not isinstance(_tmp, unicode): 142 | _tmp = str(_tmp) 143 | _write(_tmp) 144 | _write(u'
') 153 | return _out.getvalue() 154 | return render 155 | 156 | __filename__ = '/Users/gawel/py/formalchemy_project/pyramid_formalchemy/pyramid_formalchemy/templates/forms/grid_readonly.pt' 157 | registry[(None, True, '1488bdb950901f8f258549439ef6661a49aae984')] = bind() 158 | -------------------------------------------------------------------------------- /pyramid_formalchemy/utils.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | from formalchemy.templates import TemplateEngine as BaseTemplateEngine 3 | from formalchemy import config 4 | from formalchemy import fatypes 5 | from webhelpers.html import literal 6 | from pyramid.renderers import render 7 | 8 | class TemplateEngine(BaseTemplateEngine): 9 | """A template engine aware of pyramid""" 10 | 11 | def __init__(self, *args, **kwargs): 12 | """Do nothing. Almost all the mechanism is deleged to pyramid.renderers""" 13 | 14 | def render(self, name=None, renderer=None, template=None, **kwargs): 15 | renderer = renderer or template 16 | if renderer is None: 17 | name = name.strip('/') 18 | if not name.endswith('.pt'): 19 | name = '%s.pt' % name 20 | renderer = 'pyramid_formalchemy:templates/forms/%s' % name 21 | kwargs.update(dict( 22 | fatypes=fatypes, 23 | )) 24 | return literal(render(renderer, kwargs, request=kwargs.get('request'))) 25 | 26 | config.engine = TemplateEngine() 27 | -------------------------------------------------------------------------------- /pyramidapp/CHANGES.txt: -------------------------------------------------------------------------------- 1 | 0.0 2 | --- 3 | 4 | - Initial version 5 | -------------------------------------------------------------------------------- /pyramidapp/README.txt: -------------------------------------------------------------------------------- 1 | pyramidapp README 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /pyramidapp/development.ini: -------------------------------------------------------------------------------- 1 | [app:pyramidapp] 2 | use = egg:pyramidapp 3 | reload_templates = true 4 | debug_authorization = false 5 | debug_notfound = false 6 | debug_routematch = false 7 | debug_templates = true 8 | default_locale_name = en 9 | sqlalchemy.url = sqlite:///%(here)s/pyramidapp.db 10 | 11 | [pipeline:main] 12 | pipeline = 13 | egg:WebError#evalerror 14 | egg:repoze.tm2#tm 15 | pyramidapp 16 | 17 | [server:main] 18 | use = egg:Paste#http 19 | host = 0.0.0.0 20 | port = 6543 21 | 22 | # Begin logging configuration 23 | 24 | [loggers] 25 | keys = root, sqlalchemy 26 | 27 | [handlers] 28 | keys = console 29 | 30 | [formatters] 31 | keys = generic 32 | 33 | [logger_root] 34 | level = INFO 35 | handlers = console 36 | 37 | [logger_sqlalchemy] 38 | level = INFO 39 | handlers = 40 | qualname = sqlalchemy.engine 41 | # "level = INFO" logs SQL queries. 42 | # "level = DEBUG" logs SQL queries and results. 43 | # "level = WARN" logs neither. (Recommended for production systems.) 44 | 45 | [handler_console] 46 | class = StreamHandler 47 | args = (sys.stderr,) 48 | level = NOTSET 49 | formatter = generic 50 | 51 | [formatter_generic] 52 | format = %(asctime)s %(levelname)-5.5s [%(name)s][%(threadName)s] %(message)s 53 | 54 | # End logging configuration 55 | -------------------------------------------------------------------------------- /pyramidapp/jquery.ini: -------------------------------------------------------------------------------- 1 | [app:pyramidapp] 2 | use = egg:pyramidapp#jquery 3 | reload_templates = true 4 | debug_authorization = false 5 | debug_notfound = false 6 | debug_routematch = false 7 | debug_templates = true 8 | default_locale_name = en 9 | sqlalchemy.url = %(db)s 10 | 11 | [pipeline:main] 12 | pipeline = 13 | egg:WebError#evalerror 14 | egg:repoze.tm2#tm 15 | pyramidapp 16 | 17 | [server:main] 18 | use = egg:Paste#http 19 | host = 0.0.0.0 20 | port = 6543 21 | 22 | # Begin logging configuration 23 | 24 | [loggers] 25 | keys = root, sqlalchemy 26 | 27 | [handlers] 28 | keys = console 29 | 30 | [formatters] 31 | keys = generic 32 | 33 | [logger_root] 34 | level = INFO 35 | handlers = console 36 | 37 | [logger_sqlalchemy] 38 | level = INFO 39 | handlers = 40 | qualname = sqlalchemy.engine 41 | # "level = INFO" logs SQL queries. 42 | # "level = DEBUG" logs SQL queries and results. 43 | # "level = WARN" logs neither. (Recommended for production systems.) 44 | 45 | [handler_console] 46 | class = StreamHandler 47 | args = (sys.stderr,) 48 | level = NOTSET 49 | formatter = generic 50 | 51 | [formatter_generic] 52 | format = %(asctime)s %(levelname)-5.5s [%(name)s][%(threadName)s] %(message)s 53 | 54 | # End logging configuration 55 | -------------------------------------------------------------------------------- /pyramidapp/pyramidapp/__init__.py: -------------------------------------------------------------------------------- 1 | from pyramid.config import Configurator 2 | from sqlalchemy import engine_from_config 3 | 4 | from pyramidapp.models import initialize_sql 5 | from pyramidapp import events; events #pyflakes 6 | 7 | def main(global_config, **settings): 8 | """ This function returns a Pyramid WSGI application. 9 | """ 10 | engine = engine_from_config(settings, 'sqlalchemy.') 11 | initialize_sql(engine) 12 | config = Configurator(settings=settings) 13 | config.add_static_view('static', 'pyramidapp:static') 14 | config.add_route('home', '/') 15 | config.add_view('pyramidapp.views.my_view', 16 | route_name='home', 17 | renderer='templates/mytemplate.pt') 18 | 19 | # pyramid_formalchemy's configuration 20 | config.include('pyramid_formalchemy') 21 | 22 | # register an admin UI 23 | config.formalchemy_admin('admin', package='pyramidapp') 24 | 25 | # register an admin UI for a single model 26 | config.formalchemy_model('foo', package='pyramidapp', model='pyramidapp.models.Foo') 27 | 28 | # register custom model listing 29 | config.formalchemy_model_view('admin', 30 | model='pyramidapp.models.Foo', 31 | context='pyramid_formalchemy.resources.ModelListing', 32 | renderer='templates/foolisting.pt', 33 | attr='listing', 34 | request_method='GET', 35 | permission='view') 36 | 37 | # register custom model view 38 | config.formalchemy_model_view('admin', 39 | model='pyramidapp.models.Foo', 40 | context='pyramid_formalchemy.resources.Model', 41 | name='', 42 | renderer='templates/fooshow.pt', 43 | attr='show', 44 | request_method='GET', 45 | permission='view') 46 | 47 | return config.make_wsgi_app() 48 | 49 | 50 | -------------------------------------------------------------------------------- /pyramidapp/pyramidapp/events.py: -------------------------------------------------------------------------------- 1 | from pyramid_formalchemy import events 2 | from pyramidapp.models import Foo 3 | import logging 4 | 5 | log = logging.getLogger(__name__) 6 | 7 | @events.subscriber([Foo, events.IBeforeValidateEvent]) 8 | def before_foo_validate(context, event): 9 | log.info("%r will be validated" % context) 10 | 11 | @events.subscriber([Foo, events.IAfterSyncEvent]) 12 | def after_foo_sync(context, event): 13 | log.info("%r foo has been synced" % context) 14 | 15 | @events.subscriber([Foo, events.IBeforeDeleteEvent]) 16 | def before_foo_delete(context, event): 17 | log.info("%r foo will be deleted" % context) 18 | 19 | @events.subscriber([Foo, events.IBeforeRenderEvent]) 20 | def before_foo_render(context, event): 21 | log.info("%r foo will be rendered" % event.object) 22 | 23 | @events.subscriber([Foo, events.IBeforeShowRenderEvent]) 24 | def before_foo_show_render(context, event): 25 | log.info("%r foo show will be rendered" % event.object) 26 | 27 | @events.subscriber([Foo, events.IBeforeEditRenderEvent]) 28 | def before_foo_edit_render(context, event): 29 | log.info("%r foo edit will be rendered" % event.object) 30 | 31 | @events.subscriber([Foo, events.IBeforeListingRenderEvent]) 32 | def before_foo_listing_render(context, event): 33 | log.info("%r listing will be rendered" % context) 34 | 35 | -------------------------------------------------------------------------------- /pyramidapp/pyramidapp/forms.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | from pyramid_formalchemy.utils import TemplateEngine 3 | from pyramidapp import models 4 | from formalchemy import Grid, FieldSet 5 | from formalchemy import fields 6 | from formalchemy import config 7 | 8 | config.engine = TemplateEngine() 9 | 10 | FieldSet.default_renderers['dropdown'] = fields.SelectFieldRenderer 11 | 12 | MyModel = FieldSet(models.MyModel) 13 | 14 | GridMyModel = Grid(models.MyModel) 15 | GridMyModelReadOnly = Grid(models.MyModel) 16 | GridMyModelReadOnly.configure(readonly=True) 17 | 18 | FooEdit = FieldSet(models.Foo) 19 | FooEdit.configure() 20 | -------------------------------------------------------------------------------- /pyramidapp/pyramidapp/jquery.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | from pyramid.config import Configurator 3 | from sqlalchemy import engine_from_config 4 | 5 | from pyramidapp.models import initialize_sql 6 | 7 | def main(global_config, **settings): 8 | """ This function returns a Pyramid WSGI application. 9 | """ 10 | engine = engine_from_config(settings, 'sqlalchemy.') 11 | initialize_sql(engine) 12 | config = Configurator(settings=settings) 13 | config.add_static_view('static', 'pyramidapp:static') 14 | config.add_route('home', '/') 15 | config.add_view('pyramidapp.views.my_view', 16 | route_name='home', 17 | renderer='templates/mytemplate.pt') 18 | 19 | # pyramid_formalchemy's configuration 20 | config.include('pyramid_fanstatic') 21 | config.include('pyramid_formalchemy') 22 | config.include('fa.jquery') 23 | 24 | # register an admin UI 25 | config.formalchemy_admin('/admin', package='pyramidapp', view='fa.jquery.pyramid.ModelView') 26 | 27 | # register an admin UI for a single model 28 | config.formalchemy_model('/foo', package='pyramidapp', 29 | view='fa.jquery.pyramid.ModelView', 30 | model='pyramidapp.models.Foo') 31 | 32 | return config.make_wsgi_app() 33 | 34 | 35 | -------------------------------------------------------------------------------- /pyramidapp/pyramidapp/models.py: -------------------------------------------------------------------------------- 1 | import transaction 2 | 3 | from sqlalchemy import Table 4 | from sqlalchemy import Column 5 | from sqlalchemy import Integer 6 | from sqlalchemy import Unicode 7 | from sqlalchemy import ForeignKey 8 | 9 | from sqlalchemy.exc import IntegrityError 10 | from sqlalchemy.orm import relation 11 | from sqlalchemy.ext.declarative import declarative_base 12 | 13 | from sqlalchemy.orm import scoped_session 14 | from sqlalchemy.orm import sessionmaker 15 | 16 | from zope.sqlalchemy import ZopeTransactionExtension 17 | from pyramid.security import Allow, Authenticated, ALL_PERMISSIONS 18 | 19 | DBSession = scoped_session(sessionmaker(extension=ZopeTransactionExtension())) 20 | Base = declarative_base() 21 | 22 | class MyModel(Base): 23 | __tablename__ = 'models' 24 | id = Column(Integer, primary_key=True) 25 | name = Column(Unicode(255), unique=True) 26 | value = Column(Integer) 27 | 28 | class Foo(Base): 29 | __tablename__ = 'foo' 30 | __acl__ = [ 31 | (Allow, 'admin', ALL_PERMISSIONS), 32 | (Allow, Authenticated, 'view'), 33 | (Allow, 'editor', 'edit'), 34 | (Allow, 'manager', ('new', 'edit', 'delete')), 35 | ] 36 | id = Column(Integer, primary_key=True) 37 | bar = Column(Unicode(255)) 38 | 39 | 40 | class Bar(Base): 41 | __tablename__ = 'bar' 42 | __acl__ = [ 43 | (Allow, 'admin', ALL_PERMISSIONS), 44 | (Allow, 'bar_manager', ('view', 'new', 'edit')), 45 | ] 46 | id = Column(Integer, primary_key=True) 47 | foo = Column(Unicode(255)) 48 | 49 | class User(Base): 50 | __tablename__ = 'users' 51 | id = Column(Integer, primary_key=True) 52 | name = Column(Unicode) 53 | group_id = Column(Integer, ForeignKey('groups.id')) 54 | group = relation("Group", backref='users') 55 | 56 | def __unicode__(self): 57 | return self.name 58 | 59 | group_permissions = Table('group_permissions', Base.metadata, 60 | Column('permission_id', Integer, ForeignKey('permissions.id')), 61 | Column('group_id', Integer, ForeignKey('groups.id')), 62 | ) 63 | 64 | class Group(Base): 65 | __tablename__ = 'groups' 66 | id = Column(Integer, primary_key=True) 67 | name = Column(Unicode) 68 | permissions = relation("Permission", secondary=group_permissions, backref="groups") 69 | 70 | def __unicode__(self): 71 | return self.name 72 | 73 | class Permission(Base): 74 | __tablename__ = 'permissions' 75 | id = Column(Integer, primary_key=True) 76 | name = Column(Unicode) 77 | 78 | def __unicode__(self): 79 | return self.name 80 | 81 | def populate(): 82 | session = DBSession() 83 | model = MyModel(name=u'root',value=55) 84 | session.add(model) 85 | session.flush() 86 | for i in range(50): 87 | model = MyModel(name=u'root%i' % i,value=i) 88 | session.add(model) 89 | session.flush() 90 | g = Group() 91 | g.id = 1 92 | g.name = 'group1' 93 | transaction.commit() 94 | 95 | def initialize_sql(engine): 96 | DBSession.configure(bind=engine) 97 | Base.metadata.bind = engine 98 | Base.metadata.create_all(engine) 99 | try: 100 | populate() 101 | except IntegrityError: 102 | DBSession.rollback() 103 | -------------------------------------------------------------------------------- /pyramidapp/pyramidapp/resources.py: -------------------------------------------------------------------------------- 1 | class Root(object): 2 | def __init__(self, request): 3 | self.request = request 4 | -------------------------------------------------------------------------------- /pyramidapp/pyramidapp/security.py: -------------------------------------------------------------------------------- 1 | from pyramid.config import Configurator 2 | from sqlalchemy import engine_from_config 3 | from pyramid.authorization import ACLAuthorizationPolicy 4 | from pyramid.authentication import RemoteUserAuthenticationPolicy 5 | from pyramid_formalchemy.resources import Models 6 | from pyramid.security import Allow, Authenticated, ALL_PERMISSIONS 7 | 8 | from pyramidapp.models import initialize_sql 9 | 10 | class ModelsWithACL(Models): 11 | """A factory to override the default security setting""" 12 | __acl__ = [ 13 | (Allow, 'admin', ALL_PERMISSIONS), 14 | (Allow, Authenticated, 'view'), 15 | (Allow, 'editor', 'edit'), 16 | (Allow, 'manager', ('new', 'edit', 'delete')), 17 | ] 18 | 19 | def main(global_config, **settings): 20 | """ This function returns a Pyramid WSGI application. 21 | """ 22 | engine = engine_from_config(settings, 'sqlalchemy.') 23 | initialize_sql(engine) 24 | 25 | # configure the security stuff 26 | config = Configurator(settings=settings, 27 | authentication_policy=RemoteUserAuthenticationPolicy(), 28 | authorization_policy=ACLAuthorizationPolicy()) 29 | 30 | config.add_static_view('static', 'pyramidapp:static') 31 | config.add_route('home', '/') 32 | config.add_view('pyramidapp.views.my_view', 33 | route_name='home', 34 | renderer='templates/mytemplate.pt') 35 | 36 | # pyramid_formalchemy's configuration 37 | config.include('pyramid_formalchemy') 38 | config.formalchemy_admin('admin', package='pyramidapp', 39 | factory=ModelsWithACL) # use the secure factory 40 | 41 | return config.make_wsgi_app() 42 | 43 | 44 | -------------------------------------------------------------------------------- /pyramidapp/pyramidapp/static/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FormAlchemy/pyramid_formalchemy/62919df6c88230e80b48c0e70932ddc115f0821c/pyramidapp/pyramidapp/static/favicon.ico -------------------------------------------------------------------------------- /pyramidapp/pyramidapp/static/footerbg.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FormAlchemy/pyramid_formalchemy/62919df6c88230e80b48c0e70932ddc115f0821c/pyramidapp/pyramidapp/static/footerbg.png -------------------------------------------------------------------------------- /pyramidapp/pyramidapp/static/headerbg.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FormAlchemy/pyramid_formalchemy/62919df6c88230e80b48c0e70932ddc115f0821c/pyramidapp/pyramidapp/static/headerbg.png -------------------------------------------------------------------------------- /pyramidapp/pyramidapp/static/ie6.css: -------------------------------------------------------------------------------- 1 | * html img, 2 | * html .png{position:relative;behavior:expression((this.runtimeStyle.behavior="none")&&(this.pngSet?this.pngSet=true:(this.nodeName == "IMG" && this.src.toLowerCase().indexOf('.png')>-1?(this.runtimeStyle.backgroundImage = "none", 3 | this.runtimeStyle.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + this.src + "',sizingMethod='image')", 4 | this.src = "static/transparent.gif"):(this.origBg = this.origBg? this.origBg :this.currentStyle.backgroundImage.toString().replace('url("','').replace('")',''), 5 | this.runtimeStyle.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + this.origBg + "',sizingMethod='crop')", 6 | this.runtimeStyle.backgroundImage = "none")),this.pngSet=true) 7 | );} 8 | #wrap{display:table;height:100%} 9 | -------------------------------------------------------------------------------- /pyramidapp/pyramidapp/static/middlebg.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FormAlchemy/pyramid_formalchemy/62919df6c88230e80b48c0e70932ddc115f0821c/pyramidapp/pyramidapp/static/middlebg.png -------------------------------------------------------------------------------- /pyramidapp/pyramidapp/static/pylons.css: -------------------------------------------------------------------------------- 1 | html,body,div,span,applet,object,iframe,h1,h2,h3,h4,h5,h6,p,blockquote,pre,a,abbr,acronym,address,big,cite,code,del,dfn,em,font,img,ins,kbd,q,s,samp,small,strike,strong,sub,sup,tt,var,b,u,i,center,dl,dt,dd,ol,ul,li,fieldset,form,label,legend,table,caption,tbody,tfoot,thead,tr,th,td{margin:0;padding:0;border:0;outline:0;font-size:100%;/* 16px */ 2 | vertical-align:baseline;background:transparent;} 3 | body{line-height:1;} 4 | ol,ul{list-style:none;} 5 | blockquote,q{quotes:none;} 6 | blockquote:before,blockquote:after,q:before,q:after{content:'';content:none;} 7 | :focus{outline:0;} 8 | ins{text-decoration:none;} 9 | del{text-decoration:line-through;} 10 | table{border-collapse:collapse;border-spacing:0;} 11 | sub{vertical-align:sub;font-size:smaller;line-height:normal;} 12 | sup{vertical-align:super;font-size:smaller;line-height:normal;} 13 | ul,menu,dir{display:block;list-style-type:disc;margin:1em 0;padding-left:40px;} 14 | ol{display:block;list-style-type:decimal-leading-zero;margin:1em 0;padding-left:40px;} 15 | li{display:list-item;} 16 | ul ul,ul ol,ul dir,ul menu,ul dl,ol ul,ol ol,ol dir,ol menu,ol dl,dir ul,dir ol,dir dir,dir menu,dir dl,menu ul,menu ol,menu dir,menu menu,menu dl,dl ul,dl ol,dl dir,dl menu,dl dl{margin-top:0;margin-bottom:0;} 17 | ol ul,ul ul,menu ul,dir ul,ol menu,ul menu,menu menu,dir menu,ol dir,ul dir,menu dir,dir dir{list-style-type:circle;} 18 | ol ol ul,ol ul ul,ol menu ul,ol dir ul,ol ol menu,ol ul menu,ol menu menu,ol dir menu,ol ol dir,ol ul dir,ol menu dir,ol dir dir,ul ol ul,ul ul ul,ul menu ul,ul dir ul,ul ol menu,ul ul menu,ul menu menu,ul dir menu,ul ol dir,ul ul dir,ul menu dir,ul dir dir,menu ol ul,menu ul ul,menu menu ul,menu dir ul,menu ol menu,menu ul menu,menu menu menu,menu dir menu,menu ol dir,menu ul dir,menu menu dir,menu dir dir,dir ol ul,dir ul ul,dir menu ul,dir dir ul,dir ol menu,dir ul menu,dir menu menu,dir dir menu,dir ol dir,dir ul dir,dir menu dir,dir dir dir{list-style-type:square;} 19 | .hidden{display:none;} 20 | p{line-height:1.5em;} 21 | h1{font-size:1.75em;line-height:1.7em;font-family:helvetica,verdana;} 22 | h2{font-size:1.5em;line-height:1.7em;font-family:helvetica,verdana;} 23 | h3{font-size:1.25em;line-height:1.7em;font-family:helvetica,verdana;} 24 | h4{font-size:1em;line-height:1.7em;font-family:helvetica,verdana;} 25 | html,body{width:100%;height:100%;} 26 | body{margin:0;padding:0;background-color:#ffffff;position:relative;font:16px/24px "Nobile","Lucida Grande",Lucida,Verdana,sans-serif;} 27 | a{color:#1b61d6;text-decoration:none;} 28 | a:hover{color:#e88f00;text-decoration:underline;} 29 | body h1, 30 | body h2, 31 | body h3, 32 | body h4, 33 | body h5, 34 | body h6{font-family:"Neuton","Lucida Grande",Lucida,Verdana,sans-serif;font-weight:normal;color:#373839;font-style:normal;} 35 | #wrap{min-height:100%;} 36 | #header,#footer{width:100%;color:#ffffff;height:40px;position:absolute;text-align:center;line-height:40px;overflow:hidden;font-size:12px;vertical-align:middle;} 37 | #header{background:#000000;top:0;font-size:14px;} 38 | #footer{bottom:0;background:#000000 url(footerbg.png) repeat-x 0 top;position:relative;margin-top:-40px;clear:both;} 39 | .header,.footer{width:750px;margin-right:auto;margin-left:auto;} 40 | .wrapper{width:100%} 41 | #top,#top-small,#bottom{width:100%;} 42 | #top{color:#000000;height:230px;background:#ffffff url(headerbg.png) repeat-x 0 top;position:relative;} 43 | #top-small{color:#000000;height:60px;background:#ffffff url(headerbg.png) repeat-x 0 top;position:relative;} 44 | #bottom{color:#222;background-color:#ffffff;} 45 | .top,.top-small,.middle,.bottom{width:750px;margin-right:auto;margin-left:auto;} 46 | .top{padding-top:40px;} 47 | .top-small{padding-top:10px;} 48 | #middle{width:100%;height:100px;background:url(middlebg.png) repeat-x;border-top:2px solid #ffffff;border-bottom:2px solid #b2b2b2;} 49 | .app-welcome{margin-top:25px;} 50 | .app-name{color:#000000;font-weight:bold;} 51 | .bottom{padding-top:50px;} 52 | #left{width:350px;float:left;padding-right:25px;} 53 | #right{width:350px;float:right;padding-left:25px;} 54 | .align-left{text-align:left;} 55 | .align-right{text-align:right;} 56 | .align-center{text-align:center;} 57 | ul.links{margin:0;padding:0;} 58 | ul.links li{list-style-type:none;font-size:14px;} 59 | form{border-style:none;} 60 | fieldset{border-style:none;} 61 | input{color:#222;border:1px solid #ccc;font-family:sans-serif;font-size:12px;line-height:16px;} 62 | input[type=text],input[type=password]{width:205px;} 63 | input[type=submit]{background-color:#ddd;font-weight:bold;} 64 | /*Opera Fix*/ 65 | body:before{content:"";height:100%;float:left;width:0;margin-top:-32767px;} 66 | -------------------------------------------------------------------------------- /pyramidapp/pyramidapp/static/pyramid-small.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FormAlchemy/pyramid_formalchemy/62919df6c88230e80b48c0e70932ddc115f0821c/pyramidapp/pyramidapp/static/pyramid-small.png -------------------------------------------------------------------------------- /pyramidapp/pyramidapp/static/pyramid.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FormAlchemy/pyramid_formalchemy/62919df6c88230e80b48c0e70932ddc115f0821c/pyramidapp/pyramidapp/static/pyramid.png -------------------------------------------------------------------------------- /pyramidapp/pyramidapp/static/transparent.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FormAlchemy/pyramid_formalchemy/62919df6c88230e80b48c0e70932ddc115f0821c/pyramidapp/pyramidapp/static/transparent.gif -------------------------------------------------------------------------------- /pyramidapp/pyramidapp/templates/foolisting.pt: -------------------------------------------------------------------------------- 1 | 2 | 3 |
4 | My Foo custom listing 5 |
6 | 7 |

8 |

9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /pyramidapp/pyramidapp/templates/foolisting.pt.py: -------------------------------------------------------------------------------- 1 | registry = dict(version=0) 2 | def bind(): 3 | from cPickle import loads as _loads 4 | _lookup_attr = _loads('cchameleon.core.codegen\nlookup_attr\np1\n.') 5 | _init_scope = _loads('cchameleon.core.utils\necontext\np1\n.') 6 | _attrs_4357125136 = _loads('(dp1\nVclass\np2\nVlayout-grid\np3\ns.') 7 | _attrs_4357125072 = _loads('(dp1\nVclass\np2\nVui-pager\np3\ns.') 8 | _attrs_4357124944 = _loads('(dp1\n.') 9 | _init_stream = _loads('cchameleon.core.generation\ninitialize_stream\np1\n.') 10 | _attrs_4357125200 = _loads('(dp1\nVclass\np2\nVfa_field\np3\ns.') 11 | _init_default = _loads('cchameleon.core.generation\ninitialize_default\np1\n.') 12 | _init_tal = _loads('cchameleon.core.generation\ninitialize_tal\np1\n.') 13 | def render(econtext, rcontext=None): 14 | macros = econtext.get('macros') 15 | _translate = econtext.get('_translate') 16 | _slots = econtext.get('_slots') 17 | target_language = econtext.get('target_language') 18 | u'_init_stream()' 19 | (_out, _write, ) = _init_stream() 20 | u'_init_tal()' 21 | (_attributes, repeat, ) = _init_tal() 22 | u'_init_default()' 23 | _default = _init_default() 24 | u'None' 25 | default = None 26 | u'None' 27 | _domain = None 28 | u"main.macros['master']" 29 | _metal = _lookup_attr(econtext['main'], 'macros')['master'] 30 | def _callback_main(econtext, _repeat, _out=_out, _write=_write, _domain=_domain, **_ignored): 31 | if _repeat: 32 | repeat.update(_repeat) 33 | attrs = _attrs_4357124944 34 | u"''" 35 | _write(u'
\n My Foo custom listing\n ') 36 | _default.value = default = '' 37 | u'pager' 38 | _content = econtext['pager'] 39 | attrs = _attrs_4357125072 40 | u'_content' 41 | _write(u'
') 42 | _tmp1 = _content 43 | _tmp = _tmp1 44 | if (_tmp.__class__ not in (str, unicode, int, float, )): 45 | try: 46 | _tmp = _tmp.__html__ 47 | except: 48 | _tmp = _translate(_tmp, domain=_domain, mapping=None, target_language=target_language, default=None) 49 | else: 50 | _tmp = _tmp() 51 | _write(_tmp) 52 | _tmp = None 53 | if (_tmp is not None): 54 | if not isinstance(_tmp, unicode): 55 | _tmp = str(_tmp) 56 | _write(_tmp) 57 | u"''" 58 | _write(u'
\n ') 59 | _default.value = default = '' 60 | u'fs.render()' 61 | _content = _lookup_attr(econtext['fs'], 'render')() 62 | attrs = _attrs_4357125136 63 | u'_content' 64 | _write(u'
') 65 | _tmp1 = _content 66 | _tmp = _tmp1 67 | if (_tmp.__class__ not in (str, unicode, int, float, )): 68 | try: 69 | _tmp = _tmp.__html__ 70 | except: 71 | _tmp = _translate(_tmp, domain=_domain, mapping=None, target_language=target_language, default=None) 72 | else: 73 | _tmp = _tmp() 74 | _write(_tmp) 75 | _tmp = None 76 | if (_tmp is not None): 77 | if not isinstance(_tmp, unicode): 78 | _tmp = str(_tmp) 79 | _write(_tmp) 80 | u"u'\\n '" 81 | _write(u'
\n ') 82 | _default.value = default = u'\n ' 83 | u'actions.buttons(request)' 84 | _content = _lookup_attr(econtext['actions'], 'buttons')(econtext['request']) 85 | attrs = _attrs_4357125200 86 | u'_content' 87 | _write(u'

') 88 | _tmp1 = _content 89 | _tmp = _tmp1 90 | if (_tmp.__class__ not in (str, unicode, int, float, )): 91 | try: 92 | _tmp = _tmp.__html__ 93 | except: 94 | _tmp = _translate(_tmp, domain=_domain, mapping=None, target_language=target_language, default=None) 95 | else: 96 | _tmp = _tmp() 97 | _write(_tmp) 98 | _tmp = None 99 | if (_tmp is not None): 100 | if not isinstance(_tmp, unicode): 101 | _tmp = str(_tmp) 102 | _write(_tmp) 103 | _write(u'

\n
\n') 104 | u"{'main': _callback_main}" 105 | _tmp = {'main': _callback_main, } 106 | u"main.macros['master']" 107 | _metal.render(_tmp, _out=_out, _write=_write, _domain=_domain, econtext=econtext) 108 | return _out.getvalue() 109 | return render 110 | 111 | __filename__ = '/Users/gawel/py/formalchemy_project/pyramid_formalchemy/pyramidapp/pyramidapp/templates/foolisting.pt' 112 | registry[(None, True, '1488bdb950901f8f258549439ef6661a49aae984')] = bind() 113 | -------------------------------------------------------------------------------- /pyramidapp/pyramidapp/templates/fooshow.pt: -------------------------------------------------------------------------------- 1 | 2 | 3 |
4 | Custom Foo view 5 |
6 | 19 |
20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /pyramidapp/pyramidapp/templates/fooshow.pt.py: -------------------------------------------------------------------------------- 1 | registry = dict(version=0) 2 | def bind(): 3 | from cPickle import loads as _loads 4 | _lookup_attr = _loads('cchameleon.core.codegen\nlookup_attr\np1\n.') 5 | _init_scope = _loads('cchameleon.core.utils\necontext\np1\n.') 6 | _re_amp = _loads("cre\n_compile\np1\n(S'&(?!([A-Za-z]+|#[0-9]+);)'\np2\nI0\ntRp3\n.") 7 | _attrs_4356515344 = _loads('(dp1\n.') 8 | _attrs_4356515728 = _loads('(dp1\nVclass\np2\nVui-widget-header ui-widget-link ui-corner-all\np3\ns.') 9 | _attrs_4356515408 = _loads('(dp1\n.') 10 | _init_stream = _loads('cchameleon.core.generation\ninitialize_stream\np1\n.') 11 | _attrs_4356515920 = _loads('(dp1\nVclass\np2\nVui-icon ui-icon-circle-arrow-w\np3\ns.') 12 | _attrs_4356515664 = _loads('(dp1\nVhref\np2\nV#\nsVclass\np3\nVui-widget-header ui-widget-link ui-widget-button ui-corner-all\np4\ns.') 13 | _attrs_4356515216 = _loads('(dp1\n.') 14 | _init_default = _loads('cchameleon.core.generation\ninitialize_default\np1\n.') 15 | _attrs_4356515536 = _loads('(dp1\nVclass\np2\nVfa_field\np3\ns.') 16 | _attrs_4356515792 = _loads("(dp1\nVtype\np2\nVsubmit\np3\nsVvalue\np4\nV${F_('Edit')}\np5\ns.") 17 | _init_tal = _loads('cchameleon.core.generation\ninitialize_tal\np1\n.') 18 | def render(econtext, rcontext=None): 19 | macros = econtext.get('macros') 20 | _translate = econtext.get('_translate') 21 | _slots = econtext.get('_slots') 22 | target_language = econtext.get('target_language') 23 | u'_init_stream()' 24 | (_out, _write, ) = _init_stream() 25 | u'_init_tal()' 26 | (_attributes, repeat, ) = _init_tal() 27 | u'_init_default()' 28 | _default = _init_default() 29 | u'None' 30 | default = None 31 | u'None' 32 | _domain = None 33 | u"main.macros['master']" 34 | _metal = _lookup_attr(econtext['main'], 'macros')['master'] 35 | def _callback_main(econtext, _repeat, _out=_out, _write=_write, _domain=_domain, **_ignored): 36 | if _repeat: 37 | repeat.update(_repeat) 38 | attrs = _attrs_4356515216 39 | u"''" 40 | _write(u'
\n Custom Foo view\n ') 41 | _default.value = default = '' 42 | u'fs.render()' 43 | _content = _lookup_attr(econtext['fs'], 'render')() 44 | attrs = _attrs_4356515344 45 | u'_content' 46 | _write(u'
') 47 | _tmp1 = _content 48 | _tmp = _tmp1 49 | if (_tmp.__class__ not in (str, unicode, int, float, )): 50 | try: 51 | _tmp = _tmp.__html__ 52 | except: 53 | _tmp = _translate(_tmp, domain=_domain, mapping=None, target_language=target_language, default=None) 54 | else: 55 | _tmp = _tmp() 56 | _write(_tmp) 57 | _tmp = None 58 | if (_tmp is not None): 59 | if not isinstance(_tmp, unicode): 60 | _tmp = str(_tmp) 61 | _write(_tmp) 62 | _write(u'
\n ') 63 | attrs = _attrs_4356515408 64 | _write(u'
\n ') 65 | attrs = _attrs_4356515536 66 | _write(u'

\n ') 67 | attrs = _attrs_4356515664 68 | u"request.fa_url(request.model_name, request.model_id, 'edit')" 69 | _write(u'' in _tmp1): 87 | _tmp1 = _tmp1.replace('>', '>') 88 | if ('"' in _tmp1): 89 | _tmp1 = _tmp1.replace('"', '"') 90 | _write(((' href="' + _tmp1) + '"')) 91 | _write(u'>\n ') 92 | attrs = _attrs_4356515792 93 | 'join(value("F_(\'Edit\')"),)' 94 | _write(u'' in _tmp1): 112 | _tmp1 = _tmp1.replace('>', '>') 113 | if ('"' in _tmp1): 114 | _tmp1 = _tmp1.replace('"', '"') 115 | _write(((' value="' + _tmp1) + '"')) 116 | _write(u' />\n \n ') 117 | attrs = _attrs_4356515728 118 | u'request.fa_url(request.model_name)' 119 | _write(u'' in _tmp1): 137 | _tmp1 = _tmp1.replace('>', '>') 138 | if ('"' in _tmp1): 139 | _tmp1 = _tmp1.replace('"', '"') 140 | _write(((' href="' + _tmp1) + '"')) 141 | _write(u'>\n ') 142 | attrs = _attrs_4356515920 143 | u"F_('Back')" 144 | _write(u'\n ') 145 | _tmp1 = econtext['F_']('Back') 146 | _tmp = _tmp1 147 | if (_tmp.__class__ not in (str, unicode, int, float, )): 148 | try: 149 | _tmp = _tmp.__html__ 150 | except: 151 | _tmp = _translate(_tmp, domain=_domain, mapping=None, target_language=target_language, default=None) 152 | else: 153 | _tmp = _tmp() 154 | _write(_tmp) 155 | _tmp = None 156 | if (_tmp is not None): 157 | if not isinstance(_tmp, unicode): 158 | _tmp = str(_tmp) 159 | if ('&' in _tmp): 160 | if (';' in _tmp): 161 | _tmp = _re_amp.sub('&', _tmp) 162 | else: 163 | _tmp = _tmp.replace('&', '&') 164 | if ('<' in _tmp): 165 | _tmp = _tmp.replace('<', '<') 166 | if ('>' in _tmp): 167 | _tmp = _tmp.replace('>', '>') 168 | _write(_tmp) 169 | _write(u'\n \n

\n
\n
\n') 170 | u"{'main': _callback_main}" 171 | _tmp = {'main': _callback_main, } 172 | u"main.macros['master']" 173 | _metal.render(_tmp, _out=_out, _write=_write, _domain=_domain, econtext=econtext) 174 | return _out.getvalue() 175 | return render 176 | 177 | __filename__ = '/Users/gawel/py/formalchemy_project/pyramid_formalchemy/pyramidapp/pyramidapp/templates/fooshow.pt' 178 | registry[(None, True, '1488bdb950901f8f258549439ef6661a49aae984')] = bind() 179 | -------------------------------------------------------------------------------- /pyramidapp/pyramidapp/templates/mytemplate.pt: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | The Pyramid Web Application Development Framework 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 15 | 16 | 17 |
18 |
19 |
20 |
pyramid
21 |
22 |
23 |
24 |
25 |

26 | Welcome to ${project}, an application generated by
27 | the Pyramid web application development framework. 28 |

29 |
30 |
31 |
32 |
33 |
34 |

Search documentation

35 |
36 | 37 | 38 |
39 |
40 | 69 |
70 |
71 |
72 | 75 | 76 | -------------------------------------------------------------------------------- /pyramidapp/pyramidapp/tests.py: -------------------------------------------------------------------------------- 1 | import unittest2 as unittest 2 | from pyramid.config import Configurator 3 | from pyramid import testing 4 | from sqlalchemy.orm import scoped_session 5 | from sqlalchemy.orm import sessionmaker 6 | 7 | from zope.sqlalchemy import ZopeTransactionExtension 8 | 9 | import os 10 | import shutil 11 | import tempfile 12 | from webtest import TestApp 13 | from pyramidapp import main 14 | from pyramidapp import models 15 | from paste.deploy import loadapp 16 | 17 | dirname = os.path.abspath(__file__) 18 | dirname = os.path.dirname(dirname) 19 | dirname = os.path.dirname(dirname) 20 | 21 | class Test_1_UI(unittest.TestCase): 22 | 23 | config = os.path.join(dirname, 'test.ini') 24 | extra_environ = {} 25 | 26 | def setUp(self): 27 | app = loadapp('config:%s' % self.config, global_conf={'db':'sqlite://'}) 28 | self.app = TestApp(app, extra_environ=self.extra_environ) 29 | self.config = Configurator(autocommit=True) 30 | self.config.begin() 31 | 32 | def test_index(self): 33 | resp = self.app.get('/') 34 | 35 | def test_1_crud(self): 36 | # index 37 | resp = self.app.get('/admin') 38 | self.assertEqual(resp.status_int, 302) 39 | assert '/admin/' in resp.location, resp 40 | 41 | resp = self.app.get('/admin/') 42 | resp.mustcontain('/admin/Foo') 43 | resp = resp.click('Foo') 44 | 45 | ## Simple model 46 | 47 | # add page 48 | resp.mustcontain('/admin/Foo/new') 49 | resp = resp.click(linkid='new') 50 | resp.mustcontain('/admin/Foo"') 51 | form = resp.forms[0] 52 | form['Foo--bar'] = 'value' 53 | resp = form.submit() 54 | assert resp.headers['location'] == 'http://localhost/admin/Foo', resp 55 | 56 | # model index 57 | resp = resp.follow() 58 | resp.mustcontain('value') 59 | form = resp.forms[0] 60 | resp = form.submit() 61 | 62 | # edit page 63 | form = resp.forms[0] 64 | form['Foo-1-bar'] = 'new value' 65 | #form['_method'] = 'PUT' 66 | resp = form.submit() 67 | resp = resp.follow() 68 | 69 | # model index 70 | resp.mustcontain('new value') 71 | 72 | # delete 73 | resp = self.app.get('/admin/Foo') 74 | resp.mustcontain('new value') 75 | resp = resp.forms[1].submit() 76 | resp = resp.follow() 77 | 78 | assert 'new value' not in resp, resp 79 | 80 | def test_2_model(self): 81 | # index 82 | resp = self.app.get('/foo') 83 | self.assertEqual(resp.status_int, 302) 84 | assert '/' in resp.location, resp 85 | 86 | ## Simple model 87 | resp = self.app.get('/foo/') 88 | 89 | # add page 90 | resp.mustcontain('/foo/new') 91 | resp = resp.click(linkid='new') 92 | resp.mustcontain('/foo') 93 | form = resp.forms[0] 94 | form['Foo--bar'] = 'value' 95 | resp = form.submit() 96 | assert resp.headers['location'] == 'http://localhost/foo/', resp 97 | 98 | # model index 99 | resp = resp.follow() 100 | resp.mustcontain('value') 101 | form = resp.forms[0] 102 | resp = form.submit() 103 | 104 | # edit page 105 | form = resp.forms[0] 106 | form['Foo-1-bar'] = 'new value' 107 | #form['_method'] = 'PUT' 108 | resp = form.submit() 109 | resp = resp.follow() 110 | 111 | # model index 112 | resp.mustcontain('new value') 113 | 114 | # delete 115 | resp = self.app.get('/foo/') 116 | resp.mustcontain('new value') 117 | resp = resp.forms[1].submit() 118 | resp = resp.follow() 119 | 120 | assert 'new value' not in resp, resp 121 | 122 | 123 | 124 | def test_3_json(self): 125 | # index 126 | response = self.app.get('/admin/json') 127 | response.mustcontain('{"models": {', '"Foo": "http://localhost/admin/Foo/json"') 128 | 129 | ## Simple model 130 | 131 | # add page 132 | response = self.app.post('/admin/Foo/json', 133 | {'bar': 'value'}) 134 | 135 | data = response.json 136 | id = data['absolute_url'].split('/')[-1] 137 | 138 | response.mustcontain('"bar": "value"') 139 | 140 | 141 | # get data 142 | response = self.app.get(str(data['absolute_url'])) 143 | response.mustcontain('"bar": "value"') 144 | 145 | # edit page 146 | response = self.app.post(str(data['absolute_url']), {'bar': 'new value'}) 147 | response.mustcontain('"bar": "new value"') 148 | 149 | # delete 150 | response = self.app.delete(str(data['absolute_url'])) 151 | self.assert_(response.json['id'] > 0) 152 | 153 | def test_4_json_prefix(self): 154 | # index 155 | response = self.app.get('/admin/json') 156 | response.mustcontain('{"models": {', '"Foo": "http://localhost/admin/Foo/json"') 157 | 158 | ## Simple model 159 | 160 | # add page 161 | response = self.app.post('/admin/Foo/json?with_prefix=True', 162 | {'Foo--bar': 'value', 'with_prefix': 'true'}) 163 | 164 | data = response.json 165 | id = data['absolute_url'].split('/')[-1] 166 | 167 | response.mustcontain('"Foo-%s-bar": "value"' % id) 168 | 169 | 170 | # get data 171 | response = self.app.get(str(data['absolute_url'])+'?with_prefix=True') 172 | response.mustcontain('"Foo-%s-bar": "value"' % id) 173 | 174 | # edit page 175 | response = self.app.post(str(data['absolute_url']+'?with_prefix=True'), {'Foo-%s-bar' % id: 'new value', 'with_prefix': 'true'}) 176 | response.mustcontain('"Foo-%s-bar": "new value"' % id) 177 | 178 | # delete 179 | response = self.app.delete(str(data['absolute_url']+'?with_prefix=True')) 180 | self.assert_(response.json['id'] > 0) 181 | 182 | def test_5_xhr(self): 183 | # add page 184 | resp = self.app.post('/admin/Foo/', {'Foo--bar':'value'}, extra_environ={'HTTP_X_REQUESTED_WITH':'XMLHttpRequest'}) 185 | self.assertEqual(resp.content_type, 'text/plain') 186 | 187 | resp = self.app.post('/admin/Foo/1', {'Foo-1-bar':'value'}, extra_environ={'HTTP_X_REQUESTED_WITH':'XMLHttpRequest'}) 188 | self.assertEqual(resp.content_type, 'text/plain') 189 | 190 | # assume all are deleted 191 | response = self.app.delete('/admin/Foo/1', extra_environ={'HTTP_X_REQUESTED_WITH':'XMLHttpRequest'}) 192 | self.assertEqual(resp.content_type, 'text/plain') 193 | 194 | 195 | class Test_2_Security(Test_1_UI): 196 | 197 | config = os.path.join(dirname, 'security.ini') 198 | extra_environ = {'REMOTE_USER': 'admin'} 199 | 200 | def test_model_security(self): 201 | resp = self.app.get('/admin/', extra_environ={'REMOTE_USER': 'editor'}) 202 | self.assertEqual(resp.status_int, 200) 203 | 204 | resp = self.app.get('/admin/Foo', extra_environ={'REMOTE_USER': 'editor'}) 205 | self.assertEqual(resp.status_int, 200) 206 | 207 | resp = self.app.get('/admin/Foo/new', status=403, extra_environ={'REMOTE_USER': 'editor'}) 208 | self.assertEqual(resp.status_int, 403) 209 | 210 | resp = self.app.get('/admin/Bar', status=403, extra_environ={'REMOTE_USER': 'editor'}) 211 | self.assertEqual(resp.status_int, 403) 212 | 213 | resp = self.app.get('/admin/Bar', extra_environ={'REMOTE_USER': 'bar_manager'}) 214 | self.assertEqual(resp.status_int, 200) 215 | 216 | resp = self.app.post('/admin/Bar', {'Bar--foo':'bar'}, extra_environ={'REMOTE_USER': 'bar_manager'}) 217 | resp = self.app.get('/admin/Bar/1/edit', extra_environ={'REMOTE_USER': 'admin'}) 218 | self.assertEqual(resp.status_int, 200) 219 | resp.mustcontain('Delete') 220 | resp = self.app.get('/admin/Bar/1/edit', extra_environ={'REMOTE_USER': 'bar_manager'}) 221 | self.assertEqual(resp.status_int, 200) 222 | assert 'Delete' not in resp.body, resp.body 223 | 224 | def test_2_model(self): 225 | pass 226 | 227 | 228 | 229 | class Test_3_JQuery(Test_1_UI): 230 | 231 | config = os.path.join(dirname, 'jquery.ini') 232 | 233 | def test_1_crud(self): 234 | # index 235 | resp = self.app.get('/admin/') 236 | resp.mustcontain('/admin/Foo') 237 | resp = resp.click('Foo') 238 | 239 | ## Simple model 240 | 241 | # add page 242 | resp.mustcontain('/admin/Foo/new') 243 | resp = resp.click(linkid='new') 244 | resp.mustcontain('/admin/Foo"') 245 | form = resp.forms[0] 246 | form['Foo--bar'] = 'value' 247 | resp = form.submit() 248 | assert resp.headers['location'] == 'http://localhost/admin/Foo', resp 249 | 250 | # model index 251 | resp = resp.follow() 252 | 253 | # edit page 254 | resp = self.app.get('/admin/Foo/1/edit') 255 | form = resp.forms[0] 256 | form['Foo-1-bar'] = 'new value' 257 | #form['_method'] = 'PUT' 258 | resp = form.submit() 259 | resp = resp.follow() 260 | 261 | # model index 262 | resp.mustcontain('new value') 263 | 264 | # delete 265 | resp = self.app.get('/admin/Foo') 266 | resp.mustcontain('jQuery') 267 | 268 | def test_2_model(self): 269 | pass 270 | -------------------------------------------------------------------------------- /pyramidapp/pyramidapp/views.py: -------------------------------------------------------------------------------- 1 | from pyramidapp.models import DBSession 2 | from pyramidapp.models import MyModel 3 | from pyramidapp import forms 4 | 5 | def my_view(request): 6 | dbsession = DBSession() 7 | root = dbsession.query(MyModel).filter(MyModel.name==u'root').first() 8 | fs = forms.GridMyModel.bind(instances=[root]).render() 9 | fs = forms.GridMyModelReadOnly.bind(instances=[root]).render() 10 | return {'root':root, 'project':'pyramidapp'} 11 | -------------------------------------------------------------------------------- /pyramidapp/security.ini: -------------------------------------------------------------------------------- 1 | [app:pyramidapp] 2 | use = egg:pyramidapp#security 3 | reload_templates = true 4 | debug_authorization = false 5 | debug_notfound = false 6 | debug_routematch = false 7 | debug_templates = true 8 | default_locale_name = en 9 | sqlalchemy.url = %(db)s 10 | 11 | [pipeline:main] 12 | pipeline = 13 | egg:WebError#evalerror 14 | egg:repoze.tm2#tm 15 | pyramidapp 16 | 17 | [server:main] 18 | use = egg:Paste#http 19 | host = 0.0.0.0 20 | port = 6543 21 | 22 | # Begin logging configuration 23 | 24 | [loggers] 25 | keys = root, sqlalchemy 26 | 27 | [handlers] 28 | keys = console 29 | 30 | [formatters] 31 | keys = generic 32 | 33 | [logger_root] 34 | level = INFO 35 | handlers = console 36 | 37 | [logger_sqlalchemy] 38 | level = INFO 39 | handlers = 40 | qualname = sqlalchemy.engine 41 | # "level = INFO" logs SQL queries. 42 | # "level = DEBUG" logs SQL queries and results. 43 | # "level = WARN" logs neither. (Recommended for production systems.) 44 | 45 | [handler_console] 46 | class = StreamHandler 47 | args = (sys.stderr,) 48 | level = NOTSET 49 | formatter = generic 50 | 51 | [formatter_generic] 52 | format = %(asctime)s %(levelname)-5.5s [%(name)s][%(threadName)s] %(message)s 53 | 54 | # End logging configuration 55 | -------------------------------------------------------------------------------- /pyramidapp/setup.cfg: -------------------------------------------------------------------------------- 1 | [nosetests] 2 | match=^test 3 | nocapture=1 4 | cover-package=pyramid_formalchemy 5 | with-coverage=1 6 | cover-erase=1 7 | verbosity=3 8 | 9 | [compile_catalog] 10 | directory = pyramidapp/locale 11 | domain = pyramidapp 12 | statistics = true 13 | 14 | [extract_messages] 15 | add_comments = TRANSLATORS: 16 | output_file = pyramidapp/locale/pyramidapp.pot 17 | width = 80 18 | 19 | [init_catalog] 20 | domain = pyramidapp 21 | input_file = pyramidapp/locale/pyramidapp.pot 22 | output_dir = pyramidapp/locale 23 | 24 | [update_catalog] 25 | domain = pyramidapp 26 | input_file = pyramidapp/locale/pyramidapp.pot 27 | output_dir = pyramidapp/locale 28 | previous = true 29 | -------------------------------------------------------------------------------- /pyramidapp/setup.py: -------------------------------------------------------------------------------- 1 | import os 2 | import sys 3 | 4 | from setuptools import setup, find_packages 5 | 6 | here = os.path.abspath(os.path.dirname(__file__)) 7 | README = open(os.path.join(here, 'README.txt')).read() 8 | CHANGES = open(os.path.join(here, 'CHANGES.txt')).read() 9 | 10 | requires = [ 11 | 'pyramid', 12 | 'SQLAlchemy', 13 | 'transaction', 14 | 'repoze.tm2', 15 | 'zope.sqlalchemy', 16 | 'WebError', 17 | ] 18 | 19 | if sys.version_info[:3] < (2,5,0): 20 | requires.append('pysqlite') 21 | 22 | setup(name='pyramidapp', 23 | version='0.0', 24 | description='pyramidapp', 25 | long_description=README + '\n\n' + CHANGES, 26 | classifiers=[ 27 | "Programming Language :: Python", 28 | "Framework :: Pylons", 29 | "Topic :: Internet :: WWW/HTTP", 30 | "Topic :: Internet :: WWW/HTTP :: WSGI :: Application", 31 | ], 32 | author='', 33 | author_email='', 34 | url='', 35 | keywords='web wsgi bfg pylons pyramid', 36 | packages=find_packages(), 37 | include_package_data=True, 38 | zip_safe=False, 39 | test_suite='pyramidapp', 40 | install_requires = requires, 41 | entry_points = """\ 42 | [paste.app_factory] 43 | main = pyramidapp:main 44 | jquery = pyramidapp.jquery:main 45 | security = pyramidapp.security:main 46 | """, 47 | paster_plugins=['pyramid'], 48 | ) 49 | 50 | -------------------------------------------------------------------------------- /pyramidapp/test.ini: -------------------------------------------------------------------------------- 1 | [app:pyramidapp] 2 | use = egg:pyramidapp 3 | reload_templates = true 4 | debug_authorization = false 5 | debug_notfound = false 6 | debug_routematch = false 7 | debug_templates = true 8 | default_locale_name = en 9 | sqlalchemy.url = %(db)s 10 | 11 | [pipeline:main] 12 | pipeline = 13 | egg:WebError#evalerror 14 | egg:repoze.tm2#tm 15 | pyramidapp 16 | 17 | [server:main] 18 | use = egg:Paste#http 19 | host = 0.0.0.0 20 | port = 6543 21 | 22 | # Begin logging configuration 23 | 24 | [loggers] 25 | keys = root, sqlalchemy 26 | 27 | [handlers] 28 | keys = console 29 | 30 | [formatters] 31 | keys = generic 32 | 33 | [logger_root] 34 | level = INFO 35 | handlers = console 36 | 37 | [logger_sqlalchemy] 38 | level = INFO 39 | handlers = 40 | qualname = sqlalchemy.engine 41 | # "level = INFO" logs SQL queries. 42 | # "level = DEBUG" logs SQL queries and results. 43 | # "level = WARN" logs neither. (Recommended for production systems.) 44 | 45 | [handler_console] 46 | class = StreamHandler 47 | args = (sys.stderr,) 48 | level = NOTSET 49 | formatter = generic 50 | 51 | [formatter_generic] 52 | format = %(asctime)s %(levelname)-5.5s [%(name)s][%(threadName)s] %(message)s 53 | 54 | # End logging configuration 55 | -------------------------------------------------------------------------------- /setup.cfg: -------------------------------------------------------------------------------- 1 | [nosetests] 2 | match = ^test 3 | nocapture = 1 4 | cover-package = pyramid_formalchemy 5 | with-coverage = 1 6 | with-doctest=true 7 | cover-erase = 1 8 | 9 | [compile_catalog] 10 | directory = pyramid_formalchemy/locale 11 | domain = pyramid_formalchemy 12 | statistics = true 13 | 14 | [extract_messages] 15 | add_comments = TRANSLATORS: 16 | output_file = pyramid_formalchemy/locale/pyramid_formalchemy.pot 17 | width = 80 18 | 19 | [init_catalog] 20 | domain = pyramid_formalchemy 21 | input_file = pyramid_formalchemy/locale/pyramid_formalchemy.pot 22 | output_dir = pyramid_formalchemy/locale 23 | 24 | [update_catalog] 25 | domain = pyramid_formalchemy 26 | input_file = pyramid_formalchemy/locale/pyramid_formalchemy.pot 27 | output_dir = pyramid_formalchemy/locale 28 | previous = true 29 | 30 | [aliases] 31 | release = sdist --formats=zip,gztar register upload 32 | -------------------------------------------------------------------------------- /setup.py: -------------------------------------------------------------------------------- 1 | import os 2 | 3 | from setuptools import setup, find_packages 4 | 5 | here = os.path.abspath(os.path.dirname(__file__)) 6 | README = open(os.path.join(here, 'README.txt')).read() 7 | CHANGES = open(os.path.join(here, 'CHANGES.txt')).read() 8 | 9 | requires = ['pyramid>=1.1', 'WebError', 'FormAlchemy>=1.3.8', 'Babel', 10 | 'zope.component'] 11 | 12 | version = '0.4.4dev' 13 | 14 | setup(name='pyramid_formalchemy', 15 | version=version, 16 | description='FormAlchemy plugins and helpers for Pyramid', 17 | long_description=README + '\n\nCHANGES\n=======\n\n' + CHANGES, 18 | classifiers=[ 19 | "Programming Language :: Python", 20 | "Framework :: Pylons", 21 | "Topic :: Internet :: WWW/HTTP", 22 | "Topic :: Internet :: WWW/HTTP :: WSGI :: Application", 23 | ], 24 | author='Gael Pasgrimaud', 25 | author_email='gael@gawel.org', 26 | url='http://docs.formalchemy.org/pyramid_formalchemy/', 27 | keywords='web pyramid pylons formalchemy', 28 | packages=find_packages(exclude=['pyramidapp']), 29 | message_extractors={'pyramid_formalchemy': [ 30 | ('*.py', 'lingua_python', None), 31 | ('templates/**.pt', 'lingua_xml', None), 32 | ]}, 33 | include_package_data=True, 34 | zip_safe=False, 35 | install_requires=requires, 36 | entry_points=""" 37 | [paste.paster_create_template] 38 | pyramid_fa = pyramid_formalchemy.paster:PyramidFormAlchemyTemplate 39 | [pyramid.scaffold] 40 | pyramid_fa = pyramid_formalchemy.paster:PyramidFormAlchemyTemplate 41 | """ 42 | ) 43 | --------------------------------------------------------------------------------