Logo Search packages:      
Sourcecode: zope-ldap version File versions

def ZLDAPConnection::Entry::GenericEntry::addSubentry (   self,
  attrs = {},

Create a new subentry of myself 

Definition at line 224 of file Entry.py.

00224                                      {}, **kw):
        """ Create a new subentry of myself """
        conn = self._connection()
        nkw = {}
        nkw.update(attrs); nkw.update(kw)
        attrs = nkw

        # Create the full new DN (Distinguished Name) for the new subentry
        # and verify that it doesn't already exist
        dn = "%s,%s" % (string.strip(rdn), self.dn)
        if conn.hasEntry(dn):           # Check the LDAP server directly
            raise KeyError, "DN '%s' already exists" % dn

        # Now split out the first attr based on the RDN (ie 'cn=bob') and
        # turn it into one of our attributes (ie attr[cn] = 'bob')
        key, value = map(string.strip, string.split(rdn,'='))
        attrs[key] = value

        # If the objectclass is not already set in the attrs, set it now
        if not attrs.has_key('objectclass'):
            attrs['objectclass'] = ['top']

        # Instantiate the instance based on the connections EntryFactory
        Entry = conn._EntryFactory()
        entry = Entry(dn, attrs, conn, isNew=1).__of__(self)
        conn._addEntry(dn, attrs.items()) # Physically add the new entry
        self._setSubentry(entry.id, entry)

        return entry

Generated by  Doxygen 1.6.0   Back to index