pauamma: Cartooney crab holding drink (Default)
Res facta quae tamen fingi potuit ([personal profile] pauamma) wrote in [site community profile] dw_dev_training2011-09-21 12:11 pm
Entry tags:

Jumping in with questions and answers

I just came across To Answer, Or Not To Answer. The gist of it is: someone asked "Should I answer a perl question when I'm not sure of the answer or when I can only answer part of the question?" and got overwhelming "yes" answers (and very good suggestions on how to handle uncertainty), because even if your answer doesn't help the person asking, researching your answer (and thinking about the question) may well help you. So as an experiment, I'd like to try something similar in this entry:

- You may ask any dev-related question you have in a comment. (It doesn't even need to be about Dreamwidth, although if it involves a language/library/framework/database Dreamwidth doesn't use, you will probably get answers pointing that out and suggesting a better place to ask.)
- You may also answer any question, using the guidelines given in the discussion I linked to above.

If this works, I'll try to make it a regular feature of this community. (How often should it happen?)
jeshyr: Blessed are the broken. Harry Potter. (Default)

[personal profile] jeshyr 2011-09-21 11:57 am (UTC)(link)
Ohhh, that's a very cool idea!! I've been hesitant about answering stuff because I'm still very newbie-ish (it took me an hour to set up a 'map' function yesterday for a one line patch) and I have weird splinter-knowledge. It's good to have a "safe" spot where I know somebody with more experience will come and correct me if needs be!

Weird thing I wonder about: What does "stc" stand for in the directory naming system? There are two (I think? at least one!) directory called "stc" in the code and I don't know what they're for. I'm trying to figure out the function of the directories for myself and documenting in but there are so many I don't know!
denise: Image: Me, facing away from camera, on top of the Castel Sant'Angelo in Rome (Default)

[staff profile] denise 2011-09-21 03:09 pm (UTC)(link)
Not positive (the true answer may be lost to time) but I think it's 'static'.
sophie: A cartoon-like representation of a girl standing on a hill, with brown hair, blue eyes, a flowery top, and blue skirt. ☀ (Default)

[personal profile] sophie 2011-09-21 05:22 pm (UTC)(link)
That would make sense! I had wondered the same thing.

[edit: I took a look at the LiveJournal repo. is the appropriate changeset where the htdocs/stc directory started on 13th July 2005, and the description is "Move floating .css file(s) to a more appropriate place."

Based on that, yeah, I'd say it was likely that "stc" means "static".]
Edited 2011-09-21 17:29 (UTC)
foxfirefey: Fox stealing an egg. (mischief)

[personal profile] foxfirefey 2011-09-22 12:02 am (UTC)(link)
Haha, I've always wondered that one too.
skakri: (Default)

[personal profile] skakri 2011-09-21 07:36 pm (UTC)(link)
I have a question. Hypothetically speaking - could external site (cross-posting) controller be modified to support Twitter / other social platform? How should I implement that, as I'd have to have a separate table for user id => auth_hash. I'm currently learning how to get/parse/use data via Perl (previously I've used only PHP/AWK/bash for my scripting purposes; If I have a question about some controller, I mostly use
find /home/dw/ -type f | xargs grep 'what was I looking for' | less

Another one - if I define a "beta feature", could I somehow use
 LJ::BetaFeatures->user_in_beta( $u => "featurename" );
in my .tt template to conditionally load needed JS assets (I like the idea about "real time web" - as I've used to node.js and, I'd like to try to implement real time comments)?
denise: Image: Me, facing away from camera, on top of the Castel Sant'Angelo in Rome (Default)

[staff profile] denise 2011-09-21 08:11 pm (UTC)(link)
We have a bug open to add Twitter crossposting (and Facebook, and Wordpress, and Movable Type, and and etc) -- the issue with each of them is that you have to a) implement the remote site's posting protocol and b) work out how it would map to DW. (For instance with Twitter, figuring out how you would handle the metadata like current mood/music, figuring out what to do if the post is over 140 characters, etc.) So yes, it's possible! It would go into cgi-bin/DW/External/XPostProtocol and get hooked in somewhere (I'm not sure where). (And if you get it working, give us the patch. *G*)

I don't know TT or how to work the beta features, so I'll pass on that!
exor674: Computer Science is my girlfriend (Default)

[personal profile] exor674 2011-09-22 12:47 am (UTC)(link)
or in this case, we'd extend the existing plugin. We really do not need multiple plugins for just one purpose.

fu: Close-up of Fu, bringing a scoop of water to her mouth (Default)

[personal profile] fu 2011-09-22 02:47 am (UTC)(link)
I like the first one! It's very simple, and is also easiest to find/remove later once something is out of beta.
skakri: (Default)

[personal profile] skakri 2011-09-22 06:56 pm (UTC)(link)
So basically, .tt can access user information/settings? That sounds awesome, I'll try to implement "beta feature" detection in to my template.
fu: Close-up of Fu, bringing a scoop of water to her mouth (Default)

[personal profile] fu 2011-09-22 02:45 am (UTC)(link)
The main thing you need to do to implement crossposting is to create another subclass of cgi-bin/DW/External/ You can get the list of methods that the subclass needs to implement from that file as well; it's in the section called

# instance methods for subclasses.

We currently only have one for LJ-based sites -- cgi-bin/DW/External/XPostProtocol/, you can use that to see what (in general) you need to handle in each.

Then, so that it will be registered as a crosspost handler, and show up in the dropdown when you're setting up a crosspost account, add the class to the protocols hash in cgi-bin/DW/External/, like it is here:

my %protocols;
eval { $protocols{"lj"} = DW::External::XPostProtocol::LJXMLRPC->new; };

I'd probably start really simple first! Hardcode authentication while you figure out how to use the other site's protocol, and then when that's working, figure out the problem of storing the authentication.

Why not continue to use the externalaccount table, btw? The field says password, but it's always just the hashed password which can be used as an authentication token; it's not a huge stretch to use it for other auth schemes.
exor674: Computer Science is my girlfriend (Default)

[personal profile] exor674 2011-09-22 04:34 am (UTC)(link)

Hypothetically speaking - could external site (cross-posting) controller be modified to support Twitter / other social platform?

I am actually ( in my oh so copious ) free time working on at least the bit to auth a twitter account, just in case you want to avoid duplicating work.
allen: (Default)

[personal profile] allen 2011-09-22 04:55 pm (UTC)(link)
Re crossposting to Twitter: what [personal profile] fu said. Use DW::External::Account to store the connection/authentication information, then extend DW::External::XPostProtocol to do the actual implementation. Especially look at overriding XPostProtocol->options() to add in additional, protocol-specific fields (LJXMLRPC does this; look at it for an example).

I have a not-quite-working version of the Atom crossposter that I could upload if you want to see an example of adding a new protocol. That I remember, most of the configuration stuff works; it's just the crosspost itself that doesn't.

I can also give you a walkthrough of how I've done crossposting development in the past (what workers to start, etc.) if you'd like.
skakri: (Default)

[personal profile] skakri 2011-09-22 06:54 pm (UTC)(link)
That would be just great. The API in question uses "User approvement -> hash, hash -> action" model. So I could authorize user, store hash and push post information (title and url) to their API.

Basically, I'd just like to try to dive in, "how stuff works", so far, I've only adjusted DeadJournal plug to xpost to ancient LJ page.

So yes, I'd really like to see the code you're working on. That would help me a lot!
allen: extras (extras)

[personal profile] allen 2011-09-23 04:36 am (UTC)(link)

That should be the attachment itself. Or just go to and get it from there.

As I said before, the Atom code doesn't work, but it should work as a template. Oh, and there seems to be a bug that I just noticed where if you go back and view Details on a non-LJXMLRPC account, you still see the LJXMLRPC options.

So the way I usually work on crossposter issues is to open up three windows, go to $LJHOME/bin/worker, and start up xpost, esn-process-sub, and process-esn. Oh, and go into Manage Account, and under Notifications, enable notifications on successful crosspost attempts. Makes troubleshooting easier.

In general, any time you update any crossposter code in DW/External you'll need to restart the xpost worker. You shouldn't need to restart the esn workers unless you're actually working on the notification code.

Some errors that aren't caught by the xpost worker end up in the sch_error table; if you are having mysterious failures, it's worth checking there.

I think that's most of the special crossposter development notes, other than just "here's the code, look at how external accounts are created and configured in externalaccount.bml, look at DW/Worker/XPostWorker to see how the actual crossposting code is called by The Schwartz, and hope that you don't have to deal with the part in between where you actually do the post and the crosspost job gets created." :)
allen: (Default)

[personal profile] allen 2011-09-23 03:19 pm (UTC)(link)
Why both esn-process-sub and process-esn?

Habit? :)
jeshyr: Blessed are the broken. Harry Potter. (Default)

[personal profile] jeshyr 2011-10-01 10:22 am (UTC)(link)
How do you start individual bits like that anyway?I 've only got as far as "worker-manager --debug"
afuna: Cat under a blanket. Text: "Cats are just little people with Fur and Fangs" (Default)

[personal profile] afuna 2011-09-22 02:21 am (UTC)(link)
If this works, I'll try to make it a regular feature of this community. (How often should it happen?)

Hm, maybe once a month, or once every two weeks?

[personal profile] jazzyjj 2019-04-10 01:18 pm (UTC)(link)
I love this idea, and am glad it now seems to be implemented. Unfortunately, I just have not had near the amount of time in recent years to devote to these things as I'd of liked to. But I *think* that's about to change. I have very chatty neighbors here in my building, one in particular. Luckily though they are all super nice and friendly and all that. But I've made it my goal to get into this programming stuff and more advanced uses for all my awesome assistive technology. I know next to nothing about programming, so these question-and-answer threads will really help me out. Hopefully more of these will be popping up.