'Return the WKB representation of the given geometry.'

def write(self, geom):

    from django.contrib.gis.geos import Polygon
    geom = self._handle_empty_point(geom)
    wkb = wkb_writer_write(self.ptr, geom.ptr, byref(c_size_t()))
    if (isinstance(geom, Polygon) and geom.empty):
        wkb = (wkb[:(-8)] + ('\x00' * 4))
    return memoryview(wkb)
