I do this for controllers too, but with the current plugin I am
working on (pingback/trackback) i have right now 5 models which define
functions that need to be accessible from anywhere (which I might
redesign this and put them as modules, so they don't get executed
every time). There are 15 functions / plugin specific variables across
these files.

For small plugins it is not that big of a deal (my comment plugin
looks fine). However for larger ones it gets crazy.

Without looking at how web2py currently dispatches models, would it be
possible to have plugins dispatch in their own "container" so that
variables / functions declared within do not appear in globals(). For
functions that should be exposed a decorator such as @expose() and
web2py will take the function name, append plugin_ to it, and place it
in the web2py globals if there is no name conflict.

just going out on a limb here.

-Thadeus





On Wed, Dec 23, 2009 at 10:23 PM, mdipierro <[email protected]> wrote:
> The current mechanism is not optimal but as we discuss works without
> adding new structure.
> I am open to proposals.
>
> The way I deal with this is that in models I use the long name for the
> table
>
>   db.plugin_tagging_tag
>
> but on top of the plugin controller I shorten it
>
>   tag = db.plugin_tagging_tag
>
> Massimo
>
> On Dec 23, 10:02 pm, Thadeus Burgess <[email protected]> wrote:
>> Massimo,
>>
>> I know with the current implementation of plugins the current spec
>> calls for you to append plugin_ to all of the function names /
>> database names that get called. Is there a better way of doing this?
>>
>> The reason I ask is that it leads to having long variable and function
>> names... a simple query gets quite insane after a while...
>>
>> db(db.plugin_pingback_incoming.url ==
>> url)(db.plugin_pingback_incoming.blog_name ==
>> blog_name).select(orderby=~db.plugin_pingback_incoming.receive_date)
>>
>> Another annoying issue is the calling internal plugin functions, it
>> gets just as crazy when you have to call
>> plugin_pingback_send_pingback(decoder=plugin_pingback_pingback_decoder)....
>>
>> Is it feasible that plug-ins could have their own namespace, this way
>> I can call my function internally "send_pingback" and then in other
>> parts of the application could access the public functions by
>> plugin_pingback.send_pingback() ?
>>
>> If there is no other way... I will live...
>>
>> -Thadeus
>
> --
>
> 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.
>
>
>

--

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