New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Insufficient support for Multireddits #344
Comments
I'm adding some TODO items for this task. I would suggest starting simple and getting the list of a multis working first (make a single PR for that). Then make a new PR for each feature. Tests will need to be added for each function to ensure it works.
|
Hi bboe, I'm glad to be working on this! I will be ready for the initial PR as soon as get_my_multis() is working and I make test cases, but I have a few questions for you:
Thanks! |
A few things first. The branches you are working on do not align with PRAW's branches, which will make creating a PR very difficult. Fixing this will be kind of a pain. Step 1, is to make sure that your master branch is always in-sync with the primary master branch. First, assuming you don't have any extra work on your master branch, run the following:
There are a number of ways to fix your multi-reddit branch. We're going to do it by creating a new branch (so we have the original in case we mess up):
Unless you know you specifically changed something in the second section, then use only what's from the first section. Then, for each conflicted file run Finally, once your new branch is fixed, push that branch to your remote Once you've fixed that, for #1, try passing in |
Dammit, I hadn't even thought about looking for changes first, you're way too patient with me. Well, everything is in the right place now. Problem 1 still isn't happy. Line 491 produces a list, and it's immediately tossed into 498 which is trying to do list.get(). There will need to be a special case for multis that knows what to do with the list. I could probably make a miniature version of get_content() specifically for multireddits, and put it right inside the get_my_multis function, or I could do something inside of get_content() itself, but that's why I wanted to ask for your recommendation. I'm not exactly stuck yet, but I want to make sure I do this right. I have solved out problem 2 by adding this line to the end of the Multireddit constructor, so that's pretty cool.
You may have a preferred way of doing this, I'm happy to change it. I don't exactly understand at what point the text for things like "author" are converted into |
Given that Maybe make a comment as to why |
I just filed https://github.com/reddit/reddit/issues/1177. Let's proceed as I indicated for now, and hopefully in the future we'll be able to use |
Thanks, that's exactly the answer I was looking for. Function get_my_multis is now fully operational. I have created a multireddit on your test user, http://reddit.com/user/pyapitestuser2/m/publicempty, which should remain public and empty to be used in the tests. Edit: Pull 345 closed. Will start on MR creation, copying deletion for future pull |
Hi bboe I'm trying to create multireddits, but my function appears to be tripping over the cache. One of the POST params is a list and it's creating "Unhashable Type" errors when checking the praw cache.
This is not an issue with the API because I had a typo in the Any advice? Also, I figure I should ask while I have your attention: While Submission, Account and Stylesheet-Image deletion each have special With your help on these two questions it's only a matter of time until I have Create, Delete, Copy and Rename ready to go (This time I'll make sure I'm up-to-date and squashed). Thanks again! |
Thanks for all the great work. |
When you get a chance, can you rename |
Hmm, last night I also tried setting The I agree with the decision to rename. |
I'll take a look later at your caching issue unless you figure it out. I'm On Mon, Nov 24, 2014 at 9:25 AM, voussoir notifications@github.com wrote:
|
This StackOverflow taught me something
Because the
The reddit source code is definitely expecting a list full of dicts, so my options are a) Give the cache a specialized version of data while sending the actual data to reddit b) Disable caching for create_multireddit entirely, which no other function seems to do. c) Raise an issue on their github and wait for change. Create_multireddit is not the kind of operation that really needs caching, but it seems weird that such a core function of PRAW should change for this fringe method. Why do they want dicts of a single variable anyway?! What are your thoughts? In the meantime, I'll try MR deletion. |
Great observation with regard to the dictionary. Why not add this |
I'm really lost now :(
I caught the error as a variable, and found that the request data didn't appear to carry the subreddit list anymore:
While taking shots in the dark, I also gave this a try because I don't know how closely it's supposed to resemble the API page:
I'm really out of ideas on what to try next. I'm also having trouble deleting MRs but let's tackle one thing at a time I guess. Edit: Realized that the FrozenDict was producing an incorrect hash. Give me a minute to investigate. Edit: I fixed that part, but I'm still just stuck. The FrozenDict isn't behaving as expected with the other elements of praw. The keys and values aren't moving around correctly. |
I'll take a peak in a bit. |
I think this endpoint may take json data, which is going to be a bit of a pain to implement. Feel free to keep trying, but if my hunch is right then it's going to require some internal restructuring. |
Feels like Multireddits have come from a different planet or something. I know you filed that issue last week (which hasn't seen any response yet), but I feel like the API itself is partly at fault. How silly that they want a list of single-variable dicts in a format unlike anything else I can think of. I should ask them about it. In case you were curious, my attempts at Deletion resulted in 403 Forbidden, "Please login to do that" errors, though I hadn't modified the headers or cookies in any way and the request was carrying my modhash. It got pretty disorienting figuring out the way requests are bounced around through praw, but I ended up inside internal.py wondering why POST methods pass and DELETE methods fail. I wouldn't worry about solving this immediately but if the issue is obvious it'd be nice to knock out. |
Okay, I got multireddit creation working. I did some refactoring. Please pull in the commit I added from this branch: https://github.com/praw-dev/praw/tree/multireddit You should be able to get delete's working from here. Happy Thanksgiving (if you're in the US). Thanks again for all the great work. |
Wow, awesome! I wasn't expecting a turnaround that fast. I'll start cooking up the next PR. Enjoy your Thanksgiving Edit: I'm going to make Edit: Here are the features I will implement and test for the upcoming PR. Let me know if there's anything else you'd like to see
The PR after that will consist of adding and dropping subreddits from multis. Then, the modification of Multireddit properties. |
Can I have your opinion on the copy function? I'm not sure how I want to lay out the parameters to make it quick and friendly, and give it a useful docstring Here's what I have now
This gives the following:
I know organizing the parameters like this is uncommon (And potentially against Pep8?), but I think it gives more flexibility than the alternatives. Pretty much the only way to misuse this function is to copy your own multireddit without explicitly setting Does this system assume / imply too much? Edit: It's working great so far. I'm quite happy with this method. Edit: Copy and Rename are complete, now I'm left with this whiny Delete method. Do you have any idea why I might get 403 Forbidden, "Please login to do that" despite the request carrying my cookie and modhash? |
It should only be a function on existing Multis. I'm no longer in favor of
|
Oh, that's unexpected, though I guess it does simplify things. This also means that copying, renaming, and deleting a multireddit will all require a minimum of 2 calls when it could be done in 1. Are you sure that's the right move? What are the concerns regarding top-level functions? I feel it will make writing more cumbersome without benefit. Since the functions are already available from the Object side, removing the Toplevel side only gives users less options, which I don't think is helpful to anyone. |
It won't actually require two calls because |
In that case, it looks like Multireddits aren't responding to Furthermore, I still don't understand the concern / perceived benefits? |
First Regarding whether or not to add more For the most part PRAW has currently supported both approaches. The reasoning for this is simply backwards compatibility with older versions of PRAW. If I had more time, I would remove all the unnecessary top-level functions in the PRAW3 release, however, I don't have that time. What I can do it prevent the addition new top-level functions, and that's what I intend to do. |
As the Owner, I've got to respect your decision there, it wouldn't be right for me to force you into a debate about your own project. However, for me to write this change would be to shoot myself in the foot. It may be worthwhile to get the opinions of other PRAW users and see if they consider the |
I don't understand how making the addition shoots yourself in the foot. You can still accomplish exactly what you want to do; the syntax is just slightly different. |
Users who prefer the It's turning 1 click into 2. Like if sending a reddit PM permanently required you to go to their user page and click "send a message" instead of being able to type their name straight into the compose box. Or disabling the ability to use I've always considered the Redditor objects, etc, to be containers for information, and the ability to use Redditor.send_message() function is icing on the cake. Making My opinions on this kind of UX are generally more extreme than the average person's, which is why it may help to hear from other PRAW users. Sorry for being a pain in the ass. |
That's good feedback. I agree that
I would argue that it's more common, however, to perform an action dynamically based on data returned from a PRAW request. Thus you'll often see:
which is slightly simpler than:
not to mention that the documentation could confuse people (and the code is more complicated) and they may think they need to call the function like:
Perhaps we can support a way to enable Also the example you provide actually is a great reason why I prefer there to be only one way to do something because the way we use the same documentation strings for these two methods has resulted in a number of issues brought up on /r/redditdev. |
This is sacrificing clarity and readability for fitting characters on a line, especially since Redditor and Message are both objects. "Should I be using The alternative to the line-length issue is:
which, again... 1 click into 2 here.
I'd agree, and that's why I consider Most people don't know the in-depth Windows hotkeys, but they're a godsend to those that do. They speed up the process if you are willing to learn how to use them, and don't cause any grief if you are fine with using a mouse. When learning how to use a computer, you'll be taught with a mouse, so PRAW can be taught with your OOP. The idea of a Sometimes I'll use commandline PRAW to do things that I could normally do in the browser, because the API provides all sorts of wonderful shorthand ways of doing things. The script shouldn't have artificial roadblocks to slow me down. I realize this all sounds very melodramatic but I do not wish to rewrite it. |
Alright I'm out of clues, deletion is still returning 403 "Please login to do that" despite carrying my cookie and modhash. By the time the Request object leaves Here is prepare_request, and here is delete_multireddit Here are some screenshots relating my tales of woe. Chrome and PRAW are both hitting the same URL with roughly the same amount of information. As you can see in copy_multireddit and rename_multireddit, some multi operations have a special endpoint despite contrary help from the API page! I tried assuming the same for
This attempt goes against what I was seeing in Chrome, but the API page made me think I'm supposed to pass the multipath in data. Interestingly, if you visit http://www.reddit.com/api/multi/delete, it actually has something there, unlike copy and rename. I'm not sure what to make of that. What obvious hint am I missing here? We can resume arguing about toplevels just as soon as this endpoint stops giving me a hard time. |
Any status on this issue? I've been trying to clean some stuff up for a PRAW3 release and wanted to see what your desire to get this in is. |
I was having trouble understanding the JSON format that reddit wanted, but I've just created several multireddits and I think I have a much better handle on it overall. I'll definitely be able to put together a PR with at least some basic mr features. |
Fantastic. Thanks for the efforts. |
I'm going to consider this resolved. A few more tweaks and tests, otherwise it should be good to go. Thanks! |
I've done several searches throughout the repo, and as far as I can tell there aren't any resources for handling Multireddits. I'd love to help develop this if a project manager can get some groundwork started. Any plans? (Is there a to-do file somewhere?)
Multireddit API
The text was updated successfully, but these errors were encountered: