Skip to content
This repository has been archived by the owner on May 15, 2023. It is now read-only.

Commit

Permalink
Merge pull request #29 from vinzBad/list-exclude-hidden-fields
Browse files Browse the repository at this point in the history
Add Flag to List constructor to exclude hidden fields
  • Loading branch information
jasonrollins committed Oct 6, 2018
2 parents e707347 + 597b5c0 commit ce8f034
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
4 changes: 3 additions & 1 deletion docs/objects.rst
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,12 @@ Methods
Returns information on the userbase of the current Site.

.. py:function:: List(listName)
.. py:function:: List(listName, exclude_hidden_fields=False)
Returns a List object for the list with 'listName' on the current Site.

Sometimes internal fields can take the same DisplayName as visible fields, effectively hiding them from SharePlum. When 'exclude_hidden_fields' is True, these internal fields won't be loaded.

List
====

Expand Down
13 changes: 9 additions & 4 deletions shareplum/shareplum.py
Original file line number Diff line number Diff line change
Expand Up @@ -294,13 +294,13 @@ def GetUsers(self, rowlimit=0):


# SharePoint Method Objects
def List(self, listName):
def List(self, listName, exclude_hidden_fields=False):
"""Sharepoint Lists Web Service
Microsoft Developer Network:
The Lists Web service provides methods for working
with SharePoint lists, content types, list items, and files.
"""
return _List(self._session, listName, self._url, self._verify_ssl, self.users, self.huge_tree, self.timeout)
return _List(self._session, listName, self._url, self._verify_ssl, self.users, self.huge_tree, self.timeout, exclude_hidden_fields=exclude_hidden_fields)


class _List(object):
Expand All @@ -310,22 +310,27 @@ class _List(object):
with SharePoint lists, content types, list items, and files.
"""

def __init__(self, session, listName, url, verify_ssl, users, huge_tree, timeout):
def __init__(self, session, listName, url, verify_ssl, users, huge_tree, timeout, exclude_hidden_fields=False):
self._session = session
self.listName = listName
self._url = url
self._verify_ssl = verify_ssl
self.users = users
self.huge_tree = huge_tree
self.timeout = timeout

self._exclude_hidden_fields = exclude_hidden_fields
# List Info
self.fields = []
self.regional_settings = {}
self.server_settings = {}
self.GetList()
self.views = self.GetViewCollection()

# fields sometimes share the same displayname
# filtering fields to only contain visible fields, minimizes the chance of a one field hiding another
if exclude_hidden_fields:
self.fields = [field for field in self.fields if field.get("Hidden", "FALSE") == "FALSE"]

self._sp_cols = {i['Name']: {'name': i['DisplayName'], 'type': i['Type']} for i in self.fields}
self._disp_cols = {i['DisplayName']: {'name': i['Name'], 'type': i['Type']} for i in self.fields}

Expand Down

0 comments on commit ce8f034

Please sign in to comment.