Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
gajim
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Weblate
gajim
Commits
6b5e9ea7
Commit
6b5e9ea7
authored
16 years ago
by
steve-e
Browse files
Options
Downloads
Patches
Plain Diff
Documentation improvements in client.py
parent
ad7c6499
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/common/xmpp/client.py
+31
-16
31 additions, 16 deletions
src/common/xmpp/client.py
with
31 additions
and
16 deletions
src/common/xmpp/client.py
+
31
−
16
View file @
6b5e9ea7
...
...
@@ -16,23 +16,30 @@
'''
Provides PlugIn class functionality to develop extentions for xmpppy.
Also provides Client and Component classes implementations as the
examples of xmpppy structures usage.
These classes can be used for simple applications
"
AS IS
"
though.
'''
import
logging
log
=
logging
.
getLogger
(
'
gajim.c.x.plugin
'
)
class
PlugIn
:
'''
Common xmpppy plugins infrastructure: plugging in/out, debugging.
'''
'''
Abstract xmpppy plugin infrastructure code, providing plugging in/out and
debugging functionality.
Inherit to develop pluggable objects. No code change on the owner class
required (the object where we plug into)
'''
def
__init__
(
self
):
self
.
_exported_methods
=
[]
def
PlugIn
(
self
,
owner
):
'''
Attach to main instance and register ourself and all our staff in it.
'''
def
PlugIn
(
self
,
owner
):
'''
Attach to owner and register ourself and our _exported_methods in it.
If defined by a subclass, call self.plugin(owner) to execute hook
code after plugging.
'''
self
.
_owner
=
owner
log
.
info
(
'
Plugging %s __INTO__ %s
'
%
(
self
,
self
.
_owner
))
log
.
info
(
'
Plugging %s __INTO__ %s
'
%
(
self
,
self
.
_owner
))
if
self
.
__class__
.
__name__
in
owner
.
__dict__
:
log
.
debug
(
'
Plugging ignored: another instance already plugged.
'
)
return
...
...
@@ -47,22 +54,30 @@ class PlugIn:
owner
.
__dict__
[
'
Dispatcher
'
]
=
self
else
:
owner
.
__dict__
[
self
.
__class__
.
__name__
]
=
self
#
following commented line will not work for classes inheriting plugin()
#
if
self.__class__.__dict__.has_key('plugin'): return
self
.
plugin
(owner)
if
hasattr
(
self
,
'
plugin
'
):
return
self
.
plugin
(
owner
)
#
Execute hook
if
hasattr
(
self
,
'
plugin
'
):
return
self
.
plugin
(
owner
)
def
PlugOut
(
self
):
'''
Unregister all our staff from main instance and detach from it.
'''
'''
Unregister our _exported_methods from owner and detach from it.
If defined by a subclass, call self.plugout() after unplugging to execute
hook code.
'''
log
.
info
(
'
Plugging %s __OUT__ of %s.
'
%
(
self
,
self
.
_owner
))
for
method
in
self
.
_exported_methods
:
del
self
.
_owner
.
__dict__
[
method
.
__name__
]
for
method
in
self
.
_old_owners_methods
:
self
.
_owner
.
__dict__
[
method
.
__name__
]
=
method
for
method
in
self
.
_exported_methods
:
del
self
.
_owner
.
__dict__
[
method
.
__name__
]
for
method
in
self
.
_old_owners_methods
:
self
.
_owner
.
__dict__
[
method
.
__name__
]
=
method
# FIXME: Dispatcher workaround
if
self
.
__class__
.
__name__
.
endswith
(
'
Dispatcher
'
):
del
self
.
_owner
.
__dict__
[
'
Dispatcher
'
]
else
:
del
self
.
_owner
.
__dict__
[
self
.
__class__
.
__name__
]
#if self.__class__.__dict__.has_key('plugout'): return self.plugout()
if
hasattr
(
self
,
'
plugout
'
):
return
self
.
plugout
()
# Execute hook
if
hasattr
(
self
,
'
plugout
'
):
return
self
.
plugout
()
del
self
.
_owner
# vim: se ts=3:
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment