The following works
from dolfin import *
class Obstacle(SubDomain):
def inside(self, x, on_boundary):
return (between(x[1], (0.5, 0.7)) and between(x[0], (0.2, 1.0)))
obstacle = Obstacle()
# Define mesh
mesh = RectangleMesh(0.0, 0.0, 1.0, 1.0, 100, 100)
# Initialize mesh function for interior domains
subdomains = CellFunction('size_t', mesh)
subdomains.set_all(0)
obstacle.mark(subdomains, 1)
dx = Measure('dx')[subdomains]
V = FunctionSpace(mesh, 'CG', 1)
f = project(Constant(1.1), V)
print assemble(f * dx('everywhere'))
print assemble(f * dx())
print assemble(f * dx(0))
print assemble(f * dx(1))