def _attach_slot(self,<EOL>oid,<EOL>klass,<EOL>marshal=None,<EOL>parse=None,<EOL>build=None,<EOL>cast=None,<EOL>compress=None,<EOL>create=True,<EOL>name=None,<EOL>description=None):
assert isinstance(oid, uuid.UUID)<EOL>assert issubclass(klass, _pmap.PersistentMap)<EOL>assert marshal is None or callable(marshal)<EOL>assert parse is None or callable(parse)<EOL>assert build is None or callable(build)<EOL>assert cast is None or callable(cast)<EOL>assert (not marshal and not parse and not build and not cast) or(not marshal and not parse and build and cast) or(marshal and parse and not build and not cast)<EOL>assert type(create) == bool<EOL>assert name is None or type(name) == six.text_type<EOL>assert description is None or type(description) == six.text_type<EOL>if oid not in self._slots_by_index:<EOL><INDENT>self.log.debug('<STR_LIT>', name=name, oid=oid)<EOL>if create:<EOL><INDENT>slot_index = self._get_free_slot()<EOL>slot = Slot(oid=oid, creator='<STR_LIT>', slot=slot_index, name=name, description=description)<EOL>self._set_slot(slot_index, slot)<EOL>self.log.info('<STR_LIT>',<EOL>slot_index=slot_index,<EOL>oid=oid,<EOL>name=name)<EOL><DEDENT>else:<EOL><INDENT>raise Exception('<STR_LIT>', name=name, oid=oid)<EOL><DEDENT><DEDENT>else:<EOL><INDENT>slot_index = self._slots_by_index[oid]<EOL>pmap = _pmap.PersistentMap(slot_index)<EOL>with self.begin() as txn:<EOL><INDENT>records = pmap.count(txn)<EOL><DEDENT>self.log.debug(<EOL>'<STR_LIT>',<EOL>name=name,<EOL>oid=oid,<EOL>slot_index=slot_index,<EOL>records=records)<EOL><DEDENT>if marshal:<EOL><INDENT>slot_pmap = klass(slot_index, marshal=marshal, unmarshal=parse, compress=compress)<EOL><DEDENT>elif build:<EOL><INDENT>slot_pmap = klass(slot_index, build=build, cast=cast, compress=compress)<EOL><DEDENT>else:<EOL><INDENT>slot_pmap = klass(slot_index, compress=compress)<EOL><DEDENT>return slot_pmap<EOL>
:param slot:
:param klass:
:param marshal:
:param unmarshal:
:return: