Anvil Documentation Suggestions [ON-GOING]

I think the methods outlined in this docs section (as below) is may be missing from the API reference

GoogleMap.InfoWindow

Display a popup on the map at a particular position.

Properties

  • position: GoogleMap.LatLng - Specifies the position of the popup. Not required if this popup is anchored to a component (see the open method, below).
  • content: anvil.Component | string - The content of the popup. Can be a string, or an Anvil Component.

Methods

  • open(map, [anchor]) - Display this InfoWindow on the specified map. If anchor is specified, the InfoWindow does not need to have its own position property set.
  • close() - Hide this InfoWindow. The user can also cause this to happen by clicking the close button in the top-right of the popup.

Also please could I request this thread be pinned so it can be found easily (and yes I also now have it as a bookmark :slight_smile: )

2 Likes

The example code here seems wonky to me:

@anvil.server.callable
def login_with_password(username, password):
  user = app_tables.users.get(username=username)
  if user is not None and \
       bcrypt.hashpw(password, user['password_hash']).decode() == user['password_hash']:
    anvil.users.force_login(user)
    return user

Shouldn’t it be something like:

import bcrypt

@anvil.server.callable
def login_with_password(username, password):
  user = app_tables.users.get(email=username)
  if (user is not None) and \
       bcrypt.checkpw(password.encode('utf-8'), user['password_hash'].encode('utf-8')):
    anvil.users.force_login(user)
    return user
  else:
    return None

Please could the docs include something on session_id as per this post

1 Like
3 Likes

More Documentation on PDFRenderer

I was looking to reduce the pdf size generated by PDFRenderer and went to the docs! The quality optional argument looks like the worker for the job, but I am sure what the acceptable options are, based off of the docs. I found a couple of post showing different quality options I am trying, but having it explained clearly in the docs would be great!

The other options would be great to get the explanations as well.

Thank you anvil team! :slight_smile:

1 Like

See

1 Like

The options actually are listed in the main documentation (though not in the API docs) here:

1 Like
1 Like
1 Like

It would have helped me if the anvil.server Globals section specified their type: that context is an instance of anvil.server.CallContext (and likewise for request).

1 Like

A couple users have recently thought they needed to purchase their own SSL certificate to use a custom domain, so it might be good to add something to the publish interface or docs explicitly saying that that is not necessary.

5 Likes
2 Likes
1 Like

Please clarify which code and which database gets cloned. Based on my testing just now, it’s the master branch and the Debug database, but it would be helpful to have that spelled out.

When trying to implement Stripe charging on the server. I followed the documentation code below…

@anvil.server.callable
def add_card(token, email):
  user = anvil.users.get_user()

  if user['stripe_id'] is None:
    customer = anvil.stripe.new_customer(email, token)
    user['stripe_id'] = customer['id']
  else:
    customer = anvil.stripe.get_customer(user['stripe_id'])

  customer.add_token(token)

I think the last code line - customer.add_token(token) is in the wrong place. Should it not be…

@anvil.server.callable
def add_card(token, email):
  user = anvil.users.get_user()

  if user['stripe_id'] is None:
    customer = anvil.stripe.new_customer(email, token)
    user['stripe_id'] = customer['id']
  else:
    customer = anvil.stripe.get_customer(user['stripe_id'])
    customer.add_token(token)

as the adding of token is only applicable in the case of an existing Stripe customer found. For a new Stripe customer is created with a token added.

1 Like

When saving an older app to GitHub, I happened to have a feature branch checked out in the IDE. I was surprised to find that that branch was thus set to be the default branch in GitHub, rather than master. (It’s not a huge inconvenience to change that in GitHub, assuming doing so isn’t going to mess up the Anvil integration, but still.) It would be helpful to add a heads-up to that effect to the docs, if I’m understanding correctly how it worked: that the currently checked-out branch when saving to GitHub is set to the default in the GitHub repo.

2 Likes

The get_url(False) option for media files in data tables:

1 Like

The wellknown_endpoint decorator:

1 Like