Пример #1
0
def read_folder_and_files_alt(context, list_title):
    """Read a folder example"""
    list_obj = context.web.lists.get_by_title(list_title)
    qry = CamlQuery.create_all_items_query()
    items = list_obj.get_items(qry)
    context.execute_query()
    for cur_item in items:
        print("File name: {0}".format(cur_item.properties["Title"]))
Пример #2
0
def print_view_items(ctx):
    """Example demonstrates how to retrieve View items"""

    list_object = ctx.web.lists.get_by_title(list_title)
    # 1.get View query
    view = list_object.views.get_by_title(view_title)
    ctx.load(view, "ViewQuery")
    ctx.execute_query()

    # 2.get items for View query
    qry = CamlQuery()
    qry.ViewXml = "<View><Where>{0}</Where></View>".format(
        view.properties["ViewQuery"])
    items = list_object.get_items(qry)
    ctx.load(items)
    ctx.execute_query()

    for item in items:
        print("Item title: {0}".format(item.properties["Title"]))
Пример #3
0
 def get_items(self):
     """Get list items per a view """
     if not self.viewQuery:
         self.context.load(self, "ViewQuery")
         self.context.afterExecuteOnce += self._get_items_inner
         return self._parent_list.items
     else:
         qry = CamlQuery.parse(self.viewQuery)
         items = self._parent_list.get_items(qry)
         return items
Пример #4
0
 def get_items(self, caml_query=None):
     """Returns a collection of items from the list based on the specified query.
     :type caml_query: CamlQuery
     """
     if not caml_query:
         caml_query = CamlQuery.create_all_items_query()
     items = ListItemCollection(self.context,
                                ResourcePath("items", self.resourcePath))
     qry = ServiceOperationQuery(self, "GetItems", None, caml_query,
                                 "query", items)
     self.context.add_query(qry)
     return items
Пример #5
0
 def get_query(self):
     return CamlQuery.create_custom_query(self.create_query())
Пример #6
0
 def _get_items_inner(self, target_view):
     caml_query = CamlQuery.parse(target_view.viewQuery)
     qry = ServiceOperationQuery(self._parent_list, "GetItems", None,
                                 caml_query, "query",
                                 self._parent_list.items)
     self.context.add_query(qry)