question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

List schema fields

See original GitHub issue

I have a schema that I am filtering using query attributes. I want to remove invalid field names before dumping the schema, but I cannot figure out how to properly list the fields that are part of my schema. I tried JournalListSchema.dict.keys() which worked on my local machine, but when I deployed it to production the fields were not listed. Any ideas on how to do this?

Here is my example code:

# schema
class JournalListSchema(ma.Schema):
    issn = fields.String()
    title = fields.String()

# view
attrs = request.args.get("attrs")
only = attrs.split(",")


for field in only:
    if field not in JournalListSchema.__dict__.keys():
        only.remove(field)

journal_list_schema = JournalListSchema(only=only)
journals_dumped = journal_list_schema.dump(journals.items, many=True)

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
caseydmcommented, Jul 20, 2021

Another thing you could to is use webargs to validate the inputs in the first place. You’d have to to declare explicitly which fields you allow the user to select, which may involve duplication, though.

Yes I did consider that but thought it’s a bit too much overhead for now.

1reaction
lafrechcommented, Jul 20, 2021

Another thing you could to is use webargs to validate the inputs in the first place. You’d have to to declare explicitly which fields you allow the user to select, which may involve duplication, though.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Field element (List) | Microsoft Learn
Defines the internal data types used in the list infrastructure of a SharePoint website. A field is a column or attribute of information ......
Read more >
Schemas and Types - GraphQL
The most basic components of a GraphQL schema are object types, which just represent a kind of object you can fetch from your...
Read more >
List all schemas - ActiveCampaign
Retrieve all schemas available within an account. Users are encouraged to leverage the ?showFields=all query parameter when programmatically creating new schema ...
Read more >
SharePoint Field Schema XML Examples
SharePoint Field Schema XML Examples. By Gunjan Datta in field. This post will give examples of SharePoint field schema xml.
Read more >
GraphQL schema basics - Apollo GraphQL Docs
Each field returns data of the type specified. A field's return type can be a scalar, object, enum, union, or interface (all described...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found