Comments (15)
Hmmm. Has item creation worked for you previously? (also, I removed the API key from your posted output)
from pyzotero.
It did when I first started testing out pyzotero, and collection deletion certainly worked. I'll experiment some more and try to pin this down.
And thanks for removing the key from the output here-- I remembered to catch it in the gist.
from pyzotero.
Basic creation works:
> > > server = zotero.Zotero('5770', '[key]')
> > > server
> > > <pyzotero.zotero.Zotero object at 0xb781680c>
> > > zitem = server.item_template("manuscript")
> > > zitem>>> zitem
> > > {u'numPages': '', u'itemType': u'manuscript', u'language': '', u'title': '', u'url': '', u'manuscriptType': '', u'rights': '', u'libraryCatalog': '', u'shortTitle': '', u'extra': '', u'accessDate': '', u'tags': [], u'place': '', u'notes': [], u'date': '', u'abstractNote': '', u'creators': [{u'lastName': '', u'creatorType': u'author', u'firstName': ''}], u'archiveLocation': '', u'archive': '', u'callNumber': ''}
> > > zitem["title"] = "ну?"
> > > zitem
> > > {u'numPages': '', u'itemType': u'manuscript', u'language': '', u'title': '\xd0\xbd\xd1\x83?', u'url': '', u'manuscriptType': '', u'rights': '', u'libraryCatalog': '', u'shortTitle': '', u'extra': '', u'accessDate': '', u'tags': [], u'place': '', u'notes': [], u'date': '', u'abstractNote': '', u'creators': [{u'lastName': '', u'creatorType': u'author', u'firstName': ''}], u'archiveLocation': '', u'archive': '', u'callNumber': ''}
> > > out = server.create_items([zitem])
> > > out
> > > [{u'itemType': u'manuscript', u'extra': u'', u'abstractNote': u'', u'archive': u'', u'title': u'\u043d\u0443?', u'archiveLocation': u'', u'etag': u'327ebd24f3a2d83bb8f820fdfc0cdacc', u'updated': 'Sat, 16 Jul 2011 11:29:34 MSK', u'tags': [], u'accessDate': u'', u'manuscriptType': u'', u'libraryCatalog': u'', u'callNumber': u'', u'key': u'QCWW78ZM', u'date': u'', u'numPages': u'', u'group_id': u'5770', u'shortTitle': u'', u'language': u'', u'rights': u'', u'url': u'', u'place': u'', u'creators': []}]
> > >
> > > ```
> > > ```
from pyzotero.
It's an issue in the type
field. When I removed yours ("\u0440\u0443\u043a\u043e\u043f\u0438\u0441\u044c"
), I was able to create the item. So it seems the server is fussy about what it accepts in that field.
from pyzotero.
This is, as I expected, just a mistake on my part. The proper field for type on manuscripts is "manuscriptType" (ridiculous but true).
Would it be possible for pyzotero to do integrity checks, since it has the item template and can presumably can anticipate such errors (especially since Zotero's error seems to be pretty opaque)?
from pyzotero.
Hmmm. I'll have to think about how best to do it. I'm not currently storing the item-creation templates, but I suppose I can do that, check the user-created dicts, and raise an error if there are unknown fields in the item.
from pyzotero.
The integrity check could be made optional, if you think it will add unnecessary overhead. Maybe a new check_fields method?
The receiving API is pretty strict about things like this, and people will frequently trip up on field names, creator roles, and the like.
from pyzotero.
OK, I have this working. But I've now realised that there are fields missing from the data returned by a call to /itemFields
(notes, tags, itemType, and creators), so an update will have to wait a little while, until I figure out whether they've been omitted on purpose.
from pyzotero.
I think that that's because the item types and creator types are returned by different calls: http://www.zotero.org/support/dev/server_api/write_api#get_valid_creator_types_for_an_item_type
from pyzotero.
Yes, but I'm not sure that behaviour is correct, since creators
is a valid item field. I'll ask on zotero-dev shortly.
from pyzotero.
We could just consider those fields OK for all item types, since they are universal. I'm glad to work on this and test it myself, if you want to commit what you've written so far.
from pyzotero.
There's now a check_items()
method: 1187a40
You can pass it a list of one or more dicts, and it'll compare them to the output of a call to item_fields()
, raising a KeyError
detailing the unknown keys if any are found.
from pyzotero.
Looks like you've added it to the docs as check_keys
...
I'll try adding this to my script.
from pyzotero.
Fixed now. You'll have to pip install directly from the dev branch of the repo, btw. I'll merge it into master and upload it to pypi once I'm happy that it's behaving as it should.
from pyzotero.
This works for me! Closing the ticket, since it wasn't a bug in pyzotero to begin with, and now I have a way to avoid it.
from pyzotero.
Related Issues (20)
- HTTP response is stored in Zotero.request property
- report requests.exceptions.HTTPError: 403, when use attachment_simple() function HOT 1
- Can't retrieve groups metadata.
- Feature Request - Add tags and modify comments of annotations HOT 8
- Missing git tag for 1.5.3 HOT 2
- How can I access the link of an attachment file in Zotero and update it? HOT 4
- Using search/request parameters HOT 2
- Software itemType HOT 2
- Wrong documentation for combining tags via logical "OR" operator?
- Using collection_items function to retrieve more than 100 items HOT 2
- Moving Collections from my library to group library HOT 2
- How to access my notes from zotero?
- Efficiently fetch attachments by path HOT 8
- Bad Gateway errors HOT 5
- .txt files in attachment are dumped in an unreadable format HOT 4
- dump and file methods can't find files. item calls work fine. HOT 2
- Markdown formatting and line breaks not recognized when creating notes HOT 3
- switch to httpx as the underlying HTTP library HOT 1
- Websockets / Streaming HOT 2
- Pyzotero.dump() not working. Response: Not found HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from pyzotero.