}
}
});
}
else if (ret instanceof PyIterator) {
final PyIterator iter = (PyIterator) ret;
response.setEntity(new OutputRepresentation(mediaType) {
@Override
public void write(OutputStream outputStream) throws IOException {
for (Iterator i = iter.iterator(); i.hasNext();) {
outputStream.write(i.next().toString().getBytes());
outputStream.write('\n');
}
}
});
}
else if (ret instanceof PyObjectDerived) {
final PyObjectDerived iter = (PyObjectDerived)ret;
response.setEntity(new OutputRepresentation(mediaType) {
@Override
public void write(OutputStream outputStream) throws IOException {
PyObject next = null;
while ((next = iter.__iternext__()) != null) {
outputStream.write(next.toString().getBytes());
outputStream.write('\n');
}
}
});