Hmmm, if (big if) I am understanding the code correctly, I don’t think 
$latest will work for me. I think it is just calling CurrentObj with a 
data_binding. 
Time to do some more learning.
- rich

On Sunday, 2 July 2023 at 10:28:37 UTC-4 [email protected] wrote:

>
> Tom,
> I know I am on the fringe (or beyond it) of doing supported things, so I 
> really appreciate your patience. 
> First, I am using $current with a data_binding because I have multiple 
> databases. Noting that $current would do the lookup, this was just me being 
> lazy (or it maybe at the time I felt it was more consistent for every 
> observation to use $current). As I noted, I can easily use $latest for the 
> xtype and its dependencies. 
> Second, I am not actually using $current. Because of the way cheetah 
> processes ‘dynamic’ templates, I have moved much of the javascript 
> generation into pure python. So, I am interacting with WeeWX ‘tag’ code 
> directly from python.  Hence my note about not fully supported.
> Thirdly, I am using John Kline’s AQI xtype (
> https://github.com/chaunceygardiner/weewx-airlink). I only wanted the 
> xtype (I don’t have an airlink), so I wrote a service to just load the 
> xtype. Again, I know I am off the support path.
> After writing all this, I realize that I should just $latest(or its 
> equivalent). I don’t think there is a good solution for WeeWX or the AQI 
> xtype to handle this case. I am fine with the xtype expecting the 
> dependency to be in the record. It doesn’t know it is being called in the 
> ‘current context’, so a db lookup to get the latest seems ‘wrong’. I guess 
> if a data_binding is passed into CurrentObj, WeeWX could pass the db record 
> into the xtype system. But really the skin developer could just use $latest.
>  I just wanted to note that there are some complexities/intricacies with 
> xtypes and $current and hopefully save someone some time. 
> Lastly, thanks again to you, Matthew, Gary, and everyone that has 
> contributed to WeeWX. It says a lot about its design and implementation 
> that I can ‘abuse’ it. And thanks for the great support.
> rich
> On Sunday, 2 July 2023 at 09:45:35 UTC-4 Tom Keffer wrote:
>
>> It's up to the implementation of get_scalar() to decide whether to use 
>> the "current" record, or to retrieve a type from the database. Obviously, 
>> if it's not in the record, it should get the necessary ingredients for the 
>> xtypes calculation from either the record, or from the database.
>>
>> What observation type are you trying to calculate? That is, what 
>> implementation of get_scalar() are you referring to?
>>
>> -tk
>>
>>
>>
>> On Sun, Jul 2, 2023 at 6:02 AM [email protected] <[email protected]> 
>> wrote:
>>
>>> I’m using $current.obs where obs is an xtype. 
>>>
>>> The xtype is not in the current record, so a record is retrieved from 
>>> the db. But then the current record is passed into the xtype system. But, 
>>> the necessary values to calculate the xtype are not in the current record. 
>>> So calculating the xtype fails.
>>> So maybe if the xtype fails with the current record, it needs to try 
>>> with the record from the db? That sounds a bit messy…
>>>
>>> Here is a link to the line in question.
>>>
>>> https://github.com/weewx/weewx/blob/548bf5eccc5bba35eeefe482fe4fd1b95f364f06/bin/weewx/tags.py#L599
>>>
>>> A reasonable workaround for me is to $latest.
>>> Thanks!
>>> rich
>>>
>>> -- 
>>> 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/3d6dfa2a-8cb9-40ae-8631-7981210bc041n%40googlegroups.com
>>>  
>>> <https://groups.google.com/d/msgid/weewx-development/3d6dfa2a-8cb9-40ae-8631-7981210bc041n%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/4734f52f-dcbd-458e-af1b-a34d851f90a8n%40googlegroups.com.

Reply via email to