Re: authauth middleware details
Hello, Tomasz. On Thu, Dec 11, 2008 at 9:19 AM, Tomasz Narloch toma...@wp.pl wrote: 2) Where can I put @authenticate_form? I don't know such decorator. Haven't you confused it with @authorize? from pylons.decorators.secure import authenticate_form In login I create: {h.secure_form('/admin/process', method='post')} {h.text('username')} {h.password('password')} {h.end_form()} secure form - create: form .. input type=hidden name=hash_name_or_id value=some_hash / authenticate_form is decorator and if hash_name_or_id don't exist in form or is not correct then response html return error (403 or similar I don't remember) More detail on: http://en.wikipedia.org/wiki/Cross-site_request_forgery I have looked into this decorator. Several notes: 1. You are doing everything correct. You have created secure_form and must add decorator to 'process' action. I think it must look something like that: class AdminController(): @authenticate_form() def process(self, id): 2. authenticate_form has nothing to do with user authentication/authorization. You can use secure forms even with anonymous users if you want to. 3. I will do some improvements in my authentication middlewares to make them safer against CSRF. 4. If user authentication is CSRF-safe when usage of secure_form is unnecessary most probably. Unless you are really paranoid :-) I see necessity for secure_form only with anonymous users. -- Dalius http://blog.sandbox.lt --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups pylons-discuss group. To post to this group, send email to pylons-discuss@googlegroups.com To unsubscribe from this group, send email to pylons-discuss+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/pylons-discuss?hl=en -~--~~~~--~~--~--~---
Re: buildout vs virtualenv for pylons and/or other wsgi apps?
Previously Mike Orr wrote: On Sun, Dec 14, 2008 at 8:38 PM, Iain Duncan iaindun...@telus.net wrote: Hi folks, I totally do not want to start a flame war here, but was wondering if people could give me their reasons for preferring buildout or virtualenv for automated builds of pylons apps or other wsgi apps. Virtualenv is more popular because it follows traditional Python usage for the most part. You install packages interactively and can change your mind at any time. Buildout's configuration recipes are hard for many people to memorize, and it's more suited to situations where you know ahead of time exactly which libraries you'll need You can change the configuration and rebuild the environment from scratch, but it's not as easy as installing an experimental package, trying it out, and then uninstalling it if you don't like it.So with virtualenv you can use the same tools for development as you use for deployment, whereas buildout is more of a deployment-only thing. I do not fully agree with that: I use buildout for development all the time. One very very important thing buildout adds is repeatability. I can take my buildout and deploy it it any random other machine and be sure that I will have the exact same environment afterwards, down to exact package versions if needed. Adding more librares with buildout is just as simple as with virtualend, the pattern is just a bit different: instead of running easy_install you add declare the new dependency in setup.py and re-run buildout. This has the advantage of guaranteeing that your dependencies are declared correctly: buildout will happily install everything you need and uninstall everything you do not need to keep the system as clean as possible. Wichert. -- Wichert Akkerman wich...@wiggy.netIt is simple to make things. http://www.wiggy.net/ It is hard to make things simple. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups pylons-discuss group. To post to this group, send email to pylons-discuss@googlegroups.com To unsubscribe from this group, send email to pylons-discuss+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/pylons-discuss?hl=en -~--~~~~--~~--~--~---
Re: serving up generated images
Hello Matt, Thanks for your response. The page I serve has a graph plus a link to a csv file of the graph data so I can't dynamically return the data as you suggest. The page looks like this. htmltitledemand/title/headbody a href=/tmp/demand.png title=/tmp/demand img id=/tmp/demand src=/tmp/demand.png width=300 height=200 / /a/br a href=/tmp/demand__2008-10-29_2008-10-30.csvcsv/a/br /body/html Using tempfile.NamedTemporaryFile specifying this tmp directory could be an improvement if the deletion works ok. If I don't explictly close the file the docs say they will be closed and therefore deleted with gc is run. On Dec 10, 7:05 pm, Matthew Zwier mczw...@gmail.com wrote: Hello, Do you need the graphics files to remain around for a while, or are they dynamically generated for one request? If the former, the approach being discussed here makes a lot of sense. The files you create will be around until you delete them yourself. If the latter (read data from constantly-updated source, make graph, put on page -- that sort of thing), you may be better suited rendering the graphics into a temporary file (as created with tempfile.NamedTemporaryFile or whatever) and streaming it to the client yourself. # at the top of the controller file import tempfile class ChunkedFileIter(object): An iterator interface which reads chunks of a given size from a file until the file ends. def __init__(self, fileobj, blocksize = 8192): Initialize this object. :Parameters: fileobj : object supporting ``read(blocksize)`` File object from which to read blocksize : integer Number of bytes to read in each iteration self.fileobj = fileobj self.blocksize = blocksize def __iter__(self): return self def next(self): Read ``self.blocksize`` bytes from ``self.fileobj``. Raises ``StopIteration`` when the file ends. dat = self.fileobj.read(self.blocksize) if not dat: raise StopIteration return dat # in your action: tf = tempfile.NamedTemporaryFile(suffix='.png') # Write graphic into the file named by tf.name makeGraphic(tf.name) # tf.flush() # -- may be necessary if you write the file yourself, as opposed to an external program tf.seek(0) response.content_type='image/png' response.app_iter = ChunkedFileIter(tf) Using the NamedTemporaryFile ensures that the file is deleted after the request ends. You can then instruct the browser to cache its copy of the file (using etag_cache()) so you don't regenerate it unless the source data has changed or the client requests a new copy explicitly. That totally won't help if you need those PNGs laying around for future use...but as it took about five minutes of cut-and-paste...if it does help...great! Cheers, Matt Z. On Mon, Dec 8, 2008 at 5:30 AM, erowan rowan.shul...@wanadoo.fr wrote: Hello, I have a web app that dynamically generates images (png files). The main html response page has links to these files i.e. a href=/tmp/demand.png title=/tmp/demand img id=/tmp/demand src=/tmp/demand.png width=300 height=200 / I created the tmp dir under public and while running pylons in development this worked ok. Basically these filepaths resolved to the same location. 1. os.path.join(config['app_conf']['public_dir'], 'tmp', filename) 2. graph_file_name = h.url_for('/tmp/' + str(graph_file_name)) However, after packaging, install deploying the app with the same config file dev.ini python setup.py bdist_egg easy_install bmra_web-0.1.0dev-py2.5.egg cd some_deployment_dir paster serve dev.ini The dirs are not the same. 1 is but 2 resolves under the ~site- packages/bmra_web-0.1.0dev-py2.5.egg installation dir. I am not sure how to handle this? Should I be using another StaticURLParser instance for this tmp directory combined with Casade and maybe name it _tmp (does this bypass the routes dispatching?). I am a bit confused as to how to handle this. Thanks. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups pylons-discuss group. To post to this group, send email to pylons-discuss@googlegroups.com To unsubscribe from this group, send email to pylons-discuss+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/pylons-discuss?hl=en -~--~~~~--~~--~--~---
Re: serving up generated images
Hi, Using tempfile.NamedTemporaryFile specifying this tmp directory could be an improvement if the deletion works ok. If I don't explictly close the file the docs say they will be closed and therefore deleted with gc is run. Hmm...because gc can be run at any time, there's no guarantee the temp files will still be around by the time the browser gets around to retrieving them. It may work, but it sounds a bit fragile. Your idea about StaticURLParser and Cascade sounds elegant, and it should bypass routes dispatching unless you insert a route mapping which matches /tmp or /_tmp or whatever you call it. MZ --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups pylons-discuss group. To post to this group, send email to pylons-discuss@googlegroups.com To unsubscribe from this group, send email to pylons-discuss+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/pylons-discuss?hl=en -~--~~~~--~~--~--~---
small problem using pudge
Hi, when I try to generate the documentation for my application using pudge i get the following error File C:\Python25\lib\pydoc.py, line 305, in safeimport raise ErrorDuringImport(path, sys.exc_info()) pydoc.ErrorDuringImport: problem in ajax.tests - type 'exceptions.KeyError': '__file__' Error location in template file 'C:\\Python25\\lib\\site-packages\ \pudge-0.1.3-py2.5.egg\\pudge\\te mplate\\base\\package-index.html' between line 19, column 26 and line 22: ... /h2 ... ${module_index_table(browser.modules(recursive=1), qualified_names=1)} It refers to generated pylons code form \tests\__init__ # Invoke websetup with the current config file SetupCommand('setup-app').run([config[__file__]]) Any suggestions? --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups pylons-discuss group. To post to this group, send email to pylons-discuss@googlegroups.com To unsubscribe from this group, send email to pylons-discuss+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/pylons-discuss?hl=en -~--~~~~--~~--~--~---
Strange beaker 1.1 error
We are unfortunately still on Python 2.4, but we have brought hashlib in (from http://pypi.python.org/pypi/hashlib ) because we needed it elsewhere in our project. We are seeing some strange exceptions when using paste.httpexceptions - I'm theorizing that beaker's hashlib / sha1 / md5 usage is confused because we're at python 2.4 + hashlib, or something. Anybody have ideas here? maybe the hashlib from pypi is not QUITE compatible with the python 2.5 hashlib? is this a Beaker bug? (sorry stack is slightly mangled, but hopefully readable) AttributeError: 'builtin_function_or_method' object has no attribute 'new'hex:~/ly/build/_work/client-trunk_2008.12.15-18.44.58/_install%... %g'/app08-hour File '.../lib/python2.4/site-packages/Paste-1.7.2-py2.4.egg/paste/ httpexceptions.py', line 249 in response headers, content = self.prepare_content(environ) File '.../lib/python2.4/site-packages/Paste-1.7.2-py2.4.egg/paste/ httpexceptions.py', line 233 in prepare_content content = self.html(environ) File '.../lib/python2.4/site-packages/Paste-1.7.2-py2.4.egg/paste/ httpexceptions.py', line 218 in html body = self.make_body(environ, self.template, html_quote, no_quote) File '.../lib/python2.4/site-packages/Paste-1.7.2-py2.4.egg/paste/ httpexceptions.py', line 205 in make_body args[k] = escfunc(v) File '.../lib/python2.4/site-packages/Paste-1.7.2-py2.4.egg/paste/util/ quoting.py', line 36 in html_quote return cgi.escape(unicode(v).encode(encoding), 1) File '.../lib/python2.4/site-packages/Beaker-1.1.2-py2.4.egg/beaker/ session.py', line 481 in __repr__ return self._session().__repr__() File '.../lib/python2.4/site-packages/Beaker-1.1.2-py2.4.egg/beaker/ session.py', line 458 in _session self.__dict__['_sess'] = Session(req, use_cookies=True, File '.../lib/python2.4/site-packages/Beaker-1.1.2-py2.4.egg/beaker/ session.py', line 86 in __init__ self.cookie = SignedCookie(secret, input=cookieheader) File '.../lib/python2.4/site-packages/Beaker-1.1.2-py2.4.egg/beaker/ session.py', line 36 in __init__ Cookie.BaseCookie.__init__(self, input) File '/usr/lib64/python2.4/Cookie.py', line 568 in __init__ if input: self.load(input) File '/usr/lib64/python2.4/Cookie.py', line 621 in load self.__ParseString(rawdata) File '/usr/lib64/python2.4/Cookie.py', line 651 in __ParseString rval, cval = self.value_decode(V) File '.../lib/python2.4/site-packages/Beaker-1.1.2-py2.4.egg/beaker/ session.py', line 40 in value_decode sig = hmac.new(self.secret, val[40:], sha1).hexdigest() File '/usr/lib64/python2.4/hmac.py', line 107 in new return HMAC(key, msg, digestmod) File '/usr/lib64/python2.4/hmac.py', line 42 in __init__ self.outer = digestmod.new() AttributeError: 'builtin_function_or_method' object has no attribute 'new' --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups pylons-discuss group. To post to this group, send email to pylons-discuss@googlegroups.com To unsubscribe from this group, send email to pylons-discuss+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/pylons-discuss?hl=en -~--~~~~--~~--~--~---
Flickr tutorial under 0.9.7?
I'm going through the tutorials under 0.9.7. The Flickr tutorial says config/middleware.py should have javascripts_app = StaticJavascripts() ... app = Cascade([static_app, javascripts_app, app]) and a /javascripts/effects.js file. Neither are there. I read the What's new in Pylons 0.9.7? at http://wiki.pylonshq.com/pages/viewpage.action?pageId=11174779 . I see there are changes in the javascript middleware, but it's not clear how to rework/get through this tutorial. What changed wrt to the Flickr tutorial and how does one get the tutorial to work? --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups pylons-discuss group. To post to this group, send email to pylons-discuss@googlegroups.com To unsubscribe from this group, send email to pylons-discuss+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/pylons-discuss?hl=en -~--~~~~--~~--~--~---
Re: Flickr tutorial under 0.9.7?
I generally add my javascript files by hand to my base.mako template. Effects.js is from scriptaculous, which is a prototype (.js) effects framework. If you add these manually to your public folder, and add a script tag to the pages that use them, you can forgo the need to use javascripts middleware entirely. I also strongly suggest using Google's AJAX API http://code.google.com/apis/ajaxlibs/documentation/index.html to serve up prototype and scriptaculous since it is already on their CDN, and is already cached by many people's browsers. Tom Longson (nym) http://truefalsemaybe.com/ On Mon, Dec 15, 2008 at 1:07 PM, Rod Morison r...@morison.biz wrote: I'm going through the tutorials under 0.9.7. The Flickr tutorial says config/middleware.py should have javascripts_app = StaticJavascripts() ... app = Cascade([static_app, javascripts_app, app]) and a /javascripts/effects.js file. Neither are there. I read the What's new in Pylons 0.9.7? at http://wiki.pylonshq.com/pages/viewpage.action?pageId=11174779 . I see there are changes in the javascript middleware, but it's not clear how to rework/get through this tutorial. What changed wrt to the Flickr tutorial and how does one get the tutorial to work? --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups pylons-discuss group. To post to this group, send email to pylons-discuss@googlegroups.com To unsubscribe from this group, send email to pylons-discuss+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/pylons-discuss?hl=en -~--~~~~--~~--~--~---
Re: Flickr tutorial under 0.9.7?
Tom, thanks for google CDN tip. It looks like in 10.1 on http://code.google.com/apis/ajaxlibs/terms.html there are no restrictions on use for commercial applications. Is that your understanding? Rod Tom Longson (nym) wrote: I generally add my javascript files by hand to my base.mako template. Effects.js is from scriptaculous, which is a prototype (.js) effects framework. If you add these manually to your public folder, and add a script tag to the pages that use them, you can forgo the need to use javascripts middleware entirely. I also strongly suggest using Google's AJAX API http://code.google.com/apis/ajaxlibs/documentation/index.html to serve up prototype and scriptaculous since it is already on their CDN, and is already cached by many people's browsers. Tom Longson (nym) http://truefalsemaybe.com/ On Mon, Dec 15, 2008 at 1:07 PM, Rod Morison r...@morison.biz mailto:r...@morison.biz wrote: I'm going through the tutorials under 0.9.7. http://0.9.7. The Flickr tutorial says config/middleware.py should have javascripts_app = StaticJavascripts() ... app = Cascade([static_app, javascripts_app, app]) and a /javascripts/effects.js file. Neither are there. I read the What's new in Pylons 0.9.7? at http://wiki.pylonshq.com/pages/viewpage.action?pageId=11174779 . I see there are changes in the javascript middleware, but it's not clear how to rework/get through this tutorial. What changed wrt to the Flickr tutorial and how does one get the tutorial to work? --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups pylons-discuss group. To post to this group, send email to pylons-discuss@googlegroups.com To unsubscribe from this group, send email to pylons-discuss+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/pylons-discuss?hl=en -~--~~~~--~~--~--~---
Re: Flickr tutorial under 0.9.7?
On Mon, Dec 15, 2008 at 1:07 PM, Rod Morison r...@morison.biz wrote: I'm going through the tutorials under 0.9.7. The Flickr tutorial says config/middleware.py should have javascripts_app = StaticJavascripts() ... app = Cascade([static_app, javascripts_app, app]) and a /javascripts/effects.js file. Neither are there. I read the What's new in Pylons 0.9.7? at http://wiki.pylonshq.com/pages/viewpage.action?pageId=11174779 . I see there are changes in the javascript middleware, but it's not clear how to rework/get through this tutorial. What changed wrt to the Flickr tutorial and how does one get the tutorial to work? The Flickr tutorial is out of date. It will probably have to be dropped from the docs unless somebody has time to update it. You can add the Javascripts app to middleware.py and it will probably work, but that part of WebHelpers is deprecated and will be gone by Pylons 0.9.8. The Javascrips app serves a virtual /javascripts/effects.js file whose source is somewhere in WebHelpers. In a real 0.9.7 application you'd use a third-party Javascript library like JQuery or YUI, or write the Javascript yourself. You can also get the current versions of Prototype and Scriptaculous by googling them. -- Mike Orr sluggos...@gmail.com --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups pylons-discuss group. To post to this group, send email to pylons-discuss@googlegroups.com To unsubscribe from this group, send email to pylons-discuss+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/pylons-discuss?hl=en -~--~~~~--~~--~--~---
Re: Flickr tutorial under 0.9.7?
Yes Rod, that's my understanding. This comment from a Google employee seems to support that opinion: http://code.google.com/p/google-ajax-apis/issues/detail?id=50#c44 They purposely did not include the ext javascript library because of concern for commercial users. Tom Longson (nym) http://truefalsemaybe.com/ On Mon, Dec 15, 2008 at 1:47 PM, Rod Morison r...@morison.biz wrote: Tom, thanks for google CDN tip. It looks like in 10.1 on http://code.google.com/apis/ajaxlibs/terms.html there are no restrictions on use for commercial applications. Is that your understanding? Rod Tom Longson (nym) wrote: I generally add my javascript files by hand to my base.mako template. Effects.js is from scriptaculous, which is a prototype (.js) effects framework. If you add these manually to your public folder, and add a script tag to the pages that use them, you can forgo the need to use javascripts middleware entirely. I also strongly suggest using Google's AJAX API http://code.google.com/apis/ajaxlibs/documentation/index.html to serve up prototype and scriptaculous since it is already on their CDN, and is already cached by many people's browsers. Tom Longson (nym) http://truefalsemaybe.com/ On Mon, Dec 15, 2008 at 1:07 PM, Rod Morison r...@morison.biz mailto:r...@morison.biz wrote: I'm going through the tutorials under 0.9.7. http://0.9.7. The Flickr tutorial says config/middleware.py should have javascripts_app = StaticJavascripts() ... app = Cascade([static_app, javascripts_app, app]) and a /javascripts/effects.js file. Neither are there. I read the What's new in Pylons 0.9.7? at http://wiki.pylonshq.com/pages/viewpage.action?pageId=11174779 . I see there are changes in the javascript middleware, but it's not clear how to rework/get through this tutorial. What changed wrt to the Flickr tutorial and how does one get the tutorial to work? --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups pylons-discuss group. To post to this group, send email to pylons-discuss@googlegroups.com To unsubscribe from this group, send email to pylons-discuss+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/pylons-discuss?hl=en -~--~~~~--~~--~--~---
doc tools suggestions?
Hi folks, I'm working on a wsgi app that I hope to eventually make public. I'm not sure what to do about documentation, I plan on using Sphinx for hand written docs, but don't know whether I should also use a javadoc style tool like epydoc or doxygen, and if so, which one. If folks could tell me what seems to be the preferrence for pylons related projects that would be great. Thanks Iain --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups pylons-discuss group. To post to this group, send email to pylons-discuss@googlegroups.com To unsubscribe from this group, send email to pylons-discuss+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/pylons-discuss?hl=en -~--~~~~--~~--~--~---
Re: small problem using pudge
On Dec 15, 3:09 am, przemek.ch przemek...@gmail.com wrote: Hi, when I try to generate the documentation for my application using pudge i get the following error File C:\Python25\lib\pydoc.py, line 305, in safeimport raise ErrorDuringImport(path, sys.exc_info()) pydoc.ErrorDuringImport: problem in ajax.tests - type 'exceptions.KeyError': '__file__' Error location in template file 'C:\\Python25\\lib\\site-packages\ \pudge-0.1.3-py2.5.egg\\pudge\\te mplate\\base\\package-index.html' between line 19, column 26 and line 22: ... /h2 ... ${module_index_table(browser.modules(recursive=1), qualified_names=1)} It refers to generated pylons code form \tests\__init__ # Invoke websetup with the current config file SetupCommand('setup-app').run([config[__file__]]) Any suggestions? Use Sphinx instead? http://sphinx.pocoo.org/ I never had any luck with Pudge. Sphinx seems to be the emerging Python doc standard. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups pylons-discuss group. To post to this group, send email to pylons-discuss@googlegroups.com To unsubscribe from this group, send email to pylons-discuss+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/pylons-discuss?hl=en -~--~~~~--~~--~--~---
Re: mycompany.myapp instead of myapp as base package ?
On Dec 12, 7:29 am, Guillaume guillaume.tagl...@gmail.com wrote: Hi, I'm currently developing a set of applications, and I have one problem. They should all reside in the same package. The package structure should look like something like this: mycompany/ +- models | +-base.py | +-metadata.py | +-app1.py | \-app2.py +- app1/ | +- controllers/... | +- helpers.py | +- routing.py | \- wsgiapp.py +- app2/ | +- controllers/... | +- helpers.py | +- routing.py | \- wsgiapp.py \- ... Is something like this achievable with pylons ? Or am I restricted to have one b ase package per application ? Here's the setup/layout I'm using to keep my Core separate from my apps, where the Core contains the model, services, utilities, and anything else that's reusable and/or not specific to a particular application. Note that I use `pkg_resources`, so the `easy_install`/ `setuptools` haters may not like this. Core/ mycompany/ core/ model/ __init__.py ...entity definitions... services/ __init__.py ...service modules... __init__.py __init__.py setup.py SomeApp/ ini/ development.ini mycompany/ someapp/ __init__.py ...other packages and files that import mycompany.core-- e.g., a Pylons app... __init__.py setup.py At the top level, Core and SomeApp are project directories. They contain project metadata, like the setup file, maybe docs, or utility scripts that don't need to be installed with the package. mycompany/__init__.py, in both projects, contains a single line: __import__('pkg_resources').declare_namespace(__name__) When these projects are `easy_install`ed, they end up in separate directories, but there's some magic that makes both of them available from the same namespace, `mycompany`. Of course, the OP's directory layout accomplishes (more or less) the same thing as far as installation is concerned. What I like about this structure is the complete separation of the Core and the various projects that depend on it. In the uber-project I'm working on, I have a (RESTful) Web Service with no GUI built from a stripped down Pylons app and a separate user facing Web App built on a more complete Pylons app. Both depend on the Core. This structure is very useful in helping to keep things straight and enforces a separation of concerns. I'm using the Web Service app as a sort of app server--a remote interface to the Core model and services. The Web App focuses on the user experience, and whenever I start building some core functionality there, I refactor it into the Core package and expose it through the WS. I haven't been using `paster shell` with this project, but I just ran it in my SomeApp directory and it seems to work as expected. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups pylons-discuss group. To post to this group, send email to pylons-discuss@googlegroups.com To unsubscribe from this group, send email to pylons-discuss+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/pylons-discuss?hl=en -~--~~~~--~~--~--~---
Re: mycompany.myapp instead of myapp as base package ?
On Mon, Dec 15, 2008 at 6:07 PM, Wyatt Baldwin wyatt.lee.bald...@gmail.com wrote: On Dec 12, 7:29 am, Guillaume guillaume.tagl...@gmail.com wrote: Hi, I'm currently developing a set of applications, and I have one problem. They should all reside in the same package. The package structure should look like something like this: mycompany/ +- models | +-base.py | +-metadata.py | +-app1.py | \-app2.py +- app1/ | +- controllers/... | +- helpers.py | +- routing.py | \- wsgiapp.py +- app2/ | +- controllers/... | +- helpers.py | +- routing.py | \- wsgiapp.py \- ... Is something like this achievable with pylons ? Or am I restricted to have one b ase package per application ? Here's the setup/layout I'm using to keep my Core separate from my apps, where the Core contains the model, services, utilities, and anything else that's reusable and/or not specific to a particular application. Note that I use `pkg_resources`, so the `easy_install`/ `setuptools` haters may not like this. Core/ mycompany/ core/ model/ __init__.py ...entity definitions... services/ __init__.py ...service modules... __init__.py __init__.py setup.py SomeApp/ ini/ development.ini mycompany/ someapp/ __init__.py ...other packages and files that import mycompany.core-- e.g., a Pylons app... __init__.py setup.py At the top level, Core and SomeApp are project directories. They contain project metadata, like the setup file, maybe docs, or utility scripts that don't need to be installed with the package. mycompany/__init__.py, in both projects, contains a single line: __import__('pkg_resources').declare_namespace(__name__) When these projects are `easy_install`ed, they end up in separate directories, but there's some magic that makes both of them available from the same namespace, `mycompany`. Of course, the OP's directory layout accomplishes (more or less) the same thing as far as installation is concerned. What I like about this structure is the complete separation of the Core and the various projects that depend on it. In the uber-project I'm working on, I have a (RESTful) Web Service with no GUI built from a stripped down Pylons app and a separate user facing Web App built on a more complete Pylons app. Both depend on the Core. This structure is very useful in helping to keep things straight and enforces a separation of concerns. I'm using the Web Service app as a sort of app server--a remote interface to the Core model and services. The Web App focuses on the user experience, and whenever I start building some core functionality there, I refactor it into the Core package and expose it through the WS. I haven't been using `paster shell` with this project, but I just ran it in my SomeApp directory and it seems to work as expected. This is what's call a namespaced package, and yes I totally agree it's very handy all BIG projects out there use it there is even a tool to create it, BUT it breaks paster shell as it can't find the model due to the fact that development.ini isn't in the same package, I know the problem we just haven't had time to fix it as this is nice to have but not a priority. Here is a nice writeup on how to use the tool + another good explanation on why this is a good thing, http://www.percious.com/blog/archives/13 --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups pylons-discuss group. To post to this group, send email to pylons-discuss@googlegroups.com To unsubscribe from this group, send email to pylons-discuss+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/pylons-discuss?hl=en -~--~~~~--~~--~--~---
Re: doc tools suggestions?
On Dec 15, 3:06 pm, Iain Duncan iaindun...@telus.net wrote: Hi folks, I'm working on a wsgi app that I hope to eventually make public. I'm not sure what to do about documentation, I plan on using Sphinx for hand written docs, but don't know whether I should also use a javadoc style tool like epydoc or doxygen, and if so, which one. If folks could tell me what seems to be the preferrence for pylons related projects that would be great. I'm not sure, but I think Sphinx can extract documentation from source files. Or, that's what this `sphinx-quickstart` option implies to me: autodoc: automatically insert docstrings from modules (y/N) [n]: I haven't tried it, though, and I'm curious too about how other people document classes and methods (beyond PEP 8 recommendations). For a while, I was doing something like this (which I think I stole from Pylons and/or Paste): def method(self, arg, arg1): Do stuff and return things. More explanation if needed. Multiple lines and/or paragraphs. ``arg`` Blah blah. ``arg1`` ``arg1``` is super cool. pass Poking around in the Python 3.0 source, there doesn't seem to be a standard for docstrings, except maybe the use of reStructuredText. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups pylons-discuss group. To post to this group, send email to pylons-discuss@googlegroups.com To unsubscribe from this group, send email to pylons-discuss+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/pylons-discuss?hl=en -~--~~~~--~~--~--~---