Ok, I think I understand, so far.

My main question still stands, though - how can I import or
instantiate a model file, externally (say, for unit testing)? And do
you have any suggestions on how to unit test auth-protected controller
functions?

On Mon, Oct 5, 2009 at 10:59 PM, mdipierro <[email protected]> wrote:
>
> If a function needs to be used by multiple controllers in the same
> app, the easy solution is to put it into a model file.
>
> If a function needs to be used by multiple controllers in different
> applications than it needs to be defined in a module, imported, passed
> the required global variables and called by the controllers.
>
> Although code reuse is good and important it breaks the principle that
> each web2py applications should be stand alone (if two apps depend on
> each other, they they should be the same app).
>
> One repetition that you cannot avoid is listing in controllers the
> functions that you want to expose. This is unavoidable because by
> forcing you to code this we try prevent you from having two
> controllers expose the same functionality and we prevent hidden
> controller actions (expose functions by mistake).
>
>
> Massimo
>
> On Oct 5, 9:34 pm, Dmitri Zagidulin <[email protected]> wrote:
>> Actually, my main question is simply - how does one use/instantiate
>> Model code from external files? (Like, if I want to do outsource some
>> business logic to a module, so that several controllers can reuse it?)
> >
>

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"web2py-users" 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/web2py?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to