Login | Register For Free | Help
Search for: (Advanced)

Mailing List Archive: Wikipedia: Wikitech

Lua API specification

 

 

Wikipedia wikitech RSS feed   Index | Next | Previous | View Threaded


vasilvv at gmail

Jun 2, 2012, 1:43 PM

Post #1 of 4 (196 views)
Permalink
Lua API specification

Currently there is no proper way in Lua to get such basic things about
the current page name. To fix this, I propose to provide a MediaWiki
API accessible from the Lua scripts:
<https://www.mediawiki.org/wiki/Extension:Scribunto/API_specification>
Any feedback appreciated.

— Victor.

_______________________________________________
Wikitech-l mailing list
Wikitech-l [at] lists
https://lists.wikimedia.org/mailman/listinfo/wikitech-l


questpc at rambler

Jun 3, 2012, 11:32 PM

Post #2 of 4 (183 views)
Permalink
Re: Lua API specification [In reply to]

* Victor Vasiliev <vasilvv [at] gmail> [Sat, 2 Jun 2012 22:43:56 +0200]:
> Currently there is no proper way in Lua to get such basic things about
> the current page name. To fix this, I propose to provide a MediaWiki
> API accessible from the Lua scripts:
>
<https://www.mediawiki.org/wiki/Extension:Scribunto/API_specification>
> Any feedback appreciated.
>
> — Victor.
>
Is that local PHP bindings only or the remote MW API querying will be
possible? In MediaWiki, API usually means "do something remotely",
although local API usage is possible (except for very hard parts where
POST is required - but maybe that was fixed in recent versions of
Request / Response abstractions).
I am asking because when there are two different things called "API"
this may cause some confusion.
Dmitriy

_______________________________________________
Wikitech-l mailing list
Wikitech-l [at] lists
https://lists.wikimedia.org/mailman/listinfo/wikitech-l


ori.livneh at gmail

Jun 4, 2012, 1:30 AM

Post #3 of 4 (186 views)
Permalink
Re: Lua API specification [In reply to]

On Sat, Jun 2, 2012 at 1:43 PM, Victor Vasiliev <vasilvv [at] gmail> wrote:

> Any feedback appreciated.
>

(Caveat: I'm new to Mediawiki development and have only a shallow
understanding of its internals.)

I find getSomething syntax to be cluttered and verbose. The "get", the
mixed case, the function invocation -- these things are not encoding useful
information, so they exist as a kind of syntactic line noise. I find it
much easier to orient myself around APIs that make use of property
accessors -- obj.foo rather than obj.getFoo().

It looks like they are doable (and performant) in Lua: <
http://nova-fusion.com/2011/04/04/implementing-proper-gettersetters-in-lua/
>.

It's possible to go too far with properties*, though, so I make an
exception for data points that are expensive to look up. In such cases the
get and the invocation _are_ encoding useful information: i.e., the fact
that the information isn't available on hand and needs to be fetched. But
more often the fact that some value need to be computed is an
implementation detail that your users shouldn't have to care about.

My second quibble is with the mw.title interface. Most of the other
interfaces follow a loose convention of mw.object.getPropertyOfObject(),
but mw.title.parse(text) seems to get things backwards -- it's
mw.property.getFromObject(), if you will. I find that a bit confusing.

In general, I'd prefer it if there was a sharper distinction between the
REST-like resources-with-methods semantics (mw.page, mw.site) and the
"standard library" approach whereby things are bundled according to
functionality (mw.time, mw.url).

Hope this is useful. I think it's a cool project.

Ori

* I've made this mistake before: <http://djangosnippets.org/snippets/2582/
>.
_______________________________________________
Wikitech-l mailing list
Wikitech-l [at] lists
https://lists.wikimedia.org/mailman/listinfo/wikitech-l


vasilvv at gmail

Jun 9, 2012, 10:00 AM

Post #4 of 4 (172 views)
Permalink
Re: Lua API specification [In reply to]

On Mon, Jun 4, 2012 at 12:30 PM, Ori Livneh <ori.livneh [at] gmail> wrote:
> I find getSomething syntax to be cluttered and verbose. The "get", the
> mixed case, the function invocation -- these things are not encoding useful
> information, so they exist as a kind of syntactic line noise. I find it
> much easier to orient myself around APIs that make use of property
> accessors -- obj.foo rather than obj.getFoo().

Done. I've updated spec with properties

> My second quibble is with the mw.title interface. Most of the other
> interfaces follow a loose convention of mw.object.getPropertyOfObject(),
> but mw.title.parse(text) seems to get things backwards -- it's
> mw.property.getFromObject(), if you will. I find that a bit confusing.

I'm not sure I quite get this one.

> In general, I'd prefer it if there was a sharper distinction between the
> REST-like resources-with-methods semantics (mw.page, mw.site) and the
> "standard library" approach whereby things are bundled according to
> functionality (mw.time, mw.url).

Well, they are all bundled according the functionality (get current
page info, get site info, i18n functions, etc.).

> Hope this is useful. I think it's a cool project.

Thanks!

— Victor.

_______________________________________________
Wikitech-l mailing list
Wikitech-l [at] lists
https://lists.wikimedia.org/mailman/listinfo/wikitech-l

Wikipedia wikitech RSS feed   Index | Next | Previous | View Threaded
 
 


Interested in having your list archived? Contact Gossamer Threads
 
  Web Applications & Managed Hosting Powered by Gossamer Threads Inc.