Ok here's my best solution so far:
I keep the whole plugin contained according to the rules defined in the
documentation and, in order to have my my models visible to the global
namespace, I expose the plugin's model folder using this little line :
response.models_to_run.append('plugin_name')
On Wednesday, June 11, 2014 5:43:29 PM UTC+2, Louis Amon wrote:
>
> I found an answer to my own question :
> I split my model (plugin_name.py) into multiple files (0_settings.py,
> 1_user.py, etc.) and put them all in a folder ./models/plugin_name/
>
> Web2py does detect that all my model files belong to the same plugin and
> packs them together.
>
>
> *Another problem happens if I do things that way tho :*
>
> I use a database_uri as plugin parameter to define models (tables, fields,
> callbacks, etc.) in my plugin.
>
> - When I access this database from appadmin, the tables work fine
> (validators, callback, everything).
> - When I access this database from my main application (the one onto
> which my plugin is installed), my database isn't recognized at all.
>
>
> From lurking on this fine forum, I established that I have 3 options here :
>
> 1. Work around database cooperation (
> http://web2py.com/books/default/chapter/29/04#Cooperation)
> 2. Use the auto_import=true argument in the DAL
> 3. Rename the model files that came with my plugin, so all model
> features are available in the global namespace
>
> So far, *I am unsatisfied with all 3 options*, with a good reason for
> each of those :
>
> 1. Because I have dependencies between tables which makes it very
> difficult to cleanly manage all those imports
> 2. Because auto_import doesn't manage to retrieve callbacks &
> validators, which leaves me with half the work left to do
> 3. Because it would defeat the purpose of making a plugin in the first
> place
>
>
> I'm a mere padawan on this fine community, so if a web2py guru happens to
> read this thread I would appreciate any tip he could provide to face this
> issue !
>
>
> On Friday, May 23, 2014 2:06:42 PM UTC+2, Louis Amon wrote:
>>
>> I am trying to build a big 'plugin component', with a plugin manager and
>> therefore using the full naming conventions specified in the doc.
>>
>> My model is starting to be huge (1000+ lines) and I'm trying to split it
>> into multiple files.
>>
>>
>> Is there a way to name these files so that web2py still understands that
>> they're part of my plugin ?
>>
>
--
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
---
You received this message because you are subscribed to the Google Groups
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.