[ckan-dev] Override Core Functionalities

Ian Ward ian at excess.org
Tue Apr 7 14:34:19 UTC 2015


Friends don't let friends monkey-patch python :-P

Might be a better idea to fork ckan and maintain your changes there.
That way you can tell if an upstream change is going to break your
stuff. It's also easier to debug that way.

If you want to maintain this code for any length of time, though, it's
worth trying to use the plugin interfaces instead.

On Tue, Apr 7, 2015 at 10:11 AM, Kirstein, Fabian
<fabian.kirstein at fokus.fraunhofer.de> wrote:
> You are right, it is beyond the scope of this list. I will do some research
> elsewhere. But indeed patching a function worked instantly.
>
> Thanks again.
>
>
>
>
>
>
>
> Von: ckan-dev [mailto:ckan-dev-bounces at lists.okfn.org] Im Auftrag von Denis
> Zgonjanin
> Gesendet: Dienstag, 7. April 2015 15:43
>
>
> An: CKAN Development Discussions
> Betreff: Re: [ckan-dev] Override Core Functionalities
>
>
>
> Well I can't help much without knowing exactly what's happening. It is also
> a general programming question and a bit beyond the scope of this list. But,
> it sounds like you're trying to override a whole module. Why not just try to
> override the functions that you need changed? It's easier and can be done
> from anywhere.
>
>
>
> On Tue, Apr 7, 2015 at 9:30 AM, Kirstein, Fabian
> <fabian.kirstein at fokus.fraunhofer.de> wrote:
>
> That’s was my idea too. I tried to override the sys.module in the
> __init__.py, but I wasn’t successful. So I thought it might be more
> complicated to do it. How would you “monkey-patch” it?
>
> Thanks!
>
>
>
>
>
> Von: ckan-dev [mailto:ckan-dev-bounces at lists.okfn.org] Im Auftrag von Denis
> Zgonjanin
> Gesendet: Dienstag, 7. April 2015 15:17
>
>
> An: CKAN Development Discussions
> Betreff: Re: [ckan-dev] Override Core Functionalities
>
>
>
> You can certainly monkey-patch any module you want. There is nothing special
> about CKAN you need to know, you just need Python
>
>
>
> On Tue, Apr 7, 2015 at 9:10 AM, Kirstein, Fabian
> <fabian.kirstein at fokus.fraunhofer.de> wrote:
>
> Hi,
>
> thanks for the fast response.
> I know you provide already a lot of hooks and they are sufficient for a lot
> of use cases. But still you cannot provide hooks for every possible case. So
> it would be great to a have a fallback solution when it is necessary to
> override some module. I just thought the dynamic nature of Python might
> support such things.
>
>
>
>
> -----Ursprüngliche Nachricht-----
> Von: ckan-dev [mailto:ckan-dev-bounces at lists.okfn.org] Im Auftrag von Adrià
> Mercader
> Gesendet: Dienstag, 7. April 2015 14:43
> An: CKAN Development Discussions
> Betreff: Re: [ckan-dev] Override Core Functionalities
>
>
> Hi,
>
> The safest way is to use the available interfaces and hooks [1].
>
> Specifically you could look at before_index, that allows you to modify what
> gets indexed into Solr:
>
> http://docs.ckan.org/en/latest/extensions/plugin-interfaces.html#ckan.plugins.interfaces.IPackageController.before_index
>
> If the functionality you need is not exposed there we might need to add
> further extension points.
>
>
> Adrià
>
>
> [1] http://docs.ckan.org/en/latest/extensions/plugin-interfaces.html
>
> On 7 April 2015 at 13:04, Kirstein, Fabian
> <fabian.kirstein at fokus.fraunhofer.de> wrote:
>> Hello,
>>
>>
>>
>> I need to override some core functionalities. For example the
>> ckan.lib.search.index module. I was wondering if there is any way to
>> do that without forking CKAN and modifying it directly. Is it possible
>> to copy the module into an extension and modify the module loading in
>> a way to use the customized module. Any experiences with that?
>>
>>
>>
>> Thank you!
>>
>>
>>
>>
>> _______________________________________________
>> ckan-dev mailing list
>> ckan-dev at lists.okfn.org
>> https://lists.okfn.org/mailman/listinfo/ckan-dev
>> Unsubscribe: https://lists.okfn.org/mailman/options/ckan-dev
>>
> _______________________________________________
> ckan-dev mailing list
> ckan-dev at lists.okfn.org
> https://lists.okfn.org/mailman/listinfo/ckan-dev
> Unsubscribe: https://lists.okfn.org/mailman/options/ckan-dev
> _______________________________________________
> ckan-dev mailing list
> ckan-dev at lists.okfn.org
> https://lists.okfn.org/mailman/listinfo/ckan-dev
> Unsubscribe: https://lists.okfn.org/mailman/options/ckan-dev
>
>
>
>
> _______________________________________________
> ckan-dev mailing list
> ckan-dev at lists.okfn.org
> https://lists.okfn.org/mailman/listinfo/ckan-dev
> Unsubscribe: https://lists.okfn.org/mailman/options/ckan-dev
>
>
>
>
> _______________________________________________
> ckan-dev mailing list
> ckan-dev at lists.okfn.org
> https://lists.okfn.org/mailman/listinfo/ckan-dev
> Unsubscribe: https://lists.okfn.org/mailman/options/ckan-dev
>



More information about the ckan-dev mailing list