# Path: sitetree/utils.py
# def tree(alias: str, title: str = '', items: Sequence['TreeItemBase'] = None, **kwargs) -> 'TreeBase':
#     """Dynamically creates and returns a sitetree.
# 
#     :param alias:
#     :param title:
#     :param items: dynamic sitetree items objects created by `item` function.
#     :param kwargs: Additional arguments to pass to tree item initializer.
# 
#     """
#     tree_obj = get_tree_model()(alias=alias, title=title, **kwargs)
#     tree_obj.id = generate_id_for(tree_obj)
#     tree_obj.is_dynamic = True
# 
#     if items is not None:
#         tree_obj.dynamic_items = []
# 
#         def traverse(items):
#             for item in items:
#                 item.tree = tree_obj
#                 tree_obj.dynamic_items.append(item)
#                 if hasattr(item, 'dynamic_children'):
#                     traverse(item.dynamic_children)
# 
#         traverse(items)
# 
#     return tree_obj
# 
# def item(
#         title: str,
#         url: str,
#         children: Sequence['TreeItemBase'] = None,
#         url_as_pattern: bool = True,
#         hint: str = '',
#         alias: str = '',
#         description: str = '',
#         in_menu: bool = True,
#         in_breadcrumbs: bool = True,
#         in_sitetree: bool = True,
#         access_loggedin: bool = False,
#         access_guest: bool = False,
#         access_by_perms: Union[TypePermission, List[TypePermission]] = None,
#         perms_mode_all: bool = True,
#         **kwargs
# ) -> 'TreeItemBase':
#     """Dynamically creates and returns a sitetree item object.
# 
#     :param title:
# 
#     :param url:
# 
#     :param children: children for tree item. Children should also be created by `item` function.
# 
#     :param url_as_pattern: consider URL as a name of a named URL
# 
#     :param hint: hints are usually shown to users
# 
#     :param alias: item name to address it from templates
# 
#     :param description: additional information on item (usually is not shown to users)
# 
#     :param in_menu: show this item in menus
# 
#     :param in_breadcrumbs: show this item in breadcrumbs
# 
#     :param in_sitetree: show this item in sitetrees
# 
#     :param access_loggedin: show item to logged in users only
# 
#     :param access_guest: show item to guest users only
# 
#     :param access_by_perms: restrict access to users with these permissions.
# 
#         This can be set to one or a list of permission names, IDs or Permission instances.
# 
#         Permission names are more portable and should be in a form `<app_label>.<perm_codename>`, e.g.:
#             my_app.allow_save
# 
# 
#     :param perms_mode_all: permissions set interpretation rule:
#                 True - user should have all the permissions;
#                 False - user should have any of chosen permissions.
# 
#     """
#     item_obj = get_tree_item_model()(
#         title=title, url=url, urlaspattern=url_as_pattern,
#         hint=hint, alias=alias, description=description, inmenu=in_menu,
#         insitetree=in_sitetree, inbreadcrumbs=in_breadcrumbs,
#         access_loggedin=access_loggedin, access_guest=access_guest,
#         **kwargs)
# 
#     item_obj.id = generate_id_for(item_obj)
#     item_obj.is_dynamic = True
#     item_obj.dynamic_children = []
# 
#     item_obj.permissions = SimpleLazyObject(lambda: clean_permissions(access_by_perms))
#     item_obj.access_perm_type = item_obj.PERM_TYPE_ALL if perms_mode_all else item_obj.PERM_TYPE_ANY
# 
#     if access_by_perms:
#         item_obj.access_restricted = True
# 
#     if children is not None:
#         for child in children:
#             child.parent = item_obj
#             item_obj.dynamic_children.append(child)
# 
#     return item_obj


from sitetree.utils import tree, item


sitetrees = (
    tree('books', items=[
        item('Books', '/books/', url_as_pattern=False, children=[
            item('{{ book.title }}', 'books-details', in_menu=False, in_sitetree=False),
            item('Add a book', 'books-add'),
        ])
    ]),

# Path: sitetree/utils.py
# def tree(alias: str, title: str = '', items: Sequence['TreeItemBase'] = None, **kwargs) -> 'TreeBase':
#     """Dynamically creates and returns a sitetree.
# 
#     :param alias:
#     :param title:
#     :param items: dynamic sitetree items objects created by `item` function.
#     :param kwargs: Additional arguments to pass to tree item initializer.
# 
#     """
#     tree_obj = get_tree_model()(alias=alias, title=title, **kwargs)
#     tree_obj.id = generate_id_for(tree_obj)
#     tree_obj.is_dynamic = True
# 
#     if items is not None:
#         tree_obj.dynamic_items = []
# 
#         def traverse(items):
#             for item in items:
#                 item.tree = tree_obj
#                 tree_obj.dynamic_items.append(item)
#                 if hasattr(item, 'dynamic_children'):
#                     traverse(item.dynamic_children)
# 
#         traverse(items)
# 
#     return tree_obj
# 
# def item(
#         title: str,
#         url: str,
#         children: Sequence['TreeItemBase'] = None,
#         url_as_pattern: bool = True,
#         hint: str = '',
#         alias: str = '',
#         description: str = '',
#         in_menu: bool = True,
#         in_breadcrumbs: bool = True,
#         in_sitetree: bool = True,
#         access_loggedin: bool = False,
#         access_guest: bool = False,
#         access_by_perms: Union[TypePermission, List[TypePermission]] = None,
#         perms_mode_all: bool = True,
#         **kwargs
# ) -> 'TreeItemBase':
#     """Dynamically creates and returns a sitetree item object.
# 
#     :param title:
# 
#     :param url:
# 
#     :param children: children for tree item. Children should also be created by `item` function.
# 
#     :param url_as_pattern: consider URL as a name of a named URL
# 
#     :param hint: hints are usually shown to users
# 
#     :param alias: item name to address it from templates
# 
#     :param description: additional information on item (usually is not shown to users)
# 
#     :param in_menu: show this item in menus
# 
#     :param in_breadcrumbs: show this item in breadcrumbs
# 
#     :param in_sitetree: show this item in sitetrees
# 
#     :param access_loggedin: show item to logged in users only
# 
#     :param access_guest: show item to guest users only
# 
#     :param access_by_perms: restrict access to users with these permissions.
# 
#         This can be set to one or a list of permission names, IDs or Permission instances.
# 
#         Permission names are more portable and should be in a form `<app_label>.<perm_codename>`, e.g.:
#             my_app.allow_save
# 
# 
#     :param perms_mode_all: permissions set interpretation rule:
#                 True - user should have all the permissions;
#                 False - user should have any of chosen permissions.
# 
#     """
#     item_obj = get_tree_item_model()(
#         title=title, url=url, urlaspattern=url_as_pattern,
#         hint=hint, alias=alias, description=description, inmenu=in_menu,
#         insitetree=in_sitetree, inbreadcrumbs=in_breadcrumbs,
#         access_loggedin=access_loggedin, access_guest=access_guest,
#         **kwargs)
# 
#     item_obj.id = generate_id_for(item_obj)
#     item_obj.is_dynamic = True
#     item_obj.dynamic_children = []
# 
#     item_obj.permissions = SimpleLazyObject(lambda: clean_permissions(access_by_perms))
#     item_obj.access_perm_type = item_obj.PERM_TYPE_ALL if perms_mode_all else item_obj.PERM_TYPE_ANY
# 
#     if access_by_perms:
#         item_obj.access_restricted = True
# 
#     if children is not None:
#         for child in children:
#             child.parent = item_obj
#             item_obj.dynamic_children.append(child)
# 
#     return item_obj


# Path: demo/demo/sitetrees.py
from sitetree.utils import tree, item



sitetrees = (
    tree('books', items=[
        item('Books', '/books/', url_as_pattern=False, children=[
            item('{{ book.title }}', 'books-details', in_menu=False, in_sitetree=False),
            item('Add a book', 'books-add'),
        ])
    ]),

    tree('other', items=[