On Wed, Jan 27, 2010 at 2:29 PM, haronmedia <[email protected]> wrote: > > Hello! > > I've been developing in PHP ever since PHP 3. I've recently > "discovered" Python and Pylons (read: started playing with it more > seriously). I like the framework very much, and would like to switch > completely to Python and Pylons. My primary job is developing web > applications. > > However, having already some tools written in PHP, namely an inhouse > CMS used for our clients (we do managed hosting of webapps as well), > I'd like to port those to Python, namely Pylons, and opensource them > (yeah, I have the authority, I'm the CEO and lead dev). Unless of > course such components already exist? > > I'm talking about developing (porting) a set of (purely) RESTful > components for resource (content) management. For example, SmartPages > (nested hierarchy of pages not unlike Drupal's "book"), articles with > categories, product catalog, gallery, newsletter, etc... > > The idea is to have the components fully prepared as Python modules > (models, controllers and mako templates), and enable adding them to > the project using paster, for example: > > #paster component SmartPages > > which would unpack the component, place models, templates and > controllers in respective directories, add commented entries to the > url mapper, etc... depending on what the component needs. The > developers could then use them as is, or modify to suit their needs > (most likely), especially URIs and routes. > > The idea was to call the project Presto: Pylons RESTful Objects. :) > > I may be reinventing the wheel here, you guys will know if such things > already exist. I am also very new to Python so it might take a little > while before I get a grip and do a (rather big) paradigm shift from > PHP to Python.
The idea sounds great, but you'll have some difficulty making it modular. I'd suggest making a regular Pylons application, as flexible as possible, and distributing it on PyPI. Then people can try it out and borrow code. The Pylons developers are working on a project (Marco) which will make it easier to distribute bundles of models/controllers/templates, but it'll take another few months before it's ready to use. That'll give you time to gain some experience with Python and Pylons and porting your CMS code, which will come in useful later. You can make a flexible application by making heavy use of config variables defined in the INI file. That's a good place to put paths, titles, or other things the user would want to customize. You can even add your own sections and read them using Python's ConfigParser. Some people have experimented with themes/skins, by pointing to one template directory or another in environment.py. I'm not sure how well this has gone, but you can ask on the list if you're interested in this. To make "paster component", you'd have to write a plugin for paster. If you look at the source for "paster controller" (in Pylons), you'll see the basic idea. "paster controller" takes a module template, customizes it for the situation, and puts it in the appropriate place in the application. See pylons.commands.ControllerCommand . You'll have to create an entry point, which is a bit complex, but again see how "controller" is implemented in Pylons/setup.py and Pylons.egg-info/entry_points.txt. (The egg-info directory is created when you install a package.) You can make Pylons delegate to an external WSGI application (by making a pseudo-controller, among other ways), so theoretically you can nest a Pylons app inside another Pylons app, but in practice there are some difficulties with the middleware and site template. For instance middleware.py has a 'full_stack' flag that disables some middleware if it's false, but I'm not sure the default choice of middlewares is correct for a nested app. It depends on what the inner app needs its own copy of (its own route map) and what it can share (the session, maybe). You can make an autonomous nested app with its own routing, controllers, model, and templates, but trying to "plug" individual controllers and templates into a Pylons app is more difficult. And if the nested app's templates need to be decorated with the site template (common header/footer), we haven't quite figured that out yet. Regarding existing CMS software, the big granddaddy of Python CMS's is Plone. You can supposedly embed it as an external WSGI application in a Python app or vice-versa. But as for little CMS pieces for Pylons, there's not that much. A couple projects were started but I don't think they're going anywhere. The work so far is summarized on: http://wiki.pylonshq.com/display/pylonsprojects/Blog%2C+CMS%2C+and+Wiki+software Here's a summary of future changes expected in Pylons: http://wiki.pylonshq.com/display/pylonscommunity/Pylons+Roadmap+to+1.0 -- Mike Orr <[email protected]> -- You received this message because you are subscribed to the Google Groups "pylons-discuss" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/pylons-discuss?hl=en.
