Ñò ¯›—Ic@s.dZddkZddkZddkZddkZddkZddklZl Z ddk l Z l Z ddk lZddklZddkZddkiZddd gZd „Zed „Zd „Zd „Zd„Zde fd„ƒYZde fd„ƒYZd e fd„ƒYZdS(sePaster Commands, for use with paster in your project .. highlight:: bash The following commands are made available via paster utilizing setuptools points discovery. These can be used from the command line when the directory is the Pylons project. Commands available: ``controller`` Create a Controller and accompanying functional test ``restcontroller`` Create a REST Controller and accompanying functional test ``shell`` Open an interactive shell with the Pylons app loaded Example usage:: ~/sample$ paster controller account Creating /Users/ben/sample/sample/controllers/account.py Creating /Users/ben/sample/sample/tests/functional/test_account.py ~/sample$ .. admonition:: How it Works :command:`paster` is a command line script (from the PasteScript package) that allows the creation of context sensitive commands. :command:`paster` looks in the current directory for a ``.egg-info`` directory, then loads the ``paster_plugins.txt`` file. Using setuptools entry points, :command:`paster` looks for functions registered with setuptools as :func:`paste.paster_command`. These are defined in the entry_points block in each packages :file:`setup.py` module. This same system is used when running :command:`paster create` to determine what templates are available when creating new projects. iÿÿÿÿN(tloadappt appconfig(tCommandt BadCommand(tFileOp(tpaste_script_template_renderertControllerCommandtRestControllerCommandt ShellCommandcCs-yt|ƒtSWntj otSXdS(sgAttempt to __import__ the specified package/module, returning True when succeeding, otherwise FalseN(t __import__tTruet ImportErrortFalse(tname((s3/usr/lib/python2.6/site-packages/pylons/commands.pyt can_import:s  cCset}yt|dƒWnFtj o&}dt|ƒjo t}qan|o‚qanX|S(s°Determine if the specified Pylons project (package) uses the Pylons Minimal Template. fail_fast causes ImportErrors encountered during detection to be raised. s .lib.basesNo module named lib.base(R R R tstrR (tpackaget fail_fasttminimal_templatetie((s3/usr/lib/python2.6/site-packages/pylons/commands.pytis_minimal_templateDs cCset|ƒo |dp|d}y"t|tƒtƒdgƒ}WntSXtt|ddƒƒS(skDetermine if the specified Pylons project (package) defines a render callable in their base module s .controllerss .lib.baset__doc__trenderN(RR tglobalstlocalsR tcallabletgetattrtNone(Rt base_moduletbase((s3/usr/lib/python2.6/site-packages/pylons/commands.pytdefines_renderYs "cCsU|ptdƒ‚n|djo-t|ƒo td||||fƒ‚ntS(sOValidate that the name for the controller isn't present on the path alreadys%Please give the name of a controller.tsetupso A module named '%s' is already present in your PYTHON_PATH. Choosing a conflicting name will likely cause import problems in your controller at some point. It's suggested that you choose an alternate name, and if you'd like that name to be accessible as '%s', add a route to your projects config/routing.py file similar to: map.connect('%s', controller='my_%s')(RRR (R ((s3/usr/lib/python2.6/site-packages/pylons/commands.pyt validate_namefscCsGtii|d|dƒ}tii|ƒotd|ƒ‚ndS(s4Check if given controller already exists in project.t controllerss.pysController %s already exists.N(tostpathtjointexistsR(t base_packageR tfilename((s3/usr/lib/python2.6/site-packages/pylons/commands.pytcheck_controller_existance|scBszeZdZeiƒdZdeZdZdZdZdZ e i de ƒZ e iddd d d d d ƒd„ZRS(s/Create a Controller and accompanying functional test The Controller command will create the standard controller template file and associated functional test to speed creation of controllers. Example usage:: yourproj% paster controller comments Creating yourproj/yourproj/controllers/comments.py Creating yourproj/yourproj/tests/functional/test_comments.py If you'd like to have controllers underneath a directory, just include the path as the controller name and the necessary directories will be created for you:: yourproj% paster controller admin/trackback Creating yourproj/controllers/admin Creating yourproj/yourproj/controllers/admin/trackback.py Creating yourproj/yourproj/tests/functional/test_admin_trackback.py is itpylonsitsimulates --no-testtactiont store_truetdesttno_testthelps*Don't create the test; just the controllerc Cstytdd!ƒ}y |i|idƒ\}}Wntdƒ‚nX|idtƒd}|iƒ|iƒjotd|ƒ‚n|idd ƒ}t|ƒt |ƒod |}n d |}t |ƒo|d 7}nt i i ||ƒ}ti|id ƒdƒ}|it iƒpt i|}n|it id ƒd}t||ƒ|iih|d6t i i ||ƒd6|d6|d6|d6ƒ|idddt i i d|ƒd|dtƒ|iip9|idddt i i ddƒdd|dtƒnWnQtj o} td| ƒ‚n.ttiƒdƒ} td| ƒ‚nXd S("s!Main command to create controllert source_dirR)t templatesisNo egg_info directory was foundR!sCYour controller name should not be the same as the package name %r.t-t_s)from %s.controllers import BaseControllers&from %s.lib.base import BaseControllers, rendert/iÿÿÿÿiR tfnamet tmpl_nameRtimportstatementttemplatescontroller.py_tmplR-R'ttemplate_rendererstest_controller.py_tmplttestst functionalttest_sAn error occurred. %ssAn unknown error occurred. %sN(spylonsR1(Rtparse_path_name_argstargsRtfind_dirR tlowertreplaceR RRR"R#R$tutiltclass_name_from_module_nametsplitt startswithtsepR(t template_varstupdatet copy_fileRtoptionsR.Rtsystexc_info( tselftfile_opR t directoryR&R7tfullnametcontroller_namettestnametetmsg((s3/usr/lib/python2.6/site-packages/pylons/commands.pytcommand©s`            (t__name__t __module__Rt splitlinestsummarytusagetmin_argstmax_argst group_nametdefault_verbosityRtstandard_parserR tparsert add_optionRU(((s3/usr/lib/python2.6/site-packages/pylons/commands.pyRƒs  cBszeZdZeiƒdZdeZdZdZdZdZ e i de ƒZ e iddd d d d d ƒd„ZRS(s Create a REST Controller and accompanying functional test The RestController command will create a REST-based Controller file for use with the :meth:`~routes.mapper.Mapper.resource` REST-based dispatching. This template includes the methods that :meth:`~routes.mapper.Mapper.resource` dispatches to in addition to doc strings for clarification on when the methods will be called. The first argument should be the singular form of the REST resource. The second argument is the plural form of the word. If its a nested controller, put the directory information in front as shown in the second example below. Example usage:: yourproj% paster restcontroller comment comments Creating yourproj/yourproj/controllers/comments.py Creating yourproj/yourproj/tests/functional/test_comments.py If you'd like to have controllers underneath a directory, just include the path as the controller name and the necessary directories will be created for you:: yourproj% paster restcontroller admin/tracback admin/trackbacks Creating yourproj/controllers/admin Creating yourproj/yourproj/controllers/admin/trackbacks.py Creating yourproj/yourproj/tests/functional/test_admin_trackbacks.py is iR)iR*s --no-testR+R,R-R.R/s*Don't create the test; just the controllercCssytdd0ƒ}y<|i|idƒ\}}|i|idƒ\}}Wntdƒ‚nX|idtƒd}|iƒ|iƒjotd|ƒ‚nx-|gD]"}|id d ƒ}t|ƒq±Wt |ƒod |}n d |}t |ƒo|d 7}nt ||ƒt i i||ƒ} ti|idƒdƒ} | it iƒpt i| } n| it id ƒd} d} |o |it i id ƒd } nd} | o1ddi||gƒ} | d||f7} nd||| f}|iih | d6|d6|d6| d6| d6|d6|iddd1d2fƒd6t i i||ƒd 6|d!6ƒd"}|d#7}||7}|id$d%d&t i id|ƒd'|d(tƒ|iip9|id$d)d&t i id*d+ƒd'd,| d(tƒn|GHWnQtj o}td-|ƒ‚n.ttiƒdƒ}td.|ƒ‚nXd/S(3s!Main command to create controllerR0R)R1iisNo egg_info directory was foundR!sCYour controller name should not be the same as the package name %r.R2R3s)from %s.controllers import BaseControllers&from %s.lib.base import BaseControllers, renderR4iÿÿÿÿts, controller='%s', s$path_prefix='/%s', name_prefix='%s_'smap.resource('%s', '%s'%s) t classnamet pluralnamet singularnameR t nameprefixRs s %s#%st ii tresource_commandR5R7sH To create the appropriate RESTful mapping, add a map statement to your s0config/routing.py file near the top like this: R8srestcontroller.py_tmplR-R'R9stest_restcontroller.py_tmplR:R;R<sAn error occurred. %ssAn unknown error occurred. %sN(spylonss templatess s (RR=R>RR?R R@RAR RRR(R"R#R$RBRCRDRERFRGRHRIRRJR.RRKRL(RMRNRetsingulardirectoryRdtpluraldirectoryR&R R7RPRQRRRft controller_cRURhRSRT((s3/usr/lib/python2.6/site-packages/pylons/commands.pyRUsŽ                  (RVRWRRXRYRZR[R\R]R^RR_R R`RaRU(((s3/usr/lib/python2.6/site-packages/pylons/commands.pyRæs  c BsœeZdZeiƒdZdeZdZdZdZe i de ƒZ e i dddd d d d d ƒe i dddd dddd dƒd„ZRS(soOpen an interactive shell with the Pylons app loaded The optional CONFIG_FILE argument specifies the config file to use for the interactive shell. CONFIG_FILE defaults to 'development.ini'. This allows you to test your mapper, models, and simulate web requests using ``paste.fixture``. Example:: $ paster shell my-development.ini is iR)R*s-ds--disable-ipythonR+R,R-tdisable_ipythonR/s$Don't use IPython if it is availables-qtcounttquiettdefaults6Do not load logging configuration from the config filecs¢d|_e|iƒdjoId}eii|ƒp,ed|iiƒeii |fƒ‚qun|id}d|}ei ƒ}e ddƒ}|i i p|i|ƒne|d|ƒ}|ie d |id |iƒƒeiiii|ƒeiid|ƒe|d|ƒ}eii|ƒ}|id ƒ}e|iƒ‰d „|_ ‡fd †|_!ei"i#i$ˆƒe%id} e&| e'ƒod+} | d} | d} n| d} | d} | d} | o"e)| ƒoei*| |d¾scstiiiˆƒS((RsRtRutrestoration_begin(RM(t request_id(s3/usr/lib/python2.6/site-packages/pylons/commands.pyRwÀsspylons.packages.helperss .controllerss.models .lib.helperss .lib.basetmodelths[from pylons import app_globals, c, config, g, request, response, session, tmpl_context, urls6from pylons.controllers.util import abort, redirect_tos(from pylons.i18n import _, ungettext, N_s$from pylons.templating import renderR3twsgiapptapps routes.maptmappers$ All objects from %s are available s Additional Objects: s %-10s - %s sRoutes mapper objects This project's WSGI App instances$paste.fixture wrapped around wsgiappiÿÿÿÿ(t IPShellEmbedtargvs tlocal_nst global_nsNtjavatJtPs%Pylons Interactive Shell %sython %s R(smappersRoutes mapper object(R|s This project's WSGI App instance(R}s$paste.fixture wrapped around wsgiapp(=tverbosetlenR>R"R#tisfileRR`t get_usageRFtgetcwdtdictRJRntlogging_file_configRRHt local_confRrRstdeploytconfigtCONFIGtpush_thread_configRKtinsertRtfixturetTestApptgettinttbodytpre_request_hooktpost_request_hookRtRuRxR)RR RRtmodulesR tdirRERRlR t IPython.ShellRt set_bannertIPtBANNERRvtcodetplatformtversiontInteractiveConsoletreadlinetinteract(RMt config_filet config_namethere_dirtlocstconfR|ttest_appt tresponsetpkg_namet model_modulethelpers_moduleRRt_[1]t_ShellCommand__namet base_publicR R~tbannerRtshellR t py_prefixt newbannerR¤((Rys3/usr/lib/python2.6/site-packages/pylons/commands.pyRU‘s¨               2       (RVRWRRXRYRZR[R\R]RR_R R`RaRU(((s3/usr/lib/python2.6/site-packages/pylons/commands.pyRos"   (RR"RKt paste.fixtureRstpaste.registrytpaste.deploy.configt paste.deployRRtpaste.script.commandRRtpaste.script.filemakerRttempitaRR)t pylons.utilRBt__all__RR RRR R(RRR(((s3/usr/lib/python2.6/site-packages/pylons/commands.pyt)s(         c‰