Reputation: 20350
How does one work with string resources in python/gae in eclipse+pydev environment? looking for something that is the equivalent of this link. Also, what is the recommended approach for working with large strings? Create a text file as part of your app and use file I/O, or something else?
Upvotes: 0
Views: 2213
Reputation: 139
for those still seeking a solution for string resources file on GAE and Python (2.7), I used a YAML formated file:
create a file named "strings.txt" (for example), it's content can be something like this:
level_1_name: this is a text
# this is a comment
test:
- testtitle: test title
testtitlechild: testtitlechild
place this on the bottom of your main application file:
# strings file (YAML format) initialization
strings = yaml.load(open("strings.txt", "r"))
then you get 'strings' as dict, using it goes as follows:
strings["level_1_name"]
Upvotes: 2
Reputation: 14175
Assuming "string resource" is a fancy name for text-file, you have three choices;
If your large text file is read only then you can bundle it along with your other application files and access it as you would normally (via open()
or similar method).
If your application needs to write lots of text-data then you will have to store it in the datastore using a TextProperty but beware there are limits on the amoount of data that can be written to the datastore in one go (currently 1MB) ... OR...
Use the Blobstore API to read/write files
Upvotes: 1