Skip to content

Commit

Permalink
Add update and upload method
Browse files Browse the repository at this point in the history
  • Loading branch information
paulfariello committed Oct 19, 2016
1 parent 51ec702 commit 626dcf0
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
2 changes: 1 addition & 1 deletion tests/storage/test_ldap.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,5 @@ def get_storage_args(self):
conn.strategy.add_entry('cn=user0,ou=test,o=lab', {'userPassword': 'test0000', 'sn': 'user0_sn', 'revision': 0})

def inner(collection='test'):
return {'url': url, 'conn': conn}
return {'url': url, 'conn': conn, 'search_base': 'ou=test,o=lab'}
return inner
9 changes: 8 additions & 1 deletion vdirsyncer/storage/ldap.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ class LDAPStorage(Storage):
:param filter: filter
'''
storage_name = 'ldap'
read_only = True
fileext = '.vcf'
item_mimetype = 'text/vcard'

Expand Down Expand Up @@ -107,3 +106,11 @@ def get(self, href):
item = Item(vcard.serialize())

return item, etag

def upload(self, item):
vcard = vobject.readOne(item.raw)
self.conn.strategy.add_entry('cn={},ou=test,o=lab'.format(vcard.fn), vcard)

def update(self, href, item, etag):
vcard = vobject.readOne(item.raw)
self.conn.strategy.add_entry(href, vcard)

0 comments on commit 626dcf0

Please sign in to comment.