parameters: ()
return_statement: return dict(images=images,
                  manager_toolbar=manager_toolbar)
docstring: Allows to access the "photo_gallery" component
docstring_summary: Allows to access the "photo_gallery" component
docstring_tokens: Allows to access the photo_gallery component
function: def photo_gallery():
      """
      Allows to access the "photo_gallery" component
      """
      import random
      manager_toolbar = ManagerToolbar('image')
      MAX_IMAGES = WEBSITE_PARAMETERS.max_gallery_images_to_show if WEBSITE_PARAMETERS.max_gallery_images_to_show is not None else 5
      page = db.page(request.vars.container_id)
      if page:
          q=(db.image.show_in_gallery==1) & (db.image.page==page)
      else:
          q=(db.image.show_in_gallery==1)
      if db(q).isempty(): #if there are no images related to the page, we select all available images
          q=(db.image.show_in_gallery==1)
      images = sorted(db(q).select(cache=(cache.ram, 60), cacheable=True), key=lambda *args: random.random())[:MAX_IMAGES]
      
      return dict(images=images,
                  manager_toolbar=manager_toolbar)
function_tokens: def photo_gallery ( ) : import random manager_toolbar = ManagerToolbar ( 'image' ) MAX_IMAGES = WEBSITE_PARAMETERS . max_gallery_images_to_show if WEBSITE_PARAMETERS . max_gallery_images_to_show is not None else 5 page = db . page ( request . vars . container_id ) if page : q = ( db . image . show_in_gallery == 1 ) & ( db . image . page == page ) else : q = ( db . image . show_in_gallery == 1 ) if db ( q ) . isempty ( ) : #if there are no images related to the page, we select all available images q = ( db . image . show_in_gallery == 1 ) images = sorted ( db ( q ) . select ( cache = ( cache . ram , 60 ) , cacheable = True ) , key = lambda * args : random . random ( ) ) [ : MAX_IMAGES ] return dict ( images = images , manager_toolbar = manager_toolbar )