On Wed, Nov 11, 2015 at 1:26 AM, Krishnakant Mane <[email protected]> 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?

It doesn't automatically know. There are two ways to register views:

1) Use 'config.add_view()' for every view.

2) Decorate the views with '@view_config' and then run 'config.scan()'
over the module or package. The scanning does the add_view's for you.
You can specify which package to scan, and it will scan all modules
and subpackages under it.

Some people prefer one way, and some the other. I used to use
'@view_config' but I'm currently using 'config.add_view()' because
it's less magical.

-- 
Mike Orr <[email protected]>

-- 
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