Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
Scaffolding - Configuring - File/Folder Structure for larger-than-single-file apps
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  2 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
pylover2000  
View profile  
 More options Jun 15 2012, 12:13 pm
From: pylover2000 <snt....@gmail.com>
Date: Fri, 15 Jun 2012 09:13:40 -0700 (PDT)
Local: Fri, Jun 15 2012 12:13 pm
Subject: Scaffolding - Configuring - File/Folder Structure for larger-than-single-file apps

Hello everyone!

*Background:* Not new to coding, relatively new to Python. Experience with
C# and PHP frameworks for web-app development. New to Python frameworks. I
think Pyramid is the way to go.

*My question:* *- [did my research, could not find what I am looking for,
probably because of my not-so-great English]*
*
*
*+ *I would like to have a *central (routing) file* where all the routings
are defined. e.g. route / to ... route /{method}/{value} to ..... (....
being different view callable(s))
*+ AND *I would like to have each and every one of my view callables *NOT
to exist in a single .py* but to have *their own .py file* (to have better
file structure and readability)

How do I link the two?

*also:*
*+ *How can I create a class .py which is not intended to be used as view
callable but as an object *to be called by view callables*, again, *very
importantly*, *on its own .py file. *
*
*
I am willing to read any document regarding these but I would highly and
respectfully appreciate clear, simple answers sharing how to achieve these
3 goals.

Thank you very much.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Mike Orr  
View profile  
 More options Jun 16 2012, 3:07 pm
From: Mike Orr <sluggos...@gmail.com>
Date: Sat, 16 Jun 2012 12:07:04 -0700
Local: Sat, Jun 16 2012 3:07 pm
Subject: Re: Scaffolding - Configuring - File/Folder Structure for larger-than-single-file apps

Both of these are common in larger Pyramid applications, although usually
you would group the views by application section rather than than making
every view separate.

The first thing to note is that functions and classes are not related to
modules at all.  A .py file is a module. It can contain any number of
functions and classes.

For the routes, make a module, normally called 'routes.py' at the same
level as the top-level '__init__.py'. Put a 'def includeme(config):'
function in, it, containing all the config.add_route() calls. Then in the
main function, include it with 'config.include(".routes")' .

For the views, convert views.py to a package, meaning replace it with a
'views' directory with an empty '__init__.py' file, and put your view
modules in there. The view callables will still have the same structure and
imports as normal.

To connect the views to routes, use '@view_config' the normal way, with a
corresponding 'config.scan(".views")' call in the main function.

To use the same route with multiple views, using a match variable or some
other aspect of the request to determine which view to call, see the
'@view_config' optional arguments.

What you CAN"T do in Pyramid (unlike Pylons), is use a routing variable to
look up a view by name. Every view must be attached to a route at startup,
using the '@view_config' arguments as the link between them.

> *also:*
> *+ *How can I create a class .py which is not intended to be used as view
> callable but as an object *to be called by view callables*, again, *very
> importantly*, *on its own .py file. *

You can define any utility classes you want, and put them anywhere. If the
classes are more or less generic, and applicable to several views, you'd
normally create a 'lib' package and put your utility modules there.

I wrote some documentation which was intended for people with a Pylons
background, but it may be indirectly useful. See:

http://docs.pylonsproject.org/projects/pyramid_cookbook/en/latest/pyl...
Pyramid for Pylons Users

--
Mike Orr <sluggos...@gmail.com>


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »