When you are starting, most people define their routes in their __init__ main() 
function, and their views in a views.py module which they read with 
config.scan(‘.views’). You can go a LONG way with just this. Feel free to stop 
reading at this point. :)

Later, people start organizing their code base by component: a todo directory, 
a user directory, etc. Each of those then have a views.py module in them. 
However, they still leave the route definition in the top-level __init__.py, to 
control ordering.

After that, though, there is a further level of Pyramid zen:

- Have a todo/__init__.py with an includeme function, which is the single place 
for wiring up everything in the todo subpackage

- The includeme function does the view registration

- It *also* does route definition

- The top-level package then pulls in todo etc. using config.include with a 
route prefix to avoid ordering and collision problems:

  
http://docs.pylonsproject.org/projects/pyramid/en/latest/narr/urldispatch.html#using-a-route-prefix-to-compose-applications
 
<http://docs.pylonsproject.org/projects/pyramid/en/latest/narr/urldispatch.html#using-a-route-prefix-to-compose-applications>

—Paul

> On Nov 11, 2015, at 4:46 AM, kk <[email protected]> wrote:
> 
> yes and I also forgot to ask, how will it affect my roots?
> Happy hacking.
> Krishnakant.
> 
> 
> On Wednesday 11 November 2015 02:56 PM, Krishnakant Mane wrote:
>> 
>> 
>> On Monday, November 9, 2015 at 11:24:19 PM UTC+5:30, Jonathan Vanasco wrote:
>> You can have views in multiple files, and even different packages.  
>> 
>> `views.py` is just a "scaffold" or reference implementation.
>> 
>> IIRC, Pyramid will automatically scan either `views.py` or a  `views/` 
>> package directory and subdirectories by default.  (ie, everything with an 
>> `__init__.py`) 
>> 
>> If you want to scan other packages/directories, you can even use dotted 
>> notation to explicitly scan them as well:
>> 
>>     config.scan("myapp.views_a")
>> So should I do config.scann for the views package?
>> Or is it that Pyramid will automatically see my package name?
>> I am still confused how Pyramid will automatically know which files contain 
>> my view code? 
>> -- 
>> You received this message because you are subscribed to a topic in the 
>> Google Groups "pylons-discuss" group.
>> To unsubscribe from this topic, visit 
>> https://groups.google.com/d/topic/pylons-discuss/wL2P3BBdI6Y/unsubscribe 
>> <https://groups.google.com/d/topic/pylons-discuss/wL2P3BBdI6Y/unsubscribe>.
>> To unsubscribe from this group and all its topics, send an email to 
>> [email protected] 
>> <mailto:[email protected]>.
>> To post to this group, send email to [email protected] 
>> <mailto:[email protected]>.
>> Visit this group at http://groups.google.com/group/pylons-discuss 
>> <http://groups.google.com/group/pylons-discuss>.
>> For more options, visit https://groups.google.com/d/optout 
>> <https://groups.google.com/d/optout>.
> 
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "pylons-discuss" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to [email protected] 
> <mailto:[email protected]>.
> To post to this group, send email to [email protected] 
> <mailto:[email protected]>.
> Visit this group at http://groups.google.com/group/pylons-discuss 
> <http://groups.google.com/group/pylons-discuss>.
> For more options, visit https://groups.google.com/d/optout 
> <https://groups.google.com/d/optout>.

-- 
You received this message because you are subscribed to the Google Groups 
"pylons-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/pylons-discuss.
For more options, visit https://groups.google.com/d/optout.

Reply via email to