Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Latest commit

 

History

History
History
30 lines (20 loc) · 716 Bytes

File metadata and controls

30 lines (20 loc) · 716 Bytes
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
"""Example of the Observer pattern using Pyro.
Copyright 2010 Allen B. Downey
License: GNU GPLv3 http://www.gnu.org/licenses/gpl.html
"""
import Pyro.errors
from remote_object import NameServer
class Modifier:
"""A Modifier is an object that reads and writes the state of
a Subject, but it is not a registered Observer."""
def __init__(self, subject_name):
self.subject = ns.get_proxy(subject_name)
def modify(self):
"""Increment the state of the Subject."""
state = self.subject.get_state()
self.subject.set_state(state+1)
print 'Set state ' + str(state+1)
ns = NameServer()
subject_name = 'simple_subject'
mod = Modifier(subject_name)
mod.modify()
Morty Proxy This is a proxified and sanitized view of the page, visit original site.