问:
Issues upgrading from wagtail 2.15.6 to 2.16 breaks all pages except home page
I am experiencing an issue upgrading a site's wagtail installed version. I have successfully upgraded from 2.12 to 2.15.6 but am running into what seems to be an impassible issue with upgrading to 2.16 Specifically to do with this recent commit in 2.16 stable

https://github.com/wagtail/wagtail/commit/29a7f701611d22ab9c7f12f1134aeac1d31b9438

Every page except the root page of the site brings up the following error (including django and wagtail admins)

```<code>AttributeError at /django-admin/
'tuple' object has no attribute 'root_path'
Request Method: GET
Request URL:    http://localhost:8000/django-admin/
Django Version: 3.2
Exception Type: AttributeError
Exception Value:
'tuple' object has no attribute 'root_path'
Exception Location: /usr/local/lib/python3.7/site-packages/wagtail/core/models/__init__.py, line 1109, in <genexpr>
Python Executable:  /usr/local/bin/python
Python Version: 3.7.14
Python Path:
['/app',
 '/usr/local/lib/python37.zip',
 '/usr/local/lib/python3.7',
 '/usr/local/lib/python3.7/lib-dynload',
 '/usr/local/lib/python3.7/site-packages']
Server time:    Fri, 09 Dec 2022 15:42:48 -0500

Environment:

Request Method: GET
Request URL: http://localhost:8000/django-admin/

Django Version: 3.2
Python Version: 3.7.14

Installed Middleware:
['django.middleware.security.SecurityMiddleware',
 'whitenoise.middleware.WhiteNoiseMiddleware',
 'globalapp.middleware.request.RequestMiddleware',
 'django_user_agents.middleware.UserAgentMiddleware',
 'django.contrib.sessions.middleware.SessionMiddleware',
 'django.middleware.locale.LocaleMiddleware',
 'django.middleware.common.CommonMiddleware',
 'righttoplay.middleware.CustomCacheMiddleware',
 'django.middleware.csrf.CsrfViewMiddleware',
 'django.contrib.auth.middleware.AuthenticationMiddleware',
 'django.contrib.messages.middleware.MessageMiddleware',
 'django.middleware.clickjacking.XFrameOptionsMiddleware',
 'wagtail.contrib.redirects.middleware.RedirectMiddleware']

Traceback (most recent call last):
  File "/usr/local/lib/python3.7/site-packages/django/core/handlers/exception.py", line 47, in inner
    response = get_response(request)
  File "/usr/local/lib/python3.7/site-packages/django/core/handlers/base.py", line 204, in _get_response
    response = response.render()
  File "/usr/local/lib/python3.7/site-packages/django/template/response.py", line 105, in render
    self.content = self.rendered_content
  File "/usr/local/lib/python3.7/site-packages/django/template/response.py", line 83, in rendered_content
    return template.render(context, self._request)
  File "/usr/local/lib/python3.7/site-packages/django/template/backends/django.py", line 61, in render
    return self.template.render(context)
  File "/usr/local/lib/python3.7/site-packages/django/template/base.py", line 168, in render
    with context.bind_template(self):
  File "/usr/local/lib/python3.7/contextlib.py", line 112, in __enter__
    return next(self.gen)
  File "/usr/local/lib/python3.7/site-packages/django/template/context.py", line 244, in bind_template
    updates.update(processor(self.request))
  File "/app/globalapp/context_processors.py", line 8, in site_settings
    return {"settings" : national_office.serialized_data }
  File "/app/globalapp/models.py", line 1542, in serialized_data
    if self.privacy_page
  File "/usr/local/lib/python3.7/site-packages/wagtail/core/models/__init__.py", line 1214, in get_url
    url_parts = self.get_url_parts(request=request)
  File "/usr/local/lib/python3.7/site-packages/wagtail/core/models/__init__.py", line 1130, in get_url_parts
    possible_sites = self._get_relevant_site_root_paths(request)
  File "/usr/local/lib/python3.7/site-packages/wagtail/core/models/__init__.py", line 1108, in _get_relevant_site_root_paths
    for srp in self._get_site_root_paths(cache_object)
  File "/usr/local/lib/python3.7/site-packages/wagtail/core/models/__init__.py", line 1109, in <genexpr>
    if self.url_path.startswith(srp.root_path)

Exception Type: AttributeError at /django-admin/
Exception Value: 'tuple' object has no attribute 'root_path'
</code>```

None of this was documented as a breaking change in the upgrade process I've been following here

https://docs.wagtail.org/en/stable/releases/2.16.html

Technical details
-Python Version is 3.7 running in a docker container

Im including the requirements.txt here if there are any further package or dependancy changes I need to make that arent outlined please let me know.

```<code>aiosignal==1.2.0
anyascii==0.3.1
async-timeout==4.0.2
attrs==22.1.0
azure-core==1.25.1
azure-storage-blob==12.13.1
beautifulsoup4==4.9.3
certifi==2022.9.24
cffi==1.15.1
charset-normalizer==2.1.1
cryptography==38.0.1
Deprecated==1.2.13
Django==3.2
django-ajax-selects==2.2.0
django-cogwheels==0.3
django-email-extras==0.3.4
django-extensions==3.1.5
django-filter==2.4.0
django-modelcluster==5.3
django-modeltranslation==0.18.2
django-redis==5.2.0
django-storages==1.12.3
django-taggit==2.0
django-treebeard==4.5.1
django-user-agents==0.4.0
djangorestframework==3.13.1
docopt==0.4.0
draftjs-exporter==2.1.7
et-xmlfile==1.1.0
frozenlist==1.3.1
future==0.18.2
geoip2==4.6.0
gunicorn==20.1.0
html5lib==1.1
idna==3.4
isodate==0.6.1
l18n==2021.3
mailchimp3==3.0.17
mandrill==1.0.60
maxminddb==2.2.0
msrest==0.7.1
multidict==6.0.2
oauthlib==3.2.1
openpyxl==3.0.10
packaging==21.3
Pillow==8.4.0
psycopg2==2.9.3
pycparser==2.21
pyparsing==3.0.9
python-gnupg==0.5.0
pytz==2022.2.1
redis==4.3.4
requests==2.28.1
requests-oauthlib==1.3.1
six==1.16.0
soupsieve==2.3.2.post1
sqlparse==0.4.3
tablib==3.2.1
telepath==0.3
typing_extensions==4.3.0
ua-parser==0.16.1
Unidecode==1.3.6
urllib3==1.26.12
user-agents==2.2.0
wagtail==2.16
wagtail-condensedinlinepanel==0.5.3
wagtail-clear-cache==0.0.1
wagtail-modeltranslation==0.10.18
wagtailgmaps==1.0.1
wagtailmedia==0.9.0
wagtailmenus==3.1.2
webencodings==0.5.1
whitenoise==6.2.0
Willow==1.4.1
wrapt==1.14.1
xlrd==2.0.1
XlsxWriter==1.4.5
xlwt==1.3.0
yarl==1.8.1
</code>```

Following the upgrade docs https://docs.wagtail.org/en/stable/releases/2.16.html ran into this unexpected / undocumented issue.

Here is the context_processor that is causing the issue. which is getting a model of National Office which has on it multiple Pages that are foreign keys of wagtailcore.Page and the serialized_data method has some if statements checking for if the page foreign key exists and it is these checks that are triggering the wagtailcore code that is failing.

```<code>def site_settings(request):
    domain = request.META['HTTP_HOST'].replace("www.", "")
    try:
        national_office = NationalOffice.objects.get(domain=domain)
        return {"settings" : national_office.serialized_data }
    except ObjectDoesNotExist:
        print(" NO Not Found ")
        return {}
</code>```

The below is the serialized data method and it is erroring on the if self.privacy_page check which is the first occurrence of the model's foreign keys to the wagtailcore.Page in this serialized_data method

```@property
    def serialized_data(self):
        global_settings = GlobalSiteSettings.objects.all()[0]
        languages = []
        for language in self.languages.all():
            languages.append(language.serialized_data)

        static_text = None
        global_settings = GlobalSiteSettings.objects.all()[:1].get()

        if global_settings:
            static_text = global_settings.static_text

        national_offices = []
        for national_office in NationalOffice.objects.all():
            national_offices.append(
                {
                    "name": national_office.name,
                    "domain": national_office.domain,
                    "default_language_short_name": national_office.default_language.short_name
                    if national_office.default_language
                    else "en",
                    "current": True if national_office.id == self.id else False,
                    "flag": self.flag,
                    "append_to_url": "?no-redirect=true"
                    if national_office.redirect_by_geo_ip
                    else None,
                }
            )

        data = {
            # static
            "static_text": static_text,
            "national_offices": national_offices,
            "name": self.name,
            "flag": self.flag,
            "domain": self.domain,
            "gmt_code": self.gmt_code,
            # language
            "show_language_switcher": True if len(languages) > 1 else False,
            "languages": languages,
            "default_language_short_name": self.default_language.short_name,
            # header
            "announcement_text": self.announcement_text,
            "announcement_link": self.announcement_link,
            "join_nav_txt_1": self.join_nav_txt_1,
            "join_nav_url_1": self.join_nav_url_1,
            "join_nav_txt_2": self.join_nav_txt_2,
            "join_nav_url_2": self.join_nav_url_2,
            "join_nav_txt_3": self.join_nav_txt_3,
            "join_nav_url_3": self.join_nav_url_3,
            "footer_col_1_text_1": self.footer_col_1_text_1,
            "footer_col_1_url_1": self.footer_col_1_url_1,
            "footer_col_1_text_2": self.footer_col_1_text_2,
            "footer_col_1_url_2": self.footer_col_1_url_2,
            "footer_col_1_text_3": self.footer_col_1_text_3,
            "footer_col_1_url_3": self.footer_col_1_url_3,
            "footer_col_2_text_1": self.footer_col_2_text_1,
            "footer_col_2_url_1": self.footer_col_2_url_1,
            "footer_col_2_text_2": self.footer_col_2_text_2,
            "footer_col_2_url_2": self.footer_col_2_url_2,
            "footer_col_2_text_3": self.footer_col_2_text_3,
            "footer_col_2_url_3": self.footer_col_2_url_3,
            "footer_col_3_text_1": self.footer_col_3_text_1,
            "footer_col_3_url_1": self.footer_col_3_url_1,
            "footer_col_3_text_2": self.footer_col_3_text_2,
            "footer_col_3_url_2": self.footer_col_3_url_2,
            "footer_col_3_text_3": self.footer_col_3_text_3,
            "footer_col_3_url_3": self.footer_col_3_url_3,
            "primary_donation_url": self.primary_donation_url
            if self.primary_donation_url
            else None,
            "primary_donation_page": self.primary_donation_page
            if self.primary_donation_page
            else None,
            "show_fundraise_link": self.show_fundraise_link,
            "show_events_link": self.show_events_link,
            "show_get_involved_link": self.show_get_involved_link,
            "show_third_party_events": self.show_third_party_events,
            # footer
            "facebook_url": self.facebook_url
            if self.facebook_url
            else global_settings.facebook_url,
            "twitter_url": self.twitter_url
            if self.twitter_url
            else global_settings.twitter_url,
            "instagram_url": self.instagram_url
            if self.instagram_url
            else global_settings.instagram_url,
            "linkedin_url": self.linkedin_url
            if self.linkedin_url
            else global_settings.linkedin_url,
            "youtube_url": self.youtube_url
            if self.youtube_url
            else global_settings.youtube_url,
            "business_number_title": self.business_number_title
            if self.business_number_title
            else None,
            "business_number_value": self.business_number_value
            if self.business_number_value
            else None,
            "business_logo1": self.logo1 if self.logo1 else None,
            "business_logo2": self.logo2 if self.logo2 else None,
            "business_logo1_url": self.logo1_url if self.logo1_url else None,
            "business_logo2_url": self.logo2_url if self.logo2_url else None,
            "contact_director_name": self.contact_director_name
            if self.contact_director_name
            else None,
            "contact_director_title": self.contact_director_title
            if self.contact_director_title
            else None,
            "contact_address": self.contact_address if self.contact_address else None,
            "contact_phone": self.contact_phone if self.contact_phone else None,
            "contact_email": self.contact_email if self.contact_email else None,
            "contact_show_program_offices": self.contact_show_program_offices
            if self.contact_show_program_offices
            else False,
            "footer_subscribe_title": self.footer_subscribe_title
            if self.footer_subscribe_title
            else global_settings.footer_subscribe_title,
            "shop_page_url": self.shop_page if self.shop_page else None,
            "shop_page_title": self.shop_page_title if self.shop_page_title else None,
            "privacy_page_url": self.privacy_page.url
            if self.privacy_page
            else global_settings.privacy_page.url
            if global_settings.privacy_page
            else None,
            "privacy_page_title": self.privacy_page.title
            if self.privacy_page
            else global_settings.privacy_page.title
            if global_settings.privacy_page
            else None,
            "terms_page_url": self.terms_page.url
            if self.terms_page
            else global_settings.terms_page.url
            if global_settings.terms_page
            else None,
            "terms_page_title": self.terms_page.title
            if self.terms_page
            else global_settings.terms_page.title
            if global_settings.terms_page
            else None,
            "faq_page_url": self.faq_page.url
            if self.faq_page
            else global_settings.faq_page.url
            if global_settings.faq_page
            else None,
            "faq_page_title": self.faq_page.title
            if self.faq_page
            else global_settings.faq_page.title
            if global_settings.faq_page
            else None,
            "contact_page_url": self.contact_page.url
            if self.contact_page
            else global_settings.contact_page.url
            if global_settings.contact_page
            else None,
            "contact_page_title": self.contact_page.title
            if self.contact_page
            else global_settings.contact_page.title
            if global_settings.contact_page
            else None,
            "search_page_url": global_settings.search_page.url
            if global_settings.search_page
            else None,
            "resources_page_url": self.resources_page.url
            if self.resources_page
            else None,
            "resources_page_title": self.resources_page.title
            if self.resources_page
            else None,
            "more_ways_to_give_page_url": self.more_ways_to_give_page.url
            if self.more_ways_to_give_page
            else None,
            "more_ways_to_give_page_title": self.more_ways_to_give_page.title
            if self.more_ways_to_give_page
            else None,
            "more_ways_to_give_page": self.more_ways_to_give_page
            if self.more_ways_to_give_page
            else None,
            "careers_page": self.careers_page if self.careers_page else None,
            "media_center_page": self.media_center_page
            if self.media_center_page
            else None,
            "campaign_page": self.campaign_page if self.campaign_page else None,
            "we_rise_page": self.we_rise_page if self.we_rise_page else None,
            "footer_accessibility_url": self.footer_accessibility_url
            if self.footer_accessibility_url
            else None,
            "footer_accessibility_title": self.footer_accessibility_title
            if self.footer_accessibility_title
            else None,
            "fundraise_page_url": self.fundraise_page.url
            if self.fundraise_page
            else None,
            "fundraise_page_title": self.fundraise_page.title
            if self.fundraise_page
            else None,
            # generic bottom cta
            "generic_bottom_cta_title": self.generic_bottom_cta_title
            if self.generic_bottom_cta_title
            else None,
            "generic_bottom_cta_body": self.generic_bottom_cta_body
            if self.generic_bottom_cta_body
            else None,
            "generic_bottom_cta_button_text": self.generic_bottom_cta_button_text
            if self.generic_bottom_cta_button_text
            else None,
            "generic_bottom_cta_button_page": self.generic_bottom_cta_button_page
            if self.generic_bottom_cta_button_page
            else None,
            "generic_bottom_cta_button_url": self.generic_bottom_cta_button_url
            if self.generic_bottom_cta_button_url
            else None,
            "cookie_text": self.cookie_text
            if self.cookie_text
            else global_settings.cookie_text,
            "cookie_agree_text": self.cookie_agree_text
            if self.cookie_agree_text
            else global_settings.cookie_agree_text,
            # homepage overrides
            "top_carousel_type": self.top_carousel_type
            if self.top_carousel_type is not "default"
            else None,
            "top_carousel_image": self.top_carousel_image
            if self.top_carousel_image
            else None,
            "top_carousel_title": self.top_carousel_title
            if self.top_carousel_title
            else None,
            "top_carousel_button_page": self.top_carousel_button_page
            if self.top_carousel_button_page
            else None,
            "top_carousel_button_text": self.top_carousel_button_text
            if self.top_carousel_button_text
            else None,
            "home_hide_top_carousel_text": self.home_hide_top_carousel_text,
            "home_hide_top_carousel_button": self.home_hide_top_carousel_button,
            "home_section_0_visible": self.home_section_0_visible,
            "home_section_0_title": self.home_section_0_title
            if self.home_section_0_title
            else None,
            "home_section_0_body": self.home_section_0_body
            if self.home_section_0_body
            else None,
            "home_section_0_body_mobile": self.home_section_0_body_mobile
            if self.home_section_0_body_mobile
            else None,
            "home_section_0_button_text": self.home_section_0_button_text
            if self.home_section_0_button_text
            else None,
            "home_section_0_button_url": self.home_section_0_button_url
            if self.home_section_0_button_url
            else None,
            "home_section_0_light_foreground": self.home_section_0_light_foreground
            if self.home_section_0_light_foreground != "none"
            else None,
            "home_section_0_text_align": self.home_section_0_text_align
            if self.home_section_0_text_align != "none"
            else None,
            "home_section_0_background_image": self.home_section_0_background_image
            if self.home_section_0_background_image
            else None,
            "home_section_0_button_url": self.home_section_0_button_url
            if self.home_section_0_button_url
            else None,
            "home_section_0_button_page": self.home_section_0_button_page
            if self.home_section_0_button_page
            else None,
            "home_section_1_title": self.home_section_1_title
            if self.home_section_1_title
            else None,
            "home_section_1_body": self.home_section_1_body
            if self.home_section_1_body
            else None,
            "home_section_1_body_mobile": self.home_section_1_body_mobile
            if self.home_section_1_body_mobile
            else None,
            "home_section_1_button_text": self.home_section_1_button_text
            if self.home_section_1_button_text
            else None,
            "home_section_1_button_url": self.home_section_1_button_url
            if self.home_section_1_button_url
            else None,
            "home_section_1_light_foreground": self.home_section_1_light_foreground
            if self.home_section_1_light_foreground != "none"
            else None,
            "home_section_1_text_align": self.home_section_1_text_align
            if self.home_section_1_text_align != "none"
            else None,
            "home_section_1_background_image": self.home_section_1_background_image
            if self.home_section_1_background_image
            else None,
            "home_section_1_button_url": self.home_section_1_button_url
            if self.home_section_1_button_url
            else None,
            "home_section_1_button_page": self.home_section_1_button_page
            if self.home_section_1_button_page
            else None,
            "home_section_2_title": self.home_section_2_title
            if self.home_section_2_title
            else None,
            "home_section_2_body": self.home_section_2_body
            if self.home_section_2_body
            else None,
            "home_section_2_body_mobile": self.home_section_2_body_mobile
            if self.home_section_2_body_mobile
            else None,
            "home_section_2_button_text": self.home_section_2_button_text
            if self.home_section_2_button_text
            else None,
            "home_section_2_button_url": self.home_section_2_button_url
            if self.home_section_2_button_url
            else None,
            "home_section_2_light_foreground": self.home_section_2_light_foreground
            if self.home_section_2_light_foreground != "none"
            else None,
            "home_section_2_text_align": self.home_section_2_text_align
            if self.home_section_2_text_align != "none"
            else None,
            "home_section_2_background_image": self.home_section_2_background_image
            if self.home_section_2_background_image
            else None,
            "home_section_2_button_url": self.home_section_2_button_url
            if self.home_section_2_button_url
            else None,
            "home_section_2_button_page": self.home_section_2_button_page
            if self.home_section_2_button_page
            else None,
            "home_section_3_title": self.home_section_3_title
            if self.home_section_3_title
            else None,
            "home_section_3_body": self.home_section_3_body
            if self.home_section_3_body
            else None,
            "home_section_3_body_mobile": self.home_section_3_body_mobile
            if self.home_section_3_body_mobile
            else None,
            "home_section_3_button_text": self.home_section_3_button_text
            if self.home_section_3_button_text
            else None,
            "home_section_3_button_url": self.home_section_3_button_url
            if self.home_section_3_button_url
            else None,
            "home_section_3_light_foreground": self.home_section_3_light_foreground
            if self.home_section_3_light_foreground != "none"
            else None,
            "home_section_3_text_align": self.home_section_3_text_align
            if self.home_section_3_text_align != "none"
            else None,
            "home_section_3_background_image": self.home_section_3_background_image
            if self.home_section_3_background_image
            else None,
            "home_section_3_button_url": self.home_section_3_button_url
            if self.home_section_3_button_url
            else None,
            "home_section_3_button_page": self.home_section_3_button_page
            if self.home_section_3_button_page
            else None,
            "home_section_4_title": self.home_section_4_title
            if self.home_section_4_title
            else None,
            "home_section_4_body": self.home_section_4_body
            if self.home_section_4_body
            else None,
            "home_section_4_article": self.home_section_4_article
            if self.home_section_4_article
            else None,
            "home_section_4_button_text": self.home_section_4_button_text
            if self.home_section_4_button_text
            else None,
            "home_section_4_light_foreground": self.home_section_4_light_foreground
            if self.home_section_4_light_foreground
            else None,
            "home_section_4_text_align": self.home_section_4_text_align
            if self.home_section_4_text_align
            else None,
            "home_section_4_image_override": self.home_section_4_image_override
            if self.home_section_4_image_override
            else None,
            "home_featured_article_1": self.home_featured_article_1
            if self.home_featured_article_1
            else None,
            "home_featured_article_2": self.home_featured_article_2
            if self.home_featured_article_2
            else None,
            "home_featured_article_3": self.home_featured_article_3
            if self.home_featured_article_3
            else None,
            "home_bottom_cta_title": self.home_bottom_cta_title
            if self.home_bottom_cta_title
            else None,
            "home_bottom_cta_button_text": self.home_bottom_cta_button_text
            if self.home_bottom_cta_button_text
            else None,
            "home_bottom_cta_body": self.home_bottom_cta_body
            if self.home_bottom_cta_body
            else None,
            "home_bottom_cta_button_page": self.home_bottom_cta_button_page
            if self.home_bottom_cta_button_page
            else None,
            "home_bottom_cta_button_url": self.home_bottom_cta_button_url
            if self.home_bottom_cta_button_url
            else None,
            "impact_featured_article": self.impact_featured_article
            if self.impact_featured_article
            else None,
            "impact_featured_article_heading": self.impact_featured_article_heading
            if self.impact_featured_article_heading
            else None,
            "impact_featured_article_title": self.impact_featured_article_title
            if self.impact_featured_article_title
            else None,
            "impact_featured_article_button_text": self.impact_featured_article_button_text
            if self.impact_featured_article_button_text
            else None,
            "impact_featured_article_excerpt": self.impact_featured_article_excerpt
            if self.impact_featured_article_excerpt
            else None,
            "show_fundraise_inspiration_section": self.show_fundraise_inspiration_section,
            "featured_event": self.featured_event if self.featured_event else None,
            "featured_news": self.featured_news if self.featured_news else None,
            "featured_story": self.featured_story if self.featured_story else None,
            "share_twitter_handle": self.share_twitter_handle
            if self.share_twitter_handle
            else global_settings.share_twitter_handle
            if global_settings.share_twitter_handle
            else None,
            "share_image": self.share_image
            if self.share_image
            else global_settings.share_image
            if global_settings.share_image
            else None,
            "share_description": self.share_description
            if self.share_description
            else global_settings.share_description
            if global_settings.share_description
            else None,
            "facebook_pixel": self.facebook_pixel,
        }

        return data
```
<p>This is the code block in the wagtail 2.16 update that is causing my issues. It is trying to access a instance variable from the site root path but the get_site_root_paths() method is returning a list of site root paths causing the error</p>
```def _get_relevant_site_root_paths(self, cache_object=None):
        """
        .. versionadded::2.16
        Returns a tuple of root paths for all sites this page belongs to.
        """
        return tuple(
            srp
            for srp in self._get_site_root_paths(cache_object)
            if self.url_path.startswith(srp.root_path)
        )
```

Body:
I am experiencing an issue upgrading a site's wagtail installed version. I have successfully upgraded from 2.12 to 2.15.6 but am running into what seems to be an impassible issue with upgrading to 2.16 Specifically to do with this recent commit in 2.16 stable

https://github.com/wagtail/wagtail/commit/29a7f701611d22ab9c7f12f1134aeac1d31b9438

Every page except the root page of the site brings up the following error (including django and wagtail admins)

AttributeError at /django-admin/
'tuple' object has no attribute 'root_path'
Request Method: GET
Request URL:    http://localhost:8000/django-admin/
Django Version: 3.2
Exception Type: AttributeError
Exception Value:
'tuple' object has no attribute 'root_path'
Exception Location: /usr/local/lib/python3.7/site-packages/wagtail/core/models/__init__.py, line 1109, in <genexpr>
Python Executable:  /usr/local/bin/python
Python Version: 3.7.14
Python Path:
['/app',
 '/usr/local/lib/python37.zip',
 '/usr/local/lib/python3.7',
 '/usr/local/lib/python3.7/lib-dynload',
 '/usr/local/lib/python3.7/site-packages']
Server time:    Fri, 09 Dec 2022 15:42:48 -0500

Environment:

Request Method: GET
Request URL: http://localhost:8000/django-admin/

Django Version: 3.2
Python Version: 3.7.14

Installed Middleware:
['django.middleware.security.SecurityMiddleware',
 'whitenoise.middleware.WhiteNoiseMiddleware',
 'globalapp.middleware.request.RequestMiddleware',
 'django_user_agents.middleware.UserAgentMiddleware',
 'django.contrib.sessions.middleware.SessionMiddleware',
 'django.middleware.locale.LocaleMiddleware',
 'django.middleware.common.CommonMiddleware',
 'righttoplay.middleware.CustomCacheMiddleware',
 'django.middleware.csrf.CsrfViewMiddleware',
 'django.contrib.auth.middleware.AuthenticationMiddleware',
 'django.contrib.messages.middleware.MessageMiddleware',
 'django.middleware.clickjacking.XFrameOptionsMiddleware',
 'wagtail.contrib.redirects.middleware.RedirectMiddleware']

Traceback (most recent call last):
  File "/usr/local/lib/python3.7/site-packages/django/core/handlers/exception.py", line 47, in inner
    response = get_response(request)
  File "/usr/local/lib/python3.7/site-packages/django/core/handlers/base.py", line 204, in _get_response
    response = response.render()
  File "/usr/local/lib/python3.7/site-packages/django/template/response.py", line 105, in render
    self.content = self.rendered_content
  File "/usr/local/lib/python3.7/site-packages/django/template/response.py", line 83, in rendered_content
    return template.render(context, self._request)
  File "/usr/local/lib/python3.7/site-packages/django/template/backends/django.py", line 61, in render
    return self.template.render(context)
  File "/usr/local/lib/python3.7/site-packages/django/template/base.py", line 168, in render
    with context.bind_template(self):
  File "/usr/local/lib/python3.7/contextlib.py", line 112, in __enter__
    return next(self.gen)
  File "/usr/local/lib/python3.7/site-packages/django/template/context.py", line 244, in bind_template
    updates.update(processor(self.request))
  File "/app/globalapp/context_processors.py", line 8, in site_settings
    return {"settings" : national_office.serialized_data }
  File "/app/globalapp/models.py", line 1542, in serialized_data
    if self.privacy_page
  File "/usr/local/lib/python3.7/site-packages/wagtail/core/models/__init__.py", line 1214, in get_url
    url_parts = self.get_url_parts(request=request)
  File "/usr/local/lib/python3.7/site-packages/wagtail/core/models/__init__.py", line 1130, in get_url_parts
    possible_sites = self._get_relevant_site_root_paths(request)
  File "/usr/local/lib/python3.7/site-packages/wagtail/core/models/__init__.py", line 1108, in _get_relevant_site_root_paths
    for srp in self._get_site_root_paths(cache_object)
  File "/usr/local/lib/python3.7/site-packages/wagtail/core/models/__init__.py", line 1109, in <genexpr>
    if self.url_path.startswith(srp.root_path)

Exception Type: AttributeError at /django-admin/
Exception Value: 'tuple' object has no attribute 'root_path'

None of this was documented as a breaking change in the upgrade process I've been following here

https://docs.wagtail.org/en/stable/releases/2.16.html

Technical details
-Python Version is 3.7 running in a docker container

Im including the requirements.txt here if there are any further package or dependancy changes I need to make that arent outlined please let me know.

aiosignal==1.2.0
anyascii==0.3.1
async-timeout==4.0.2
attrs==22.1.0
azure-core==1.25.1
azure-storage-blob==12.13.1
beautifulsoup4==4.9.3
certifi==2022.9.24
cffi==1.15.1
charset-normalizer==2.1.1
cryptography==38.0.1
Deprecated==1.2.13
Django==3.2
django-ajax-selects==2.2.0
django-cogwheels==0.3
django-email-extras==0.3.4
django-extensions==3.1.5
django-filter==2.4.0
django-modelcluster==5.3
django-modeltranslation==0.18.2
django-redis==5.2.0
django-storages==1.12.3
django-taggit==2.0
django-treebeard==4.5.1
django-user-agents==0.4.0
djangorestframework==3.13.1
docopt==0.4.0
draftjs-exporter==2.1.7
et-xmlfile==1.1.0
frozenlist==1.3.1
future==0.18.2
geoip2==4.6.0
gunicorn==20.1.0
html5lib==1.1
idna==3.4
isodate==0.6.1
l18n==2021.3
mailchimp3==3.0.17
mandrill==1.0.60
maxminddb==2.2.0
msrest==0.7.1
multidict==6.0.2
oauthlib==3.2.1
openpyxl==3.0.10
packaging==21.3
Pillow==8.4.0
psycopg2==2.9.3
pycparser==2.21
pyparsing==3.0.9
python-gnupg==0.5.0
pytz==2022.2.1
redis==4.3.4
requests==2.28.1
requests-oauthlib==1.3.1
six==1.16.0
soupsieve==2.3.2.post1
sqlparse==0.4.3
tablib==3.2.1
telepath==0.3
typing_extensions==4.3.0
ua-parser==0.16.1
Unidecode==1.3.6
urllib3==1.26.12
user-agents==2.2.0
wagtail==2.16
wagtail-condensedinlinepanel==0.5.3
wagtail-clear-cache==0.0.1
wagtail-modeltranslation==0.10.18
wagtailgmaps==1.0.1
wagtailmedia==0.9.0
wagtailmenus==3.1.2
webencodings==0.5.1
whitenoise==6.2.0
Willow==1.4.1
wrapt==1.14.1
xlrd==2.0.1
XlsxWriter==1.4.5
xlwt==1.3.0
yarl==1.8.1

Following the upgrade docs https://docs.wagtail.org/en/stable/releases/2.16.html ran into this unexpected / undocumented issue.

Here is the context_processor that is causing the issue. which is getting a model of National Office which has on it multiple Pages that are foreign keys of wagtailcore.Page and the serialized_data method has some if statements checking for if the page foreign key exists and it is these checks that are triggering the wagtailcore code that is failing.

def site_settings(request):
    domain = request.META['HTTP_HOST'].replace("www.", "")
    try:
        national_office = NationalOffice.objects.get(domain=domain)
        return {"settings" : national_office.serialized_data }
    except ObjectDoesNotExist:
        print(" NO Not Found ")
        return {}

The below is the serialized data method and it is erroring on the if self.privacy_page check which is the first occurrence of the model's foreign keys to the wagtailcore.Page in this serialized_data method

@property
    def serialized_data(self):
        global_settings = GlobalSiteSettings.objects.all()[0]
        languages = []
        for language in self.languages.all():
            languages.append(language.serialized_data)

        static_text = None
        global_settings = GlobalSiteSettings.objects.all()[:1].get()

        if global_settings:
            static_text = global_settings.static_text

        national_offices = []
        for national_office in NationalOffice.objects.all():
            national_offices.append(
                {
                    "name": national_office.name,
                    "domain": national_office.domain,
                    "default_language_short_name": national_office.default_language.short_name
                    if national_office.default_language
                    else "en",
                    "current": True if national_office.id == self.id else False,
                    "flag": self.flag,
                    "append_to_url": "?no-redirect=true"
                    if national_office.redirect_by_geo_ip
                    else None,
                }
            )

        data = {
            # static
            "static_text": static_text,
            "national_offices": national_offices,
            "name": self.name,
            "flag": self.flag,
            "domain": self.domain,
            "gmt_code": self.gmt_code,
            # language
            "show_language_switcher": True if len(languages) > 1 else False,
            "languages": languages,
            "default_language_short_name": self.default_language.short_name,
            # header
            "announcement_text": self.announcement_text,
            "announcement_link": self.announcement_link,
            "join_nav_txt_1": self.join_nav_txt_1,
            "join_nav_url_1": self.join_nav_url_1,
            "join_nav_txt_2": self.join_nav_txt_2,
            "join_nav_url_2": self.join_nav_url_2,
            "join_nav_txt_3": self.join_nav_txt_3,
            "join_nav_url_3": self.join_nav_url_3,
            "footer_col_1_text_1": self.footer_col_1_text_1,
            "footer_col_1_url_1": self.footer_col_1_url_1,
            "footer_col_1_text_2": self.footer_col_1_text_2,
            "footer_col_1_url_2": self.footer_col_1_url_2,
            "footer_col_1_text_3": self.footer_col_1_text_3,
            "footer_col_1_url_3": self.footer_col_1_url_3,
            "footer_col_2_text_1": self.footer_col_2_text_1,
            "footer_col_2_url_1": self.footer_col_2_url_1,
            "footer_col_2_text_2": self.footer_col_2_text_2,
            "footer_col_2_url_2": self.footer_col_2_url_2,
            "footer_col_2_text_3": self.footer_col_2_text_3,
            "footer_col_2_url_3": self.footer_col_2_url_3,
            "footer_col_3_text_1": self.footer_col_3_text_1,
            "footer_col_3_url_1": self.footer_col_3_url_1,
            "footer_col_3_text_2": self.footer_col_3_text_2,
            "footer_col_3_url_2": self.footer_col_3_url_2,
            "footer_col_3_text_3": self.footer_col_3_text_3,
            "footer_col_3_url_3": self.footer_col_3_url_3,
            "primary_donation_url": self.primary_donation_url
            if self.primary_donation_url
            else None,
            "primary_donation_page": self.primary_donation_page
            if self.primary_donation_page
            else None,
            "show_fundraise_link": self.show_fundraise_link,
            "show_events_link": self.show_events_link,
            "show_get_involved_link": self.show_get_involved_link,
            "show_third_party_events": self.show_third_party_events,
            # footer
            "facebook_url": self.facebook_url
            if self.facebook_url
            else global_settings.facebook_url,
            "twitter_url": self.twitter_url
            if self.twitter_url
            else global_settings.twitter_url,
            "instagram_url": self.instagram_url
            if self.instagram_url
            else global_settings.instagram_url,
            "linkedin_url": self.linkedin_url
            if self.linkedin_url
            else global_settings.linkedin_url,
            "youtube_url": self.youtube_url
            if self.youtube_url
            else global_settings.youtube_url,
            "business_number_title": self.business_number_title
            if self.business_number_title
            else None,
            "business_number_value": self.business_number_value
            if self.business_number_value
            else None,
            "business_logo1": self.logo1 if self.logo1 else None,
            "business_logo2": self.logo2 if self.logo2 else None,
            "business_logo1_url": self.logo1_url if self.logo1_url else None,
            "business_logo2_url": self.logo2_url if self.logo2_url else None,
            "contact_director_name": self.contact_director_name
            if self.contact_director_name
            else None,
            "contact_director_title": self.contact_director_title
            if self.contact_director_title
            else None,
            "contact_address": self.contact_address if self.contact_address else None,
            "contact_phone": self.contact_phone if self.contact_phone else None,
            "contact_email": self.contact_email if self.contact_email else None,
            "contact_show_program_offices": self.contact_show_program_offices
            if self.contact_show_program_offices
            else False,
            "footer_subscribe_title": self.footer_subscribe_title
            if self.footer_subscribe_title
            else global_settings.footer_subscribe_title,
            "shop_page_url": self.shop_page if self.shop_page else None,
            "shop_page_title": self.shop_page_title if self.shop_page_title else None,
            "privacy_page_url": self.privacy_page.url
            if self.privacy_page
            else global_settings.privacy_page.url
            if global_settings.privacy_page
            else None,
            "privacy_page_title": self.privacy_page.title
            if self.privacy_page
            else global_settings.privacy_page.title
            if global_settings.privacy_page
            else None,
            "terms_page_url": self.terms_page.url
            if self.terms_page
            else global_settings.terms_page.url
            if global_settings.terms_page
            else None,
            "terms_page_title": self.terms_page.title
            if self.terms_page
            else global_settings.terms_page.title
            if global_settings.terms_page
            else None,
            "faq_page_url": self.faq_page.url
            if self.faq_page
            else global_settings.faq_page.url
            if global_settings.faq_page
            else None,
            "faq_page_title": self.faq_page.title
            if self.faq_page
            else global_settings.faq_page.title
            if global_settings.faq_page
            else None,
            "contact_page_url": self.contact_page.url
            if self.contact_page
            else global_settings.contact_page.url
            if global_settings.contact_page
            else None,
            "contact_page_title": self.contact_page.title
            if self.contact_page
            else global_settings.contact_page.title
            if global_settings.contact_page
            else None,
            "search_page_url": global_settings.search_page.url
            if global_settings.search_page
            else None,
            "resources_page_url": self.resources_page.url
            if self.resources_page
            else None,
            "resources_page_title": self.resources_page.title
            if self.resources_page
            else None,
            "more_ways_to_give_page_url": self.more_ways_to_give_page.url
            if self.more_ways_to_give_page
            else None,
            "more_ways_to_give_page_title": self.more_ways_to_give_page.title
            if self.more_ways_to_give_page
            else None,
            "more_ways_to_give_page": self.more_ways_to_give_page
            if self.more_ways_to_give_page
            else None,
            "careers_page": self.careers_page if self.careers_page else None,
            "media_center_page": self.media_center_page
            if self.media_center_page
            else None,
            "campaign_page": self.campaign_page if self.campaign_page else None,
            "we_rise_page": self.we_rise_page if self.we_rise_page else None,
            "footer_accessibility_url": self.footer_accessibility_url
            if self.footer_accessibility_url
            else None,
            "footer_accessibility_title": self.footer_accessibility_title
            if self.footer_accessibility_title
            else None,
            "fundraise_page_url": self.fundraise_page.url
            if self.fundraise_page
            else None,
            "fundraise_page_title": self.fundraise_page.title
            if self.fundraise_page
            else None,
            # generic bottom cta
            "generic_bottom_cta_title": self.generic_bottom_cta_title
            if self.generic_bottom_cta_title
            else None,
            "generic_bottom_cta_body": self.generic_bottom_cta_body
            if self.generic_bottom_cta_body
            else None,
            "generic_bottom_cta_button_text": self.generic_bottom_cta_button_text
            if self.generic_bottom_cta_button_text
            else None,
            "generic_bottom_cta_button_page": self.generic_bottom_cta_button_page
            if self.generic_bottom_cta_button_page
            else None,
            "generic_bottom_cta_button_url": self.generic_bottom_cta_button_url
            if self.generic_bottom_cta_button_url
            else None,
            "cookie_text": self.cookie_text
            if self.cookie_text
            else global_settings.cookie_text,
            "cookie_agree_text": self.cookie_agree_text
            if self.cookie_agree_text
            else global_settings.cookie_agree_text,
            # homepage overrides
            "top_carousel_type": self.top_carousel_type
            if self.top_carousel_type is not "default"
            else None,
            "top_carousel_image": self.top_carousel_image
            if self.top_carousel_image
            else None,
            "top_carousel_title": self.top_carousel_title
            if self.top_carousel_title
            else None,
            "top_carousel_button_page": self.top_carousel_button_page
            if self.top_carousel_button_page
            else None,
            "top_carousel_button_text": self.top_carousel_button_text
            if self.top_carousel_button_text
            else None,
            "home_hide_top_carousel_text": self.home_hide_top_carousel_text,
            "home_hide_top_carousel_button": self.home_hide_top_carousel_button,
            "home_section_0_visible": self.home_section_0_visible,
            "home_section_0_title": self.home_section_0_title
            if self.home_section_0_title
            else None,
            "home_section_0_body": self.home_section_0_body
            if self.home_section_0_body
            else None,
            "home_section_0_body_mobile": self.home_section_0_body_mobile
            if self.home_section_0_body_mobile
            else None,
            "home_section_0_button_text": self.home_section_0_button_text
            if self.home_section_0_button_text
            else None,
            "home_section_0_button_url": self.home_section_0_button_url
            if self.home_section_0_button_url
            else None,
            "home_section_0_light_foreground": self.home_section_0_light_foreground
            if self.home_section_0_light_foreground != "none"
            else None,
            "home_section_0_text_align": self.home_section_0_text_align
            if self.home_section_0_text_align != "none"
            else None,
            "home_section_0_background_image": self.home_section_0_background_image
            if self.home_section_0_background_image
            else None,
            "home_section_0_button_url": self.home_section_0_button_url
            if self.home_section_0_button_url
            else None,
            "home_section_0_button_page": self.home_section_0_button_page
            if self.home_section_0_button_page
            else None,
            "home_section_1_title": self.home_section_1_title
            if self.home_section_1_title
            else None,
            "home_section_1_body": self.home_section_1_body
            if self.home_section_1_body
            else None,
            "home_section_1_body_mobile": self.home_section_1_body_mobile
            if self.home_section_1_body_mobile
            else None,
            "home_section_1_button_text": self.home_section_1_button_text
            if self.home_section_1_button_text
            else None,
            "home_section_1_button_url": self.home_section_1_button_url
            if self.home_section_1_button_url
            else None,
            "home_section_1_light_foreground": self.home_section_1_light_foreground
            if self.home_section_1_light_foreground != "none"
            else None,
            "home_section_1_text_align": self.home_section_1_text_align
            if self.home_section_1_text_align != "none"
            else None,
            "home_section_1_background_image": self.home_section_1_background_image
            if self.home_section_1_background_image
            else None,
            "home_section_1_button_url": self.home_section_1_button_url
            if self.home_section_1_button_url
            else None,
            "home_section_1_button_page": self.home_section_1_button_page
            if self.home_section_1_button_page
            else None,
            "home_section_2_title": self.home_section_2_title
            if self.home_section_2_title
            else None,
            "home_section_2_body": self.home_section_2_body
            if self.home_section_2_body
            else None,
            "home_section_2_body_mobile": self.home_section_2_body_mobile
            if self.home_section_2_body_mobile
            else None,
            "home_section_2_button_text": self.home_section_2_button_text
            if self.home_section_2_button_text
            else None,
            "home_section_2_button_url": self.home_section_2_button_url
            if self.home_section_2_button_url
            else None,
            "home_section_2_light_foreground": self.home_section_2_light_foreground
            if self.home_section_2_light_foreground != "none"
            else None,
            "home_section_2_text_align": self.home_section_2_text_align
            if self.home_section_2_text_align != "none"
            else None,
            "home_section_2_background_image": self.home_section_2_background_image
            if self.home_section_2_background_image
            else None,
            "home_section_2_button_url": self.home_section_2_button_url
            if self.home_section_2_button_url
            else None,
            "home_section_2_button_page": self.home_section_2_button_page
            if self.home_section_2_button_page
            else None,
            "home_section_3_title": self.home_section_3_title
            if self.home_section_3_title
            else None,
            "home_section_3_body": self.home_section_3_body
            if self.home_section_3_body
            else None,
            "home_section_3_body_mobile": self.home_section_3_body_mobile
            if self.home_section_3_body_mobile
            else None,
            "home_section_3_button_text": self.home_section_3_button_text
            if self.home_section_3_button_text
            else None,
            "home_section_3_button_url": self.home_section_3_button_url
            if self.home_section_3_button_url
            else None,
            "home_section_3_light_foreground": self.home_section_3_light_foreground
            if self.home_section_3_light_foreground != "none"
            else None,
            "home_section_3_text_align": self.home_section_3_text_align
            if self.home_section_3_text_align != "none"
            else None,
            "home_section_3_background_image": self.home_section_3_background_image
            if self.home_section_3_background_image
            else None,
            "home_section_3_button_url": self.home_section_3_button_url
            if self.home_section_3_button_url
            else None,
            "home_section_3_button_page": self.home_section_3_button_page
            if self.home_section_3_button_page
            else None,
            "home_section_4_title": self.home_section_4_title
            if self.home_section_4_title
            else None,
            "home_section_4_body": self.home_section_4_body
            if self.home_section_4_body
            else None,
            "home_section_4_article": self.home_section_4_article
            if self.home_section_4_article
            else None,
            "home_section_4_button_text": self.home_section_4_button_text
            if self.home_section_4_button_text
            else None,
            "home_section_4_light_foreground": self.home_section_4_light_foreground
            if self.home_section_4_light_foreground
            else None,
            "home_section_4_text_align": self.home_section_4_text_align
            if self.home_section_4_text_align
            else None,
            "home_section_4_image_override": self.home_section_4_image_override
            if self.home_section_4_image_override
            else None,
            "home_featured_article_1": self.home_featured_article_1
            if self.home_featured_article_1
            else None,
            "home_featured_article_2": self.home_featured_article_2
            if self.home_featured_article_2
            else None,
            "home_featured_article_3": self.home_featured_article_3
            if self.home_featured_article_3
            else None,
            "home_bottom_cta_title": self.home_bottom_cta_title
            if self.home_bottom_cta_title
            else None,
            "home_bottom_cta_button_text": self.home_bottom_cta_button_text
            if self.home_bottom_cta_button_text
            else None,
            "home_bottom_cta_body": self.home_bottom_cta_body
            if self.home_bottom_cta_body
            else None,
            "home_bottom_cta_button_page": self.home_bottom_cta_button_page
            if self.home_bottom_cta_button_page
            else None,
            "home_bottom_cta_button_url": self.home_bottom_cta_button_url
            if self.home_bottom_cta_button_url
            else None,
            "impact_featured_article": self.impact_featured_article
            if self.impact_featured_article
            else None,
            "impact_featured_article_heading": self.impact_featured_article_heading
            if self.impact_featured_article_heading
            else None,
            "impact_featured_article_title": self.impact_featured_article_title
            if self.impact_featured_article_title
            else None,
            "impact_featured_article_button_text": self.impact_featured_article_button_text
            if self.impact_featured_article_button_text
            else None,
            "impact_featured_article_excerpt": self.impact_featured_article_excerpt
            if self.impact_featured_article_excerpt
            else None,
            "show_fundraise_inspiration_section": self.show_fundraise_inspiration_section,
            "featured_event": self.featured_event if self.featured_event else None,
            "featured_news": self.featured_news if self.featured_news else None,
            "featured_story": self.featured_story if self.featured_story else None,
            "share_twitter_handle": self.share_twitter_handle
            if self.share_twitter_handle
            else global_settings.share_twitter_handle
            if global_settings.share_twitter_handle
            else None,
            "share_image": self.share_image
            if self.share_image
            else global_settings.share_image
            if global_settings.share_image
            else None,
            "share_description": self.share_description
            if self.share_description
            else global_settings.share_description
            if global_settings.share_description
            else None,
            "facebook_pixel": self.facebook_pixel,
        }

        return data

This is the code block in the wagtail 2.16 update that is causing my issues. It is trying to access a instance variable from the site root path but the get_site_root_paths() method is returning a list of site root paths causing the error

def _get_relevant_site_root_paths(self, cache_object=None):
        """
        .. versionadded::2.16
        Returns a tuple of root paths for all sites this page belongs to.
        """
        return tuple(
            srp
            for srp in self._get_site_root_paths(cache_object)
            if self.url_path.startswith(srp.root_path)
        )


来源: stackexchange

问:
Error while executing query for Postgresql from Qt C++
I want to enter enter data from vector of objects into Postgresql table but it's not working. I establish connection to the database successfully, but the output returns an error -

```<code>QSqlError("42601", "QPSQL: Unable to create query", "ERROR:  syntax error at end of input\nLINE 1: EXECUTE \n
</code>```

My Code -

```<code>void MainWindow::WriteToDatabase()
{
//  Establishing a connection to MySQL
    database = QSqlDatabase::addDatabase("QPSQL");

    database.setHostName("localhost");
    database.setUserName("postgres");
    database.setPassword("1234");
    database.setDatabaseName("nz5_flightdatar");

    bool test = QSqlDatabase::isDriverAvailable("QPSQL");
    qDebug() << test << Qt::endl;

    if(database.open())
    {
        sort(FlightList.begin(), FlightList.end());

        vector<FlightData>::iterator itr;

        ui->plainTextEdit->clear();
        for (itr = FlightList.begin(); itr != FlightList.end(); itr++)
        {
            static int i = 0;
            QString Time = QString::fromStdString(FlightList[i].getTime());
            double Latitude = FlightList[i].getLatitude();
            double Longitude = FlightList[i].getLongitude();
            int Course = FlightList[i].getCourse();
            int KTS = FlightList[i].getKTS();
            int MPH = FlightList[i].getMPH();
            int AltitudeFeet = FlightList[i].getAltitudeFeet();
            QString ReportingFacility = QString::fromStdString(FlightList[i].getReportingFacility());
            i++;

            QSqlQuery query;

            query.prepare("INSERT INTO 'public.flight_data' (Time, Latitude, Longitude, Course, KTS, MPH, AltitudeFeet, ReportingFacility)"
                          "VALUES (':time', ':latitude', ':longitude', ':course', ':kts', ':mph', ':altitudefeet', ':reportingfacility')");

            query.bindValue(":time", Time);
            query.bindValue(":latitude", Latitude);
            query.bindValue(":longitude", Longitude);
            query.bindValue(":course", Course);
            query.bindValue(":kts", KTS);
            query.bindValue(":mph", MPH);
            query.bindValue(":altitudefeet", AltitudeFeet);
            query.bindValue(":reportingfacility", ReportingFacility);

            if(query.exec())
                qDebug() << "success";
            else
            {
                QMessageBox::information(this, "error", "No success");
                qDebug() << query.lastError();
                exit(0);
            }
        }

        ui->statusbar->showMessage("Writing data to Database successful", 4000);

    }

    else
    {
        QMessageBox::warning(this, "Not connected", "Unable to connect to Database");
    }

}
</code>```

and the output -

```<code>qt.core.plugin.loader: In C:/Qt_Framework/6.4.1/mingw_64/plugins/sqldrivers/qsqlmysqld.dll:
  Plugin uses incompatible Qt library (5.13.0) [debug]
true

QSqlError("42601", "QPSQL: Unable to create query", "ERROR:  syntax error at end of input\nLINE 1: EXECUTE \n                ^\n(42601)")
</code>```

I am familiar with MySQL but I went crazy today trying to install drivers but failed miserably (read document and also a lot of StackOverflow threads), so I switched to Postgresql as Qt supports QPSQL.
Kindly help if you can.

ContentLicense: CC BY-SA 4.0

Body:
I want to enter enter data from vector of objects into Postgresql table but it's not working. I establish connection to the database successfully, but the output returns an error -

QSqlError("42601", "QPSQL: Unable to create query", "ERROR:  syntax error at end of input\nLINE 1: EXECUTE \n

My Code -

void MainWindow::WriteToDatabase()
{
//  Establishing a connection to MySQL
    database = QSqlDatabase::addDatabase("QPSQL");

    database.setHostName("localhost");
    database.setUserName("postgres");
    database.setPassword("1234");
    database.setDatabaseName("nz5_flightdatar");

    bool test = QSqlDatabase::isDriverAvailable("QPSQL");
    qDebug() << test << Qt::endl;

    if(database.open())
    {
        sort(FlightList.begin(), FlightList.end());

        vector<FlightData>::iterator itr;

        ui->plainTextEdit->clear();
        for (itr = FlightList.begin(); itr != FlightList.end(); itr++)
        {
            static int i = 0;
            QString Time = QString::fromStdString(FlightList[i].getTime());
            double Latitude = FlightList[i].getLatitude();
            double Longitude = FlightList[i].getLongitude();
            int Course = FlightList[i].getCourse();
            int KTS = FlightList[i].getKTS();
            int MPH = FlightList[i].getMPH();
            int AltitudeFeet = FlightList[i].getAltitudeFeet();
            QString ReportingFacility = QString::fromStdString(FlightList[i].getReportingFacility());
            i++;

            QSqlQuery query;

            query.prepare("INSERT INTO 'public.flight_data' (Time, Latitude, Longitude, Course, KTS, MPH, AltitudeFeet, ReportingFacility)"
                          "VALUES (':time', ':latitude', ':longitude', ':course', ':kts', ':mph', ':altitudefeet', ':reportingfacility')");

            query.bindValue(":time", Time);
            query.bindValue(":latitude", Latitude);
            query.bindValue(":longitude", Longitude);
            query.bindValue(":course", Course);
            query.bindValue(":kts", KTS);
            query.bindValue(":mph", MPH);
            query.bindValue(":altitudefeet", AltitudeFeet);
            query.bindValue(":reportingfacility", ReportingFacility);

            if(query.exec())
                qDebug() << "success";
            else
            {
                QMessageBox::information(this, "error", "No success");
                qDebug() << query.lastError();
                exit(0);
            }
        }

        ui->statusbar->showMessage("Writing data to Database successful", 4000);

    }

    else
    {
        QMessageBox::warning(this, "Not connected", "Unable to connect to Database");
    }

}

and the output -

qt.core.plugin.loader: In C:/Qt_Framework/6.4.1/mingw_64/plugins/sqldrivers/qsqlmysqld.dll:
  Plugin uses incompatible Qt library (5.13.0) [debug]
true

QSqlError("42601", "QPSQL: Unable to create query", "ERROR:  syntax error at end of input\nLINE 1: EXECUTE \n                ^\n(42601)")

I am familiar with MySQL but I went crazy today trying to install drivers but failed miserably (read document and also a lot of StackOverflow threads), so I switched to Postgresql as Qt supports QPSQL.
Kindly help if you can.


问:
Kubernetes | On-Premise (Hyper-V) | MetalB | Cannot access PODs by External IP (came from MetalB)
I trying to setup a local environment with Hyper-V, Kubernetes and MetalB
And has issue (i think its something small and classic issue, but after deep research I still not understand where is my mistake)

So setup is following:

Host machine
- IP: 172.16.0.148

Hyper-V configuration:

Network switch:

Name: K8S

Type: External (in order to reach internet -- if this is problem?)

Machines

Machine 1 (Master)

Name K8S-Master

IP: 172.16.0.171

Machine 2 (Slave)

Name K8S-Slave-01

IP: 172.16.0.172

Machine 3 (Slave)

Name K8S-Slave-02

IP: 172.16.0.173

Machine 4 (DevOps)

*** THIS MACHINE NOT joint to K8S cluster)

Name DevOps_Lab

IP: 172.16.0.174

Kubernetes configuration
-

Version:

Client Version: version.Info{Major:"1", Minor:"25",
GitVersion:"v1.25.4",
GitCommit:"872a965c6c6526caa949f0c6ac028ef7aff3fb78",
GitTreeState:"clean", BuildDate:"2022-11-09T13:36:36Z",
GoVersion:"go1.19.3", Compiler:"gc", Platform:"linux/amd64"}
Kustomize Version: v4.5.7

Server Version: version.Info{Major:"1",
Minor:"25", GitVersion:"v1.25.4",
GitCommit:"872a965c6c6526caa949f0c6ac028ef7aff3fb78",
GitTreeState:"clean", BuildDate:"2022-11-09T13:29:58Z",
GoVersion:"go1.19.3", Compiler:"gc", Platform:"linux/amd64"}

Network CIDR:
10.244.0.0/24

Network CNI: Flannel

MetalB configuration:

Version: 0.13.7

Configuration

addresses:

172.16.0.180-172.16.0.185

Now I have application and LoadBalancer service for this app.
THe load balancer service got external IP: 172.16.0.183 (provided by MetalB)

If I run CURL command on master/slave machines - everything works as a charm
But If I running same curl command on DevOps_Lab machine or from host machine - then I cannot reach this service

I tried to change Ip forwarding settings on the master node - it doenst fix the issue

So I have 2 main questions:

Why I cannot access the app by load balancer ip outside cluster ?

I would like to learn more in deep everything related to ON-Premise kubernetes and networking - if you can point me to goot articles it will be great.

Thanks


问:
Is it possible to execute several filters in parallel in Envoy
Question:
Is it possible for envoy, during request processing to execute several filters at once and then combine its result in a third filter?

Looking at the thread model from the documentation I believe the answer is no

Once a connection is accepted by a listener, the connection spends the rest of its lifetime bound to a single worker thread.

Background:
I am trying to achieve such behaviour when envoy as an ingress gateway might call several different services (auth service, throttler, some other external service) during single request processing and then use information received from all those services in routing. Also, due to the nature of the requests they could be executed in parallel.

An option to achieve it outside of envoy is to make envoy call single service, and then make this single service all needed parallel calls and then return single aggregated response to envoy.

Is it possible to make it without external aggregator service? May be with lua or wasm scripts?


问:
Suggestions for python function optimization
I have the following function

```<code>def average_over_neighbours(
    distances: npt.NDArray[np.float32],
    velocities: npt.NDArray[np.float32],
    n_neighbours: int = 3,
    weights: npt.NDArray[np.float32] = np.array([]),
) -> tuple[int, npt.NDArray[np.float32]]:

    in_range = distances < search_range
    neighbours: npt.NDArray[np.int32] = np.nonzero(in_range)[0][
        distances[in_range].argsort(kind="mergesort")
    ][:n_neighbours]

    if neighbours.size == 0:
        return 0, np.array([0.0, 0.0])

    velocities = velocities[neighbours]
    weights = weights[neighbours] if weights.size != 0 else None
    average_velocity: npt.NDArray[np.float32] = np.average(
        velocities, weights=weights, axis=0
    )
    return len(neighbours), average_velocity
</code>```

that I need to call many times inside of a for loop

```<code>for point in my_points:
    average_over_neighbours(distances, velocities)
</code>```

This results in a very slow performance.
I am wondering if there is something particularly slow in this specific function, or if the issue is just the fact that I am calling it many (thousands of) times.
Given the function overhead in python, would rewriting the function such that the loop is inside the function rather than calling it multiple time give a considerable improvement? I tried to do this quickly but did not see a big difference.
I am a bit hesitant to do so, because I am worried it would impact the clarity of the code, but I can't think of other solutions.

Body:
I have the following function

def average_over_neighbours(
    distances: npt.NDArray[np.float32],
    velocities: npt.NDArray[np.float32],
    n_neighbours: int = 3,
    weights: npt.NDArray[np.float32] = np.array([]),
) -> tuple[int, npt.NDArray[np.float32]]:

    in_range = distances < search_range
    neighbours: npt.NDArray[np.int32] = np.nonzero(in_range)[0][
        distances[in_range].argsort(kind="mergesort")
    ][:n_neighbours]

    if neighbours.size == 0:
        return 0, np.array([0.0, 0.0])

    velocities = velocities[neighbours]
    weights = weights[neighbours] if weights.size != 0 else None
    average_velocity: npt.NDArray[np.float32] = np.average(
        velocities, weights=weights, axis=0
    )
    return len(neighbours), average_velocity

that I need to call many times inside of a for loop

for point in my_points:
    average_over_neighbours(distances, velocities)

This results in a very slow performance.
I am wondering if there is something particularly slow in this specific function, or if the issue is just the fact that I am calling it many (thousands of) times.
Given the function overhead in python, would rewriting the function such that the loop is inside the function rather than calling it multiple time give a considerable improvement? I tried to do this quickly but did not see a big difference.
I am a bit hesitant to do so, because I am worried it would impact the clarity of the code, but I can't think of other solutions.


问:
Run-time error '-2147023179 (800706b5)' - Automation error; The interface is unknown
I've been trying to scrape the data from an interactive table but it's giving me this error:
Run-time error '-2147023179 (800706b5)'
Automation error
The interface is unknown.

Here is the code:

```<code>Sub test()
'Load page in IE'
Dim IE As InternetExplorerMedium
Dim objCollection As Object

'Create InternetExplorer Object'
Set IE = New InternetExplorerMedium
'CreateObject("InternetExplorer.Application")'

'Make IE visible'
IE.Visible = True

'Define URL'
URL = "URL"

'Navigate to URL'
IE.Navigate URL

' Statusbar let's user know website is loading
Application.StatusBar = URL & " is loading. Please wait..."

' Wait while IE loading...
'IE ReadyState = 4 signifies the webpage has loaded (the first loop is set to avoid inadvertently skipping over the second loop)
Do While IE.ReadyState = 4: DoEvents: Loop   'Do While
Do Until IE.ReadyState = 4: DoEvents: Loop   'Do Until

'Webpage Loaded
Application.StatusBar = URL & " Loaded"

Set IE = Nothing
Set objCollection = Nothing

'Scrape data'
Set objCollection = IE.Document.getElementsByTagName("table")

End Sub

</code>```

What am I missing here?

Body:
I've been trying to scrape the data from an interactive table but it's giving me this error:
Run-time error '-2147023179 (800706b5)'
Automation error
The interface is unknown.

Here is the code:

Sub test()
'Load page in IE'
Dim IE As InternetExplorerMedium
Dim objCollection As Object

'Create InternetExplorer Object'
Set IE = New InternetExplorerMedium
'CreateObject("InternetExplorer.Application")'

'Make IE visible'
IE.Visible = True

'Define URL'
URL = "URL"

'Navigate to URL'
IE.Navigate URL

' Statusbar let's user know website is loading
Application.StatusBar = URL & " is loading. Please wait..."

' Wait while IE loading...
'IE ReadyState = 4 signifies the webpage has loaded (the first loop is set to avoid inadvertently skipping over the second loop)
Do While IE.ReadyState = 4: DoEvents: Loop   'Do While
Do Until IE.ReadyState = 4: DoEvents: Loop   'Do Until

'Webpage Loaded
Application.StatusBar = URL & " Loaded"

Set IE = Nothing
Set objCollection = Nothing

'Scrape data'
Set objCollection = IE.Document.getElementsByTagName("table")

End Sub

What am I missing here?


问:
Enum as generic type on ComponentPropsWithoutRef returning "never"
I'm trying to get a type for a custom component receiving a value from an enum, for some reason the code is not matching IntrinsicElements[T] with HtmlTag.a.
The code below is a simplified version of react internal types, already tested with casting, but I'm not able to do it since my component requires a generic type to specify with HTML tag is it, so I need to figure out how

repro on this link with ts playground

```<code>enum HtmlTag {
  div = 'div',
  a = 'a',
  h1 = 'h1',
  h2 = 'h2',
  h3 = 'h3',
  h4 = 'h4',
  h5 = 'h5',
  h6 = 'h6',
  p = 'p',
  span = 'span'
}

  interface IntrinsicElements {
    a: React.DetailedHTMLProps<React.AnchorHTMLAttributes<HTMLAnchorElement>, HTMLAnchorElement>
  }

  type ComponentProps<T extends keyof IntrinsicElements> =
    T extends keyof IntrinsicElements
      ? IntrinsicElements[T]
      : {};
  //Gets 'never' as type
  type whyNever = ComponentProps<HtmlTag.a>;

  //Works good
  type works = IntrinsicElements[HtmlTag.a]
</code>```

I'm having this issue while I'm trying to do the code below, ComponentPropsWithoutRef when receive T, which is my HtmlTag param is getting stuck and retrieving "never", and then I came into the issue above with the repro link.
I didn't follow how TS is not matching IntrinsicElements with HtmlTag when doing IntrinsicElements[T] since it works good when I do IntrinsicElements[HtmlTag.a]

```<code>export type PolymorphicComponentProp<
  C extends React.ElementType,
  Props = {}
> = React.PropsWithChildren<Props & PolymorphicElement<C>> &
  Omit<React.ComponentPropsWithoutRef<C>, PropsToOmit<C, Props>>;
</code>```

Body:
I'm trying to get a type for a custom component receiving a value from an enum, for some reason the code is not matching IntrinsicElements[T] with HtmlTag.a.
The code below is a simplified version of react internal types, already tested with casting, but I'm not able to do it since my component requires a generic type to specify with HTML tag is it, so I need to figure out how

repro on this <a href="https://www.typescriptlang.org/play?noImplicitAny=false&strictNullChecks=false&strictFunctionTypes=false&strictPropertyInitialization=false&strictBindCallApply=false&noImplicitThis=false&noImplicitReturns=false&alwaysStrict=false&experimentalDecorators=false&emitDecoratorMetadata=false&target=1&jsx=1&allowSyntheticDefaultImports=true&noFallthroughCasesInSwitch=true&isolatedModules=true&ts=4.6.4&ssl=27&ssc=44&pln=3&pc=1#code/JYWwDg9gTgLgBAJQKYEMDG8BmUIjgcilQ3wG4AocpAOwFc8AJGEAGwBUUBzOAb3LjgATYADc4AXgLCR%20ADT84KCQRRyFACwCMy-FrUD1AJh1H9cdQGYTFs%20oAsJu7YCsJ57YBsJj2bA6wZgDOYCjUOsGh%20OQAvpQCwNQwSFCY6EhwAJKJUAmBwGgAoixIIDQwgbwKAigAXIjEMAB0ACJIMCjAxYIMbACyADIACjhggQA8yOhNAILUaOrQPQPTMDA5AEa0SeNL-bPz0EUlZQB8snC7%20wtQR6WJJwqxCjAAnmDpAMK4kNRlwxCjMZsOBIAAeSWoggqAGskC8IJhMtlcvlbmVAicJFU4MCwRCoXBYfDEVk1ijCsU7uVsQIAPxIsnUPIU46JQIAbTYAF0aXA6jxohRnm90gB3dQvABySBEyWUX3AEF%20iX%20gKYrA4nEaKBOQoEr3ecFF0GhFUkpJyTNRlPR7PV7C42q5QA" rel="nofollow noreferrer">link with ts playground

enum HtmlTag {
  div = 'div',
  a = 'a',
  h1 = 'h1',
  h2 = 'h2',
  h3 = 'h3',
  h4 = 'h4',
  h5 = 'h5',
  h6 = 'h6',
  p = 'p',
  span = 'span'
}

  interface IntrinsicElements {
    a: React.DetailedHTMLProps<React.AnchorHTMLAttributes<HTMLAnchorElement>, HTMLAnchorElement>
  }

  type ComponentProps<T extends keyof IntrinsicElements> =
    T extends keyof IntrinsicElements
      ? IntrinsicElements[T]
      : {};
  //Gets 'never' as type
  type whyNever = ComponentProps<HtmlTag.a>;

  //Works good
  type works = IntrinsicElements[HtmlTag.a]

I'm having this issue while I'm trying to do the code below, ComponentPropsWithoutRef when receive T, which is my HtmlTag param is getting stuck and retrieving "never", and then I came into the issue above with the repro link.
I didn't follow how TS is not matching IntrinsicElements with HtmlTag when doing IntrinsicElements[T] since it works good when I do IntrinsicElements[HtmlTag.a]

export type PolymorphicComponentProp<
  C extends React.ElementType,
  Props = {}
> = React.PropsWithChildren<Props & PolymorphicElement<C>> &
  Omit<React.ComponentPropsWithoutRef<C>, PropsToOmit<C, Props>>;


问:
SwiftUI: Unable to resize image on a Picker menu on macOS 13
My images are not resized in a SwiftUI Picker on macOS 13.0.

```<code>Picker("", selection: $selectedItemId) {
  HStack {
    Image("icon-descriptor-country").resizable().frame(width: 16.0, height: 16.0)
    Text("Country...")
  }
}
.pickerStyle(.menu)
</code>```

The images are not resized:

I also tested a label, instead of the HStack.
Same thing.

Any idea is welcome... or it's purely a macos SwiftUI issue.

EDIT: after new tests, it seems to work with a systemImage BUT NOT with any assets image (png or svg)

Body:
My images are not resized in a SwiftUI Picker on macOS 13.0.

Picker("", selection: $selectedItemId) {
  HStack {
    Image("icon-descriptor-country").resizable().frame(width: 16.0, height: 16.0)
    Text("Country...")
  }
}
.pickerStyle(.menu)

The images are not resized:

I also tested a label, instead of the HStack.
Same thing.

Any idea is welcome... or it's purely a macos SwiftUI issue.

EDIT: after new tests, it seems to work with a systemImage BUT NOT with any assets image (png or svg)


问:
socket.io or innerHTML not functioning
Aim: To make the bundle sent to server show up in all clients currently connected to the port.

Server-side NodeJS code:

const http = require("http");
const host = 'localhost';
const port = 8000;
const express = require('express');
const app = express();
app.use(express.static('./'));
const socketIO = require("socket.io");

// creating the server and starting it on port 8000
app.get('/', (req, res)=>{
    res.sendFile(path.join(__dirname, 'public', 'index.html'))
})
const server = http.createServer(app);
server.listen(port, host, () => {
    console.log(`Server is running on http://${host}:${port}`);
});

// making io object
const io = socketIO(server, {cookie: false});

// listening to connections to the server
io.on('connection', (socket) => {
    // chat message coming to server

    socket.on("chatMessage", (chatBundle) => {
        socket.emit("toClient", chatBundle)
    });
});
```
<p>Client-side HTML code:</p>
<pre class="lang-html prettyprint-override"><code><!DOCTYPE html>
<html>
    <body>
        <h1>CHAT ROOM</h1>
        <form onsubmit="return sendServer()">
            <label for="name">Name:
                <input id="name" name="name" type="text">
            </label>

            <label for="text">Message:
                <input id="text" name="text" type="text">
            </label>

            <input type="submit" id="send">
        </form>
        <script src="/socket.io/socket.io.js">
        </script>
        <script>
            const socket = io(); // added
            function sendServer(){
                var sender = document.getElementById("name").value;
                var text = document.getElementById("text").value;
                var tempArray = [sender, text]
                socket.emit("chatMessage", tempArray)
                return false; // added
            };
            socket.on("toClient", (bundleBack) => {
                var tempObject = document.createElement("p")
                tempObject.innerHTML = bundleBack[0] + ": " + bundleBack[1]
            });
        </script>

    </body>
</html>
</code>```

Where is the bundle going wrong? Is there a problem with the double nested socket functions in js? Or is it a problem with the innerHTML I'm using in the HTML?

Title: socket.io or innerHTML not functioning

Body:
Aim: To make the bundle sent to server show up in all clients currently connected to the port.

Server-side NodeJS code:

const http = require("http");
const host = 'localhost';
const port = 8000;
const express = require('express');
const app = express();
app.use(express.static('./'));
const socketIO = require("socket.io");

// creating the server and starting it on port 8000
app.get('/', (req, res)=>{
    res.sendFile(path.join(__dirname, 'public', 'index.html'))
})
const server = http.createServer(app);
server.listen(port, host, () => {
    console.log(`Server is running on http://${host}:${port}`);
});

// making io object
const io = socketIO(server, {cookie: false});

// listening to connections to the server
io.on('connection', (socket) => {
    // chat message coming to server

    socket.on("chatMessage", (chatBundle) => {
        socket.emit("toClient", chatBundle)
    });
});

Client-side HTML code:

<!DOCTYPE html>

CHAT ROOM

        <form onsubmit="return sendServer()">
            Name:
                <input id="name" name="name" type="text">

            Message:
                <input id="text" name="text" type="text">

            <input type="submit" id="send">
        </form>

Where is the bundle going wrong? Is there a problem with the double nested socket functions in js? Or is it a problem with the innerHTML I'm using in the HTML?


问:
Calling Azure Oauth 2.0 Endpoint doesn't return
With the deprecation of basic authentication for Microsoft Exchange, I have undergone the process of switching to ModernAuthentication.

I found this you tube video

and went through the steps. It all seemed to work and I could get a token via postman and through code. Now however when I deploy my application, that call to get my token just never returns and it appears to be stuck. Below is in an image of PostMan and the URL/what I'm posting

The only thing I can think that is different is the context of who the application is running against...myself locally and the app pool user when deployed.

What in the world could be the problem of why I'm getting a token via postman and running my code locally, but not deployed


问:
How can I call functions inside a class that is from a dynamic library in C++?
I'm trying to make an SDK for my game engine, similar to the Half-Life SDK Valve has created for Goldsrc. I want to create an SDK so people can modify the game code of my game engine, but I don't have an idea on how to do this.

If somebody somehow knows how Valve does it, that would be excellent, but it's unlikely since Goldsrc it's not open source.

I have tried loading the class via the Class Interface way, where an inherited class is created thanks to the parent class that is being used as an interface, but the thing is, it only just creates the class, but there's no way to modify the variables inside this class, because the engine itself only knows about the parent class, which is the interface, and I don't think it's convenient to create an interface class for each class, that would just be 2 classes per entity.

Let me show you an example:

Right now I'm working on the client dynamic library, and I'm trying to make the game engine load a class called Text, with the ability to have its text changed

This is the code I have right now:

client_dll.cpp (client.dll)

```<code>template <class T> CLIENT_API UI_Element* CreateUI(){
    return new T();
}

#define CREATE_UI(x) \
    void create_ui() { CreateUI<x>(); }

void Text::SetText(std::string changeText)
{
    text = changeText;
}

void Text::Initialize()
{
    TTF_Font *font;
    SDL_Rect text_position;

    font = TTF_OpenFont("C:\\WINDOWS\\FONTS\\VERDANA.TTF", 20);
    if(!font) {
        printf("TTF_OpenFont: %s\n", TTF_GetError());
    }
    text_position.x = 0;
    text_position.y = 480-30;
    RenderText(text.c_str(), font, WHITE, &text_position);
}

CREATE_UI(Text)
</code>```

client_dll.h (client.dll)

```<code>#include <string>

#ifndef CLIENT_DLL_H
#define CLIENT_DLL_H

#define CLIENT_API __declspec( dllexport )

class UI_Element
{
public:
    virtual void Initialize() { return; };
};

class Text : public UI_Element
{
public:
    void SetText(std::string changeText);
    void Initialize();
private:
    std::string text;
};

template <class T> CLIENT_API UI_Element* CreateUI();

typedef UI_Element* (*CREATE_UI)();

#endif // CLIENT_DLL_H
</code>```

main.cpp (engine.exe)

```<code>UI_Element* pText;

void draw_screen()
{
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
    glClearColor(0.000, 0.000, 0.545,1.0);
    glEnable(GL_TEXTURE_2D);

    glMatrixMode(GL_PROJECTION);
    glPushMatrix();
    glLoadIdentity();
    glOrtho(0, 640, 0, 480, -1.0, 1.0);

    //This is where the text goes
    glDisable(GL_DEPTH_TEST);
    glDisable(GL_LIGHTING);
    glDepthMask(GL_FALSE);

    pText->Initialize();

    SDL_GL_SwapBuffers();
}

int main(int argc, char* argv[])
{
    HINSTANCE hDLL = LoadLibrary("bin\\client.dll");
    if(NULL == hDLL){
        printf("LoadLibrary failed\n");
        return 1;
    }

    CREATE_UI pEntryFunction = (CREATE_UI)GetProcAddress(hDLL,"_Z8CreateUII4TextEP10UI_Elementv");
    if(pEntryFunction == NULL){
        printf("GetProcAddress failed\n");
        return 1;
    }

    pText = pEntryFunction();
}
</code>```

client_dll.h (engine.exe)

```<code>#ifndef CLIENT_DLL_H
#define CLIENT_DLL_H

#define CLIENT_API __declspec( dllimport )

class UI_Element
{
public:
    virtual void Initialize() { return; };
};

typedef UI_Element* (*CREATE_UI)();

#endif // CLIENT_DLL_H
</code>```

If I try to add pText->SetText("The text has changed"); inside draw_screen(), it's not going to work because I get error: 'class UI_Element' has no member named 'SetText' .

So how can I make my game engine dynamically call Text::SetText(std::string changeText) from UI_Element* pText or any new Text class that has been created?

I could try updating the header from the engine.exe, but the thing is, it's not going to detect the changes made in the client.dll, so I don't think this is the solution for it.

Also tried this method that I found, it's kinda what I want, but there's one problem, I'm required to use __asm { MOV ECX, ClassName } , which is a Visual Studio exclusive function, and I'm not using Visual Studio, but GCC, I tried my best to convert this into gcc asm, since I have no idea how to use GCC asm, the best I could was to compile succesfully, but then my program crashes.

For extra information: I'm using CodeBlocks with GCC, on Windows.

Body:
I'm trying to make an SDK for my game engine, similar to the Half-Life SDK Valve has created for Goldsrc. I want to create an SDK so people can modify the game code of my game engine, but I don't have an idea on how to do this.

If somebody somehow knows how Valve does it, that would be excellent, but it's unlikely since Goldsrc it's not open source.

I have tried loading the class via the Class Interface way, where an inherited class is created thanks to the parent class that is being used as an interface, but the thing is, it only just creates the class, but there's no way to modify the variables inside this class, because the engine itself only knows about the parent class, which is the interface, and I don't think it's convenient to create an interface class for each class, that would just be 2 classes per entity.

Let me show you an example:

Right now I'm working on the client dynamic library, and I'm trying to make the game engine load a class called Text, with the ability to have its text changed

This is the code I have right now:

client_dll.cpp (client.dll)

template <class T> CLIENT_API UI_Element* CreateUI(){
    return new T();
}

#define CREATE_UI(x) \
    void create_ui() { CreateUI<x>(); }

void Text::SetText(std::string changeText)
{
    text = changeText;
}

void Text::Initialize()
{
    TTF_Font *font;
    SDL_Rect text_position;

    font = TTF_OpenFont("C:\\WINDOWS\\FONTS\\VERDANA.TTF", 20);
    if(!font) {
        printf("TTF_OpenFont: %s\n", TTF_GetError());
    }
    text_position.x = 0;
    text_position.y = 480-30;
    RenderText(text.c_str(), font, WHITE, &text_position);
}

CREATE_UI(Text)

client_dll.h (client.dll)

#include <string>

#ifndef CLIENT_DLL_H
#define CLIENT_DLL_H

#define CLIENT_API __declspec( dllexport )

class UI_Element
{
public:
    virtual void Initialize() { return; };
};

class Text : public UI_Element
{
public:
    void SetText(std::string changeText);
    void Initialize();
private:
    std::string text;
};

template <class T> CLIENT_API UI_Element* CreateUI();

typedef UI_Element* (*CREATE_UI)();

#endif // CLIENT_DLL_H

main.cpp (engine.exe)

UI_Element* pText;

void draw_screen()
{
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
    glClearColor(0.000, 0.000, 0.545,1.0);
    glEnable(GL_TEXTURE_2D);

    glMatrixMode(GL_PROJECTION);
    glPushMatrix();
    glLoadIdentity();
    glOrtho(0, 640, 0, 480, -1.0, 1.0);

    //This is where the text goes
    glDisable(GL_DEPTH_TEST);
    glDisable(GL_LIGHTING);
    glDepthMask(GL_FALSE);

    pText->Initialize();

    SDL_GL_SwapBuffers();
}

int main(int argc, char* argv[])
{
    HINSTANCE hDLL = LoadLibrary("bin\\client.dll");
    if(NULL == hDLL){
        printf("LoadLibrary failed\n");
        return 1;
    }

    CREATE_UI pEntryFunction = (CREATE_UI)GetProcAddress(hDLL,"_Z8CreateUII4TextEP10UI_Elementv");
    if(pEntryFunction == NULL){
        printf("GetProcAddress failed\n");
        return 1;
    }

    pText = pEntryFunction();
}

client_dll.h (engine.exe)

#ifndef CLIENT_DLL_H
#define CLIENT_DLL_H

#define CLIENT_API __declspec( dllimport )

class UI_Element
{
public:
    virtual void Initialize() { return; };
};

typedef UI_Element* (*CREATE_UI)();

#endif // CLIENT_DLL_H

If I try to add pText->SetText("The text has changed"); inside draw_screen(), it's not going to work because I get error: 'class UI_Element' has no member named 'SetText' .

So how can I make my game engine dynamically call Text::SetText(std::string changeText) from UI_Element* pText or any new Text class that has been created?

I could try updating the header from the engine.exe, but the thing is, it's not going to detect the changes made in the client.dll, so I don't think this is the solution for it.

Also tried this method that I found, it's kinda what I want, but there's one problem, I'm required to use __asm { MOV ECX, ClassName } , which is a Visual Studio exclusive function, and I'm not using Visual Studio, but GCC, I tried my best to convert this into gcc asm, since I have no idea how to use GCC asm, the best I could was to compile succesfully, but then my program crashes.

For extra information: I'm using CodeBlocks with GCC, on Windows.


问:
react-native trpc always loading
I have tried using trpc with the fastify integration, and it works  fine.

However, when I tried using it in my react-native app, it does not work (it already worked with next.js) It only displays loading as a status.

const getBaseUrl = () => {
  const localhost = Constants.manifest?.debuggerHost?.split(":")[0];
  if (!localhost)
    throw new Error("failed to get localhost, configure it manually");
  return `http://${localhost}:3000/trpc`;
};

export const TRPCProvider: React.FC<{ children: React.ReactNode }> = ({
  children,
}) => {
  console.log(getBaseUrl())
  const [queryClient] = useState(() => new QueryClient());
  const [trpcClient] = useState(() =>
    trpc.createClient({
      links: [
        httpBatchLink({
          url: `${getBaseUrl()}`,
        }),
      ],
    }),
  );
  return (
    <trpc.Provider client={trpcClient} queryClient={queryClient}>
      <QueryClientProvider client={queryClient}>
        {children}
      </QueryClientProvider>
    </trpc.Provider>
  );
};
export const TRPCProvider: React.FC<{ children: React.ReactNode }> = ({
  children,
}) => {
  console.log(getBaseUrl())
  const [queryClient] = useState(() => new QueryClient());
  const [trpcClient] = useState(() =>
    trpc.createClient({
      links: [
        httpBatchLink({
          url: `${getBaseUrl()}`,
        }),
      ],
    }),
  );
  return (
    <trpc.Provider client={trpcClient} queryClient={queryClient}>
      <QueryClientProvider client={queryClient}>
        {children}
      </QueryClientProvider>
    </trpc.Provider>
  );
};
```

Title: react-native trpc always loading


问:
Error parsing parameter '--environment': Expected: ',', received: 'EOF' for input: Variables={AMI_ID=}
I'm trying to run an AWS command in my pipeline and I'm getting this error:

```<code>Error parsing parameter '--environment': Expected: ',', received: 'EOF' for input:
Variables={AMI_ID=}
</code>```

Here's my full command being run in my pipeline:

```<code>update_lambda:
  stage: update_lambda
  script:
    - aws lambda update-function-configuration --function-name $LAMBDA_ARN --environment Variable={AMI_ID=$AMI_ID}
</code>```

I'm referencing examples I found online, what other ways could I try?

Body:
I'm trying to run an AWS command in my pipeline and I'm getting this error:

Error parsing parameter '--environment': Expected: ',', received: 'EOF' for input:
Variables={AMI_ID=}

Here's my full command being run in my pipeline:

update_lambda:
  stage: update_lambda
  script:
    - aws lambda update-function-configuration --function-name $LAMBDA_ARN --environment Variable={AMI_ID=$AMI_ID}

I'm referencing examples I found online, what other ways could I try?


问:
How to add a fragment on top of an activity view?
I have a sign up Activity with a TextView on which when pressed, is going to open a new fragment with a recyclerView

The fragment opened is supposed to show a list of available options (User roles) to choose from.

I have added a

```<code>androidx.fragment.app.FragmentContainerView
</code>```

in the xml of my activity which is supposed to launch a fragment on top of it.

```<code><layuout
...
  <ConstraintLayout
    ...
    <FragmentContainerView
       android:layout_width="match_parent"
       android:layout_height="match_parent"
       ...
    <Buttons and EditTexts
    ...
</code>```

The idea is to do on the click:

```<code>val fragment = getUserRoleFragment()
fragment.arguments = Bundle().apply {
    putParcelable(RegisterModel.KEY, viewModel.registerModel)
}
supportFragmentManager.beginTransaction()
    .setReorderingAllowed(true)
    .replace(R.id.fragment_container_view, fragment)
    .addToBackStack(null)
    .setCustomAnimations(R.anim.slide_in_from_right, R.anim.slide_out_to_right)
    .commit()
</code>```

The fragment does not show up and I am unsure what I am doing wrong.
I have tried with .add() as well.

Body:
I have a sign up Activity with a TextView on which when pressed, is going to open a new fragment with a recyclerView

The fragment opened is supposed to show a list of available options (User roles) to choose from.

I have added a

androidx.fragment.app.FragmentContainerView

in the xml of my activity which is supposed to launch a fragment on top of it.

<layuout
...
  <ConstraintLayout
    ...
    <FragmentContainerView
       android:layout_width="match_parent"
       android:layout_height="match_parent"
       ...
    <Buttons and EditTexts
    ...

The idea is to do on the click:

val fragment = getUserRoleFragment()
fragment.arguments = Bundle().apply {
    putParcelable(RegisterModel.KEY, viewModel.registerModel)
}
supportFragmentManager.beginTransaction()
    .setReorderingAllowed(true)
    .replace(R.id.fragment_container_view, fragment)
    .addToBackStack(null)
    .setCustomAnimations(R.anim.slide_in_from_right, R.anim.slide_out_to_right)
    .commit()

The fragment does not show up and I am unsure what I am doing wrong.
I have tried with .add() as well.


问:
Is it beneficial to make variables const and/or static if they will never change during program execution?
I have been working on my adventure game thingy. It has quite a lot of variables that just store values and don't need to change during execution. So basically all of the member variables, arrays, enums, and structs inside of the header file shown below won't change during program execution. Would it thus be beneficial to make the variables const and/or static? Should I make all of it const?

```<code>namespace Adv_Event {

    array<const char, 21> consonants{ 'b', 'c', 'd', 'f', 'g', 'h', 'j', 'k', 'l', 'm', 'n', 'p', 'q', 'r', 's', 't', 'v', 'w', 'x', 'z', '\'' };
    array<const char, 6> vowels{ 'a', 'e', 'i', 'o', 'u', 'y' };

    string generateName() { ... }

    enum eventType { ... };
    enum eventRewardType { ... };

    struct eventAction { int Requirement; eventType Type; string OptionText, SuccessText; eventRewardType RewardType; string FailText; };
    struct customEvent { string MainText; vector<eventAction> Actions, ContinueActions; };

    array<const customEvent, 3> customEvents{

        "MainText...", {
            { 10, Type, "First option", "First option succeeded!", RewardType, "First option failed!" },
            { 20, Type, "Second option", "Second option succeeded!", RewardType, "Second option failed!" },
        }, { ... },

    }
}
</code>```

I pretty much understand that const makes the variable read-only. I have read a little bit about static too and I at least understand its functionality for member variables of functions, but I'm not very knowledgeable about it in-general.

I have also been pondering whether it would be beneficial or not to make the array or struct itself const and/or static? However, I feel like this probably does something completely different than, for example, making a integer const and/or static.

Thanks :)

Body:
I have been working on my adventure game thingy. It has quite a lot of variables that just store values and don't need to change during execution. So basically all of the member variables, arrays, enums, and structs inside of the header file shown below won't change during program execution. Would it thus be beneficial to make the variables const and/or static? Should I make all of it const?

namespace Adv_Event {

    array<const char, 21> consonants{ 'b', 'c', 'd', 'f', 'g', 'h', 'j', 'k', 'l', 'm', 'n', 'p', 'q', 'r', 's', 't', 'v', 'w', 'x', 'z', '\'' };
    array<const char, 6> vowels{ 'a', 'e', 'i', 'o', 'u', 'y' };

    string generateName() { ... }

    enum eventType { ... };
    enum eventRewardType { ... };

    struct eventAction { int Requirement; eventType Type; string OptionText, SuccessText; eventRewardType RewardType; string FailText; };
    struct customEvent { string MainText; vector<eventAction> Actions, ContinueActions; };

    array<const customEvent, 3> customEvents{

        "MainText...", {
            { 10, Type, "First option", "First option succeeded!", RewardType, "First option failed!" },
            { 20, Type, "Second option", "Second option succeeded!", RewardType, "Second option failed!" },
        }, { ... },

    }
}

I pretty much understand that const makes the variable read-only. I have read a little bit about static too and I at least understand its functionality for member variables of functions, but I'm not very knowledgeable about it in-general.

I have also been pondering whether it would be beneficial or not to make the array or struct itself const and/or static? However, I feel like this probably does something completely different than, for example, making a integer const and/or static.

Thanks :)


问:
React refresh page after navigation clear localStorage
Im using React. After login i use

```<code> useNavigate from "react-router-dom";
</code>```

this navigate me to my home page. But my home page should re-render depends of user credentials. I store the information using localStorage. Everything working perfect but after navigate home page i use;

```<code>const navigate = useNavigate();

navigate(0)
</code>```

When i use navigate(0) it refresh page but delete everything in my localStorage. Is there any way to refresh page without clear my localStorage?

Body:
Im using React. After login i use

 useNavigate from "react-router-dom";

this navigate me to my home page. But my home page should re-render depends of user credentials. I store the information using localStorage. Everything working perfect but after navigate home page i use;

const navigate = useNavigate();

navigate(0)

When i use navigate(0) it refresh page but delete everything in my localStorage. Is there any way to refresh page without clear my localStorage?