René's URL Explorer Experiment


Title: Using the __init__() method to pass objects to the server implementation of an interface? · python-sdbus/python-sdbus · Discussion #115 · GitHub

Open Graph Title: Using the __init__() method to pass objects to the server implementation of an interface? · python-sdbus/python-sdbus · Discussion #115

X Title: Using the __init__() method to pass objects to the server implementation of an interface? · python-sdbus/python-sdbus · Discussion #115

Description: Using the __init__() method to pass objects to the server implementation of an interface?

Open Graph Description: Hi! When implementing the server side of an interface it seems to me to be convenient to be able to pass references etc. to an interface using the def __init__(self, ...) call. But I'm having troub...

X Description: Hi! When implementing the server side of an interface it seems to me to be convenient to be able to pass references etc. to an interface using the def __init__(self, ...) call. But I'm having t...

Opengraph URL: https://github.com/python-sdbus/python-sdbus/discussions/115

X: @github

direct link

Domain: patch-diff.githubusercontent.com


Hey, it has json ld scripts:
{"@context":"https://schema.org","@type":"QAPage","mainEntity":{"@type":"Question","name":"Using the __init__() method to pass objects to the server implementation of an interface?","text":"

Hi!

\n

When implementing the server side of an interface it seems to me to be convenient to be able to pass references etc. to an interface using the def __init__(self, ...) call.

\n

But I'm having trouble to get this to work, as I get the error:

\n
... object has no attribute '_dbus'\n
\n

back.

\n

An example:

\n
from sdbus import (DbusInterfaceCommonAsync, dbus_method_async,\n                   request_default_bus_name_async)\nfrom asyncio import new_event_loop\n\nclass HelloInterface(\n    DbusInterfaceCommonAsync,\n    interface_name='org.example.interface'\n):\n    def __init__(self, hello):\n        self.hello = hello\n\n    @dbus_method_async(\n        input_signature='s',\n        result_signature='s',\n    )\n    async def hello(self, string: str) -> str:\n        return self.hello.say_hello_back(str)\n\nclass Hello:\n    def say_hello_back(str):\n        return \"Hello {str}!\"\n\nhello = Hello()\ni = HelloInterface(hello)\n\nasync def startup() -> None:\n    await request_default_bus_name_async('org.example.test')\n    i.export_to_dbus('/')\n\nloop = new_event_loop()\n\nloop.run_until_complete(startup())\nloop.run_forever()\n
\n

This gives the error:

\n
Traceback (most recent call last):\n  File \"/tmp/test/hello_interface.py\", line 32, in <module>\n    loop.run_until_complete(startup())\n    ~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^\n  File \"/usr/lib/python3.13/asyncio/base_events.py\", line 725, in run_until_complete\n    return future.result()\n           ~~~~~~~~~~~~~^^\n  File \"/tmp/test/hello_interface.py\", line 28, in startup\n    i.export_to_dbus('/')\n    ~~~~~~~~~~~~~~~~^^^^^\n  File \"/usr/lib/python3/dist-packages/sdbus/dbus_proxy_async_interface_base.py\", line 322, in export_to_dbus\n    local_object_meta = self._dbus\n                        ^^^^^^^^^^\nAttributeError: 'HelloInterface' object has no attribute '_dbus'\n
\n

Obviously something is missing in the def __init__() method, but I've not been able to find out what it could be.

\n

Any pointers?

","upvoteCount":1,"answerCount":1,"acceptedAnswer":{"@type":"Answer","text":"

It is a different error caused by the fact you are using hello both as attribute and method. You have to rename one of them. For example, call attribute _hello:

\n
    def __init__(self, hello):\n        super().__init__()\n        self._hello = hello
","upvoteCount":0,"url":"https://github.com/python-sdbus/python-sdbus/discussions/115#discussioncomment-14910541"}}}

route-pattern/_view_fragments/Voltron::DiscussionsFragmentsController/show/:user_id/:repository/:discussion_number/discussion_layout(.:format)
route-controllervoltron_discussions_fragments
route-actiondiscussion_layout
fetch-noncev2:4a1e5bf3-f075-b8cc-1c6d-453a2f913f7d
current-catalog-service-hash9f0abe34da433c9b6db74bffa2466494a717b579a96b30a5d252e5090baea7be
request-idACD4:A24B6:D61A:106E0:698D12E9
html-safe-noncebbe96979d68dcc1390dcc70dc9a008b9420f4a318994d9f266c532bf256fa42a
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBQ0Q0OkEyNEI2OkQ2MUE6MTA2RTA6Njk4RDEyRTkiLCJ2aXNpdG9yX2lkIjoiMTAzOTE1MDA4NjE1NDQyNTA2NiIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9
visitor-hmac6c601dc81bcd63d3f5235ef1de03b4a7000c74310e245f456bbf2f255ecfea73
hovercard-subject-tagdiscussion:9119388
github-keyboard-shortcutsrepository,copilot
google-site-verificationApib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I
octolytics-urlhttps://collector.github.com/github/collect
analytics-location///voltron/discussions_fragments/discussion_layout
fb:app_id1401488693436528
apple-itunes-appapp-id=1477376905, app-argument=https://github.com/_view_fragments/Voltron::DiscussionsFragmentsController/show/python-sdbus/python-sdbus/115/discussion_layout
twitter:imagehttps://opengraph.githubassets.com/7a4153bf31bbb4e88464d6dcca70c4daadb0fe0d4d69b10d6ea78c7486abecf8/python-sdbus/python-sdbus/discussions/115
twitter:cardsummary_large_image
og:imagehttps://opengraph.githubassets.com/7a4153bf31bbb4e88464d6dcca70c4daadb0fe0d4d69b10d6ea78c7486abecf8/python-sdbus/python-sdbus/discussions/115
og:image:altHi! When implementing the server side of an interface it seems to me to be convenient to be able to pass references etc. to an interface using the def __init__(self, ...) call. But I'm having troub...
og:image:width1200
og:image:height600
og:site_nameGitHub
og:typeobject
hostnamegithub.com
expected-hostnamegithub.com
Nonec25395580e1e3bf82d705e0982a1b24255366088720fef945f1493d5e3e67954
turbo-cache-controlno-preview
go-importgithub.com/python-sdbus/python-sdbus git https://github.com/python-sdbus/python-sdbus.git
octolytics-dimension-user_id88226657
octolytics-dimension-user_loginpython-sdbus
octolytics-dimension-repository_id311269257
octolytics-dimension-repository_nwopython-sdbus/python-sdbus
octolytics-dimension-repository_publictrue
octolytics-dimension-repository_is_forkfalse
octolytics-dimension-repository_network_root_id311269257
octolytics-dimension-repository_network_root_nwopython-sdbus/python-sdbus
turbo-body-classeslogged-out env-production page-responsive
disable-turbofalse
browser-stats-urlhttps://api.github.com/_private/browser/stats
browser-errors-urlhttps://api.github.com/_private/browser/errors
release94219dcb9c044792ec271fd5b23c73419858bef7
ui-targetfull
theme-color#1e2327
color-schemelight dark

Links:

Skip to contenthttps://patch-diff.githubusercontent.com/python-sdbus/python-sdbus/discussions/115#start-of-content
https://patch-diff.githubusercontent.com/
Sign in https://patch-diff.githubusercontent.com/login?return_to=https%3A%2F%2Fgithub.com%2Fpython-sdbus%2Fpython-sdbus%2Fdiscussions%2F115
GitHub CopilotWrite better code with AIhttps://github.com/features/copilot
GitHub SparkBuild and deploy intelligent appshttps://github.com/features/spark
GitHub ModelsManage and compare promptshttps://github.com/features/models
MCP RegistryNewIntegrate external toolshttps://github.com/mcp
ActionsAutomate any workflowhttps://github.com/features/actions
CodespacesInstant dev environmentshttps://github.com/features/codespaces
IssuesPlan and track workhttps://github.com/features/issues
Code ReviewManage code changeshttps://github.com/features/code-review
GitHub Advanced SecurityFind and fix vulnerabilitieshttps://github.com/security/advanced-security
Code securitySecure your code as you buildhttps://github.com/security/advanced-security/code-security
Secret protectionStop leaks before they starthttps://github.com/security/advanced-security/secret-protection
Why GitHubhttps://github.com/why-github
Documentationhttps://docs.github.com
Bloghttps://github.blog
Changeloghttps://github.blog/changelog
Marketplacehttps://github.com/marketplace
View all featureshttps://github.com/features
Enterpriseshttps://github.com/enterprise
Small and medium teamshttps://github.com/team
Startupshttps://github.com/enterprise/startups
Nonprofitshttps://github.com/solutions/industry/nonprofits
App Modernizationhttps://github.com/solutions/use-case/app-modernization
DevSecOpshttps://github.com/solutions/use-case/devsecops
DevOpshttps://github.com/solutions/use-case/devops
CI/CDhttps://github.com/solutions/use-case/ci-cd
View all use caseshttps://github.com/solutions/use-case
Healthcarehttps://github.com/solutions/industry/healthcare
Financial serviceshttps://github.com/solutions/industry/financial-services
Manufacturinghttps://github.com/solutions/industry/manufacturing
Governmenthttps://github.com/solutions/industry/government
View all industrieshttps://github.com/solutions/industry
View all solutionshttps://github.com/solutions
AIhttps://github.com/resources/articles?topic=ai
Software Developmenthttps://github.com/resources/articles?topic=software-development
DevOpshttps://github.com/resources/articles?topic=devops
Securityhttps://github.com/resources/articles?topic=security
View all topicshttps://github.com/resources/articles
Customer storieshttps://github.com/customer-stories
Events & webinarshttps://github.com/resources/events
Ebooks & reportshttps://github.com/resources/whitepapers
Business insightshttps://github.com/solutions/executive-insights
GitHub Skillshttps://skills.github.com
Documentationhttps://docs.github.com
Customer supporthttps://support.github.com
Community forumhttps://github.com/orgs/community/discussions
Trust centerhttps://github.com/trust-center
Partnershttps://github.com/partners
GitHub SponsorsFund open source developershttps://github.com/sponsors
Security Labhttps://securitylab.github.com
Maintainer Communityhttps://maintainers.github.com
Acceleratorhttps://github.com/accelerator
Archive Programhttps://archiveprogram.github.com
Topicshttps://github.com/topics
Trendinghttps://github.com/trending
Collectionshttps://github.com/collections
Enterprise platformAI-powered developer platformhttps://github.com/enterprise
GitHub Advanced SecurityEnterprise-grade security featureshttps://github.com/security/advanced-security
Copilot for BusinessEnterprise-grade AI featureshttps://github.com/features/copilot/copilot-business
Premium SupportEnterprise-grade 24/7 supporthttps://github.com/premium-support
Pricinghttps://github.com/pricing
Search syntax tipshttps://docs.github.com/search-github/github-code-search/understanding-github-code-search-syntax
documentationhttps://docs.github.com/search-github/github-code-search/understanding-github-code-search-syntax
Sign in https://patch-diff.githubusercontent.com/login?return_to=https%3A%2F%2Fgithub.com%2Fpython-sdbus%2Fpython-sdbus%2Fdiscussions%2F115
Sign up https://patch-diff.githubusercontent.com/signup?ref_cta=Sign+up&ref_loc=header+logged+out&ref_page=%2F%3Cuser-name%3E%2F%3Crepo-name%3E%2Fvoltron%2Fdiscussions_fragments%2Fdiscussion_layout&source=header-repo&source_repo=python-sdbus%2Fpython-sdbus
Reloadhttps://patch-diff.githubusercontent.com/python-sdbus/python-sdbus/discussions/115
Reloadhttps://patch-diff.githubusercontent.com/python-sdbus/python-sdbus/discussions/115
Reloadhttps://patch-diff.githubusercontent.com/python-sdbus/python-sdbus/discussions/115
python-sdbus https://patch-diff.githubusercontent.com/python-sdbus
python-sdbushttps://patch-diff.githubusercontent.com/python-sdbus/python-sdbus
Please reload this pagehttps://patch-diff.githubusercontent.com/python-sdbus/python-sdbus/discussions/115
Notifications https://patch-diff.githubusercontent.com/login?return_to=%2Fpython-sdbus%2Fpython-sdbus
Fork 23 https://patch-diff.githubusercontent.com/login?return_to=%2Fpython-sdbus%2Fpython-sdbus
Star 105 https://patch-diff.githubusercontent.com/login?return_to=%2Fpython-sdbus%2Fpython-sdbus
Code https://patch-diff.githubusercontent.com/python-sdbus/python-sdbus
Issues 4 https://patch-diff.githubusercontent.com/python-sdbus/python-sdbus/issues
Pull requests 1 https://patch-diff.githubusercontent.com/python-sdbus/python-sdbus/pulls
Discussions https://patch-diff.githubusercontent.com/python-sdbus/python-sdbus/discussions
Actions https://patch-diff.githubusercontent.com/python-sdbus/python-sdbus/actions
Projects 0 https://patch-diff.githubusercontent.com/python-sdbus/python-sdbus/projects
Security 0 https://patch-diff.githubusercontent.com/python-sdbus/python-sdbus/security
Insights https://patch-diff.githubusercontent.com/python-sdbus/python-sdbus/pulse
Code https://patch-diff.githubusercontent.com/python-sdbus/python-sdbus
Issues https://patch-diff.githubusercontent.com/python-sdbus/python-sdbus/issues
Pull requests https://patch-diff.githubusercontent.com/python-sdbus/python-sdbus/pulls
Discussions https://patch-diff.githubusercontent.com/python-sdbus/python-sdbus/discussions
Actions https://patch-diff.githubusercontent.com/python-sdbus/python-sdbus/actions
Projects https://patch-diff.githubusercontent.com/python-sdbus/python-sdbus/projects
Security https://patch-diff.githubusercontent.com/python-sdbus/python-sdbus/security
Insights https://patch-diff.githubusercontent.com/python-sdbus/python-sdbus/pulse
Answered https://patch-diff.githubusercontent.com/python-sdbus/python-sdbus/discussions/115#discussioncomment-14910541
igo95862https://patch-diff.githubusercontent.com/igo95862
kmart https://patch-diff.githubusercontent.com/kmart
Q&Ahttps://patch-diff.githubusercontent.com/python-sdbus/python-sdbus/discussions/categories/q-a
Using the __init__() method to pass objects to the server implementation of an interface? https://patch-diff.githubusercontent.com/python-sdbus/python-sdbus/discussions/115#top
kmart https://patch-diff.githubusercontent.com/kmart
Answered https://patch-diff.githubusercontent.com/python-sdbus/python-sdbus/discussions/115#discussioncomment-14910541
igo95862https://patch-diff.githubusercontent.com/igo95862
Return to tophttps://patch-diff.githubusercontent.com/python-sdbus/python-sdbus/discussions/115#top
Please reload this pagehttps://patch-diff.githubusercontent.com/python-sdbus/python-sdbus/discussions/115
https://patch-diff.githubusercontent.com/python-sdbus/python-sdbus/discussions/115
kmart https://patch-diff.githubusercontent.com/kmart
Nov 8, 2025 https://patch-diff.githubusercontent.com/python-sdbus/python-sdbus/discussions/115#discussion-9119388
Give feedback.https://patch-diff.githubusercontent.com/python-sdbus/python-sdbus/discussions/115
igo95862 https://patch-diff.githubusercontent.com/igo95862
Nov 8, 2025 https://github.com/python-sdbus/python-sdbus/discussions/115#discussioncomment-14910541
View full answer https://patch-diff.githubusercontent.com/python-sdbus/python-sdbus/discussions/115#discussioncomment-14910541
Oldest https://patch-diff.githubusercontent.com/python-sdbus/python-sdbus/discussions/115?sort=old
Newest https://patch-diff.githubusercontent.com/python-sdbus/python-sdbus/discussions/115?sort=new
Top https://patch-diff.githubusercontent.com/python-sdbus/python-sdbus/discussions/115?sort=top
Please reload this pagehttps://patch-diff.githubusercontent.com/python-sdbus/python-sdbus/discussions/115
https://patch-diff.githubusercontent.com/python-sdbus/python-sdbus/discussions/115
Please reload this pagehttps://patch-diff.githubusercontent.com/python-sdbus/python-sdbus/discussions/115
https://patch-diff.githubusercontent.com/python-sdbus/python-sdbus/discussions/115
igo95862 https://patch-diff.githubusercontent.com/igo95862
Nov 8, 2025 https://patch-diff.githubusercontent.com/python-sdbus/python-sdbus/discussions/115#discussioncomment-14909811
@kmarthttps://github.com/kmart
Give feedback.https://patch-diff.githubusercontent.com/python-sdbus/python-sdbus/discussions/115
https://patch-diff.githubusercontent.com/kmart
Please reload this pagehttps://patch-diff.githubusercontent.com/python-sdbus/python-sdbus/discussions/115
https://patch-diff.githubusercontent.com/python-sdbus/python-sdbus/discussions/115
kmarthttps://patch-diff.githubusercontent.com/kmart
Nov 8, 2025 https://patch-diff.githubusercontent.com/python-sdbus/python-sdbus/discussions/115#discussioncomment-14910533
Give feedback.https://patch-diff.githubusercontent.com/python-sdbus/python-sdbus/discussions/115
https://patch-diff.githubusercontent.com/igo95862
Please reload this pagehttps://patch-diff.githubusercontent.com/python-sdbus/python-sdbus/discussions/115
https://patch-diff.githubusercontent.com/python-sdbus/python-sdbus/discussions/115
igo95862https://patch-diff.githubusercontent.com/igo95862
Nov 8, 2025 https://patch-diff.githubusercontent.com/python-sdbus/python-sdbus/discussions/115#discussioncomment-14910541
Give feedback.https://patch-diff.githubusercontent.com/python-sdbus/python-sdbus/discussions/115
kmarthttps://patch-diff.githubusercontent.com/kmart
https://patch-diff.githubusercontent.com/kmart
Please reload this pagehttps://patch-diff.githubusercontent.com/python-sdbus/python-sdbus/discussions/115
https://patch-diff.githubusercontent.com/python-sdbus/python-sdbus/discussions/115
kmarthttps://patch-diff.githubusercontent.com/kmart
Nov 8, 2025 https://patch-diff.githubusercontent.com/python-sdbus/python-sdbus/discussions/115#discussioncomment-14910779
Give feedback.https://patch-diff.githubusercontent.com/python-sdbus/python-sdbus/discussions/115
Sign up for freehttps://patch-diff.githubusercontent.com/join?source=comment-repo
Sign in to commenthttps://patch-diff.githubusercontent.com/login?return_to=https%3A%2F%2Fgithub.com%2Fpython-sdbus%2Fpython-sdbus%2Fdiscussions%2F115
🙏 Q&A https://patch-diff.githubusercontent.com/python-sdbus/python-sdbus/discussions/categories/q-a
https://patch-diff.githubusercontent.com/kmart
https://patch-diff.githubusercontent.com/igo95862
https://patch-diff.githubusercontent.com/python-sdbus/python-sdbus/discussions/115
https://patch-diff.githubusercontent.com/settings/replies?return_to=1
https://github.com
Termshttps://docs.github.com/site-policy/github-terms/github-terms-of-service
Privacyhttps://docs.github.com/site-policy/privacy-policies/github-privacy-statement
Securityhttps://github.com/security
Statushttps://www.githubstatus.com/
Communityhttps://github.community/
Docshttps://docs.github.com/
Contacthttps://support.github.com?tags=dotcom-footer

Viewport: width=device-width


URLs of crawlers that visited me.