Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Z
Zope
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
Zope
Commits
6146e717
Commit
6146e717
authored
Jan 15, 1999
by
Amos Latteier
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
revert to original producers.
parent
8544be85
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
10 additions
and
112 deletions
+10
-112
ZServer/medusa/producers.py
ZServer/medusa/producers.py
+5
-56
lib/python/ZServer/medusa/producers.py
lib/python/ZServer/medusa/producers.py
+5
-56
No files found.
ZServer/medusa/producers.py
View file @
6146e717
# -*- Mode: Python; tab-width: 4 -*-
RCS_ID
=
'$Id: producers.py,v 1.
2 1999/01/13 03:00:27
amos Exp $'
RCS_ID
=
'$Id: producers.py,v 1.
3 1999/01/15 02:27:52
amos Exp $'
import
string
...
...
@@ -11,14 +11,6 @@ in various ways to get interesting and useful behaviors.
For example, you can feed dynamically-produced output into the compressing
producer, then wrap this with the 'chunked' transfer-encoding producer.
Added 'ready' method to all producers. This allows future producers which
may not be ready until after they are created. Returning false means that
a call to 'more' will not give you useful information, right now, but will
later. A producer which is not ready is saying that it will be ready sometime
in the future. When a producer is exhausted, it should return true for ready.
When 'more' returns '', the producer is done.
"""
class
simple_producer
:
...
...
@@ -37,9 +29,6 @@ class simple_producer:
self
.
data
=
''
return
result
def
ready
(
self
):
return
1
class
scanning_producer
:
"like simple_producer, but more efficient for large strings"
def
__init__
(
self
,
data
,
buffer_size
=
1024
):
...
...
@@ -60,9 +49,6 @@ class scanning_producer:
else
:
return
''
def
ready
(
self
):
return
1
class
lines_producer
:
"producer for a list of lines"
...
...
@@ -70,7 +56,7 @@ class lines_producer:
self
.
lines
=
lines
def
ready
(
self
):
return
1
return
len
(
self
.
lines
)
def
more
(
self
):
if
self
.
lines
:
...
...
@@ -103,9 +89,6 @@ class file_producer:
else
:
return
data
def
ready
(
self
):
return
1
# A simple output producer. This one does not [yet] have
# the safety feature builtin to the monitor channel: runaway
# output will not be caught.
...
...
@@ -115,8 +98,6 @@ class file_producer:
class
output_producer
:
"Acts like an output file; suitable for capturing sys.stdout"
# XXX this should be updated for new ready semantics
# including fixing ready, more and adding a close method
def
__init__
(
self
):
self
.
data
=
''
...
...
@@ -153,18 +134,11 @@ class output_producer:
class
composite_producer
:
"combine a fifo of producers into one"
# I had to add a buffer to this producer to ensure
# that it really was ready when it said it was ready
def
__init__
(
self
,
producers
):
self
.
producers
=
producers
self
.
buffer
=
''
def
more
(
self
):
if
self
.
buffer
:
b
=
self
.
buffer
self
.
buffer
=
''
return
b
while
self
.
producers
.
ready
():
while
len
(
self
.
producers
):
p
=
self
.
producers
.
first
()
d
=
p
.
more
()
if
d
:
...
...
@@ -174,15 +148,6 @@ class composite_producer:
else
:
return
''
def
ready
(
self
):
if
self
.
buffer
or
len
(
self
.
producers
)
==
0
:
return
1
if
not
self
.
producers
.
ready
():
return
None
self
.
buffer
=
self
.
more
()
if
self
.
buffer
or
len
(
self
.
producers
)
==
0
:
return
1
class
globbing_producer
:
"""
...
...
@@ -197,7 +162,7 @@ class globbing_producer:
self
.
buffer_size
=
buffer_size
def
more
(
self
):
while
len
(
self
.
buffer
)
<
self
.
buffer_size
and
self
.
producer
.
ready
()
:
while
len
(
self
.
buffer
)
<
self
.
buffer_size
:
data
=
self
.
producer
.
more
()
if
data
:
self
.
buffer
=
self
.
buffer
+
data
...
...
@@ -207,9 +172,6 @@ class globbing_producer:
self
.
buffer
=
''
return
r
def
ready
(
self
):
return
self
.
producer
is
None
or
self
.
producer
.
ready
()
class
hooked_producer
:
"""
...
...
@@ -235,9 +197,6 @@ class hooked_producer:
else
:
return
''
def
ready
(
self
):
return
self
.
producer
is
None
or
self
.
producer
.
ready
()
# HTTP 1.1 emphasizes that an advertised Content-Length header MUST be
# correct. In the face of Strange Files, it is conceivable that
# reading a 'file' may produce an amount of data not matching that
...
...
@@ -277,9 +236,6 @@ class chunked_producer:
else
:
return
''
def
ready
(
self
):
return
self
.
producer
is
None
or
self
.
producer
.
ready
()
# Unfortunately this isn't very useful right now (Aug 97), because
# apparently the browsers don't do on-the-fly decompression. Which
# is sad, because this could _really_ speed things up, especially for
...
...
@@ -323,9 +279,6 @@ class compressed_producer:
else
:
return
''
def
ready
(
self
):
return
self
.
producer
is
None
or
self
.
producer
.
ready
()
class
escaping_producer
:
"A producer that escapes a sequence of characters"
...
...
@@ -358,7 +311,3 @@ class escaping_producer:
return
buffer
else
:
return
buffer
def
ready
(
self
):
return
self
.
producer
is
None
or
self
.
producer
.
ready
()
lib/python/ZServer/medusa/producers.py
View file @
6146e717
# -*- Mode: Python; tab-width: 4 -*-
RCS_ID
=
'$Id: producers.py,v 1.
2 1999/01/13 03:00:27
amos Exp $'
RCS_ID
=
'$Id: producers.py,v 1.
3 1999/01/15 02:27:52
amos Exp $'
import
string
...
...
@@ -11,14 +11,6 @@ in various ways to get interesting and useful behaviors.
For example, you can feed dynamically-produced output into the compressing
producer, then wrap this with the 'chunked' transfer-encoding producer.
Added 'ready' method to all producers. This allows future producers which
may not be ready until after they are created. Returning false means that
a call to 'more' will not give you useful information, right now, but will
later. A producer which is not ready is saying that it will be ready sometime
in the future. When a producer is exhausted, it should return true for ready.
When 'more' returns '', the producer is done.
"""
class
simple_producer
:
...
...
@@ -37,9 +29,6 @@ class simple_producer:
self
.
data
=
''
return
result
def
ready
(
self
):
return
1
class
scanning_producer
:
"like simple_producer, but more efficient for large strings"
def
__init__
(
self
,
data
,
buffer_size
=
1024
):
...
...
@@ -60,9 +49,6 @@ class scanning_producer:
else
:
return
''
def
ready
(
self
):
return
1
class
lines_producer
:
"producer for a list of lines"
...
...
@@ -70,7 +56,7 @@ class lines_producer:
self
.
lines
=
lines
def
ready
(
self
):
return
1
return
len
(
self
.
lines
)
def
more
(
self
):
if
self
.
lines
:
...
...
@@ -103,9 +89,6 @@ class file_producer:
else
:
return
data
def
ready
(
self
):
return
1
# A simple output producer. This one does not [yet] have
# the safety feature builtin to the monitor channel: runaway
# output will not be caught.
...
...
@@ -115,8 +98,6 @@ class file_producer:
class
output_producer
:
"Acts like an output file; suitable for capturing sys.stdout"
# XXX this should be updated for new ready semantics
# including fixing ready, more and adding a close method
def
__init__
(
self
):
self
.
data
=
''
...
...
@@ -153,18 +134,11 @@ class output_producer:
class
composite_producer
:
"combine a fifo of producers into one"
# I had to add a buffer to this producer to ensure
# that it really was ready when it said it was ready
def
__init__
(
self
,
producers
):
self
.
producers
=
producers
self
.
buffer
=
''
def
more
(
self
):
if
self
.
buffer
:
b
=
self
.
buffer
self
.
buffer
=
''
return
b
while
self
.
producers
.
ready
():
while
len
(
self
.
producers
):
p
=
self
.
producers
.
first
()
d
=
p
.
more
()
if
d
:
...
...
@@ -174,15 +148,6 @@ class composite_producer:
else
:
return
''
def
ready
(
self
):
if
self
.
buffer
or
len
(
self
.
producers
)
==
0
:
return
1
if
not
self
.
producers
.
ready
():
return
None
self
.
buffer
=
self
.
more
()
if
self
.
buffer
or
len
(
self
.
producers
)
==
0
:
return
1
class
globbing_producer
:
"""
...
...
@@ -197,7 +162,7 @@ class globbing_producer:
self
.
buffer_size
=
buffer_size
def
more
(
self
):
while
len
(
self
.
buffer
)
<
self
.
buffer_size
and
self
.
producer
.
ready
()
:
while
len
(
self
.
buffer
)
<
self
.
buffer_size
:
data
=
self
.
producer
.
more
()
if
data
:
self
.
buffer
=
self
.
buffer
+
data
...
...
@@ -207,9 +172,6 @@ class globbing_producer:
self
.
buffer
=
''
return
r
def
ready
(
self
):
return
self
.
producer
is
None
or
self
.
producer
.
ready
()
class
hooked_producer
:
"""
...
...
@@ -235,9 +197,6 @@ class hooked_producer:
else
:
return
''
def
ready
(
self
):
return
self
.
producer
is
None
or
self
.
producer
.
ready
()
# HTTP 1.1 emphasizes that an advertised Content-Length header MUST be
# correct. In the face of Strange Files, it is conceivable that
# reading a 'file' may produce an amount of data not matching that
...
...
@@ -277,9 +236,6 @@ class chunked_producer:
else
:
return
''
def
ready
(
self
):
return
self
.
producer
is
None
or
self
.
producer
.
ready
()
# Unfortunately this isn't very useful right now (Aug 97), because
# apparently the browsers don't do on-the-fly decompression. Which
# is sad, because this could _really_ speed things up, especially for
...
...
@@ -323,9 +279,6 @@ class compressed_producer:
else
:
return
''
def
ready
(
self
):
return
self
.
producer
is
None
or
self
.
producer
.
ready
()
class
escaping_producer
:
"A producer that escapes a sequence of characters"
...
...
@@ -358,7 +311,3 @@ class escaping_producer:
return
buffer
else
:
return
buffer
def
ready
(
self
):
return
self
.
producer
is
None
or
self
.
producer
.
ready
()
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment