Hi Tom,

Hope you are well.   

Regardless of whether my question was clear (apologies) your answer is and 
even better its the answer I needed!   Thanks.

Follow up questions:

1)  So we can assume that any data set in the initializer is available 
through out the reporting process?

2) This is potentially useful - is there a way to identify which template 
is being processed at the time?

Thanks again.

Chris

On Tuesday, September 8, 2020 at 3:57:20 PM UTC+1 Tom Keffer wrote:

> I'm not exactly sure what you're asking, but that won't stop me from 
> answering! :-)
>
> The member function get_extension_list() will be called for each template. 
> So, if you have 10 templates, it will get called 10 times. If there is an 
> expensive calculation that does not depend on the timespan that needs to be 
> done, then it is best done in the initializer ('__init__') of your 
> extension.
>
> There are 3 runtime options for extensions:
> 1. The initializer. Called once per skin.
> 2. In  get_extension_list(). Called once per template.
> 3. In the extension tag. Gets called when a '$' tag matches your extension 
> tag.
>
> In general, you want expensive calculations to be done farther up this 
> list. But, if they depend on things only known farther down the list, in 
> particular, a timespan, then you're out of luck.
>
> Hope this helps.
>
> -tk
>
>
> On Tue, Sep 8, 2020 at 12:14 AM Chris Davies-Barnard <[email protected]> 
> wrote:
>
>> Good morning all,
>>
>> After an extended hiatus I am very happy to have a working and recording 
>> weather station again.  Unable to contain myself I am now tinkering with 
>> skins, extensions and data on https://davies-barnard.co.uk/
>>
>> Anyway,  my install of Weewx seems to be making repeated calls to the 
>> extension I'm playing around with.  Its quite computational so I want it to 
>> run only when required to stay up to date.
>>
>> *skin.conf*
>> search_list_extensions = user.xstats.ExtendedStatistics, 
>> user.celestialPatterns.CelestialPatterns
>>  
>> [[ToDate]]
>> ...
>> [[[celestialpatterns]]]
>> template = celestialPatterns.html.tmpl
>>
>> My Extension
>>
>> def get_extension_list(self, timespan, db_lookup): 
>>     print("Extension Called")
>>  
>>      #Get the seasons
>>     seasons = self.getSeasons()
>>
>>      #Get all the sun/moon rises and sets for 12 months.
>>      allRiseAndSet = self.getRiseAndSet()
>>      ...
>>
>> def getSeasons(self):
>>     print ("calling getSeasons")
>>     ....
>>
>> def getRiseAndSet(self):
>>     print("Calling getRiseAndSet")
>>     ...
>>
>> *Is outputing:*
>> daviesc@pecan-ubuntu:/home/weewx$ sudo ./bin/wee_reports weewx.conf
>> Using configuration file weewx.conf
>> Generating for all time
>> Extension Called
>> calling getSeasons
>> Calling getRiseAndSet
>> Extension Called
>> calling getSeasons
>> Calling getRiseAndSet
>> Extension Called
>> calling getSeasons
>> Calling getRiseAndSet
>> Extension Called
>> calling getSeasons
>> Calling getRiseAndSet
>> Extension Called
>> calling getSeasons
>> Calling getRiseAndSet
>> Extension Called
>> calling getSeasons
>> Calling getRiseAndSet
>> Extension Called
>> calling getSeasons
>> Calling getRiseAndSet
>> Extension Called
>> calling getSeasons
>> Calling getRiseAndSet
>> Extension Called
>> calling getSeasons
>> Calling getRiseAndSet
>> Extension Called
>> calling getSeasons
>> Calling getRiseAndSet
>> daviesc@pecan-ubuntu:/home/weewx$
>>
>> I can see this could align with the number of entries 
>> under CheetahGenerator but it seems excessive or is it by design?    If 
>> someone could enlighten me I would be very grateful.
>>
>> Thanks again.
>>
>> Chris
>>
>>
>>
>>
>>
>> -- 
>> You received this message because you are subscribed to the Google Groups 
>> "weewx-development" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to [email protected].
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/weewx-development/c904e46d-c4ec-4293-90ed-ae1a0b3fba24n%40googlegroups.com
>>  
>> <https://groups.google.com/d/msgid/weewx-development/c904e46d-c4ec-4293-90ed-ae1a0b3fba24n%40googlegroups.com?utm_medium=email&utm_source=footer>
>> .
>>
>

-- 
You received this message because you are subscribed to the Google Groups 
"weewx-development" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/weewx-development/17a86f53-c429-4b0e-b390-1a4ddc652478n%40googlegroups.com.

Reply via email to