defining "attributes" instead of "properties"?

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

defining "attributes" instead of "properties"?

Tac Tacelosky
I'm using the very help MediaFunctions suggested on this list, and am
jazzed about being able to make queries like "get me all the images with
width < 800".

When the results come back to the api, however, "width" is an array, since
it's simply a property of the result.  Is there any way to define "width"
as more like an attribute, that is, it can have at most one value
associated with it?  And if so, can the API return its value as a scalar?

I realize that it's very unlikely that this is supported now, but wanted to
bring it up for discussion in case there is a way.  The property page
already allows some definitions, perhaps there's a way to describe an
attribute.

What I'm trying to avoid is a lot of coding on the other end of the api
that looks like

$width = isset($results['Width'][0]) ? $results['Width'][0] : $defaultWidth;

And to be able to generalize it with any property.

Thoughts?
------------------------------------------------------------------------------
Try New Relic Now & We'll Send You this Cool Shirt
New Relic is the only SaaS-based application performance monitoring service
that delivers powerful full stack analytics. Optimize and monitor your
browser, app, & servers with just a few lines of code. Try New Relic
and get this awesome Nerd Life shirt! http://p.sf.net/sfu/newrelic_d2d_apr
_______________________________________________
Semediawiki-user mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/semediawiki-user
Reply | Threaded
Open this post in threaded view
|

Re: defining "attributes" instead of "properties"?

thingles
I have a decent amount of code that has [0] all over it as well. :-)

It would be very nice to be able to specify that a property can only have one value for a given page, and then remove the single element arrays from the API output.
Jamie Thingelstad
[hidden email]
mobile: 612-810-3699
find me on AIM Twitter Facebook LinkedIn

On Apr 29, 2013, at 3:48 PM, Tac Tacelosky <[hidden email]> wrote:

> I'm using the very help MediaFunctions suggested on this list, and am
> jazzed about being able to make queries like "get me all the images with
> width < 800".
>
> When the results come back to the api, however, "width" is an array, since
> it's simply a property of the result.  Is there any way to define "width"
> as more like an attribute, that is, it can have at most one value
> associated with it?  And if so, can the API return its value as a scalar?
>
> I realize that it's very unlikely that this is supported now, but wanted to
> bring it up for discussion in case there is a way.  The property page
> already allows some definitions, perhaps there's a way to describe an
> attribute.
>
> What I'm trying to avoid is a lot of coding on the other end of the api
> that looks like
>
> $width = isset($results['Width'][0]) ? $results['Width'][0] : $defaultWidth;
>
> And to be able to generalize it with any property.
>
> Thoughts?
> ------------------------------------------------------------------------------
> Try New Relic Now & We'll Send You this Cool Shirt
> New Relic is the only SaaS-based application performance monitoring service
> that delivers powerful full stack analytics. Optimize and monitor your
> browser, app, & servers with just a few lines of code. Try New Relic
> and get this awesome Nerd Life shirt! http://p.sf.net/sfu/newrelic_d2d_apr
> _______________________________________________
> Semediawiki-user mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/semediawiki-user

------------------------------------------------------------------------------
Try New Relic Now & We'll Send You this Cool Shirt
New Relic is the only SaaS-based application performance monitoring service
that delivers powerful full stack analytics. Optimize and monitor your
browser, app, & servers with just a few lines of code. Try New Relic
and get this awesome Nerd Life shirt! http://p.sf.net/sfu/newrelic_d2d_apr
_______________________________________________
Semediawiki-user mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/semediawiki-user
Reply | Threaded
Open this post in threaded view
|

Re: defining "attributes" instead of "properties"?

Tac Tacelosky
A property page can be configured like:

This is a property of type [[Has type::Text]].

The allowed values for this property are:
* [[Allows value::a]]
* [[Allows value::c]]

Suppose there another Special Properties, Is Attribute, that always
returned a scalar value in the API.  Obviously, it wouldn't apply to
Properties of type 'Page', but I'm guessing it would apply to many dates
(birth, death) and physical properties (height, width, the oft-mentioned
Population).

Brainstorming here, I could also imagine wanting an Is Required Special
Property that wouldn't allow you to save unless a value was provided, and
perhaps something to the ask query that requested all attributes be
returned.

Another approach might be to have ask.php return something that indicates a
scalar value in the printouts:

{

   - query:
   {
      - printrequests:
      [
         -
         {
            - label: "",
            - typeid: "_wpg",
            - mode: 2
            },
         -
         {
            - label: "Height",
            - typeid: "_wpg",
            - mode: 1
            },
         -
         {
            - label: "Width",
            - typeid: "_wpg",
            - mode: 1
            }
         ],
      - results: [ ],
      - meta:
      {
         - hash: "685199b9ed8004e2c8235cc959756990",
         - count: 0,
         - offset: 0
         }
      }

}

Suppose Mode (or some other property of the printrequest) indicated that
the Property was defined as a scalar type.  Then even if the result were
are array, we'd know that there was at most one value in that array.

Just some thoughts.  Like Jamie, I'm using [0] as necessary for now.

Tac



On Mon, Apr 29, 2013 at 5:31 PM, Jamie Thingelstad <[hidden email]>wrote:

> I have a decent amount of code that has [0] all over it as well. :-)
>
> It would be very nice to be able to specify that a property can only have
> one value for a given page, and then remove the single element arrays from
> the API output.
>  Jamie Thingelstad <http://www.thingelstad.com/>
> [hidden email]
> mobile: 612-810-3699
> find me on AIM Twitter <http://twitter.com/thingles> Facebook<http://www.facebook.com/thingles>
> LinkedIn <http://www.linkedin.com/in/jthingelstad>
>
> On Apr 29, 2013, at 3:48 PM, Tac Tacelosky <[hidden email]> wrote:
>
> I'm using the very help MediaFunctions suggested on this list, and am
> jazzed about being able to make queries like "get me all the images with
> width < 800".
>
> When the results come back to the api, however, "width" is an array, since
> it's simply a property of the result.  Is there any way to define "width"
> as more like an attribute, that is, it can have at most one value
> associated with it?  And if so, can the API return its value as a scalar?
>
> I realize that it's very unlikely that this is supported now, but wanted to
> bring it up for discussion in case there is a way.  The property page
> already allows some definitions, perhaps there's a way to describe an
> attribute.
>
> What I'm trying to avoid is a lot of coding on the other end of the api
> that looks like
>
> $width = isset($results['Width'][0]) ? $results['Width'][0] :
> $defaultWidth;
>
> And to be able to generalize it with any property.
>
> Thoughts?
>
> ------------------------------------------------------------------------------
> Try New Relic Now & We'll Send You this Cool Shirt
> New Relic is the only SaaS-based application performance monitoring
> service
> that delivers powerful full stack analytics. Optimize and monitor your
> browser, app, & servers with just a few lines of code. Try New Relic
> and get this awesome Nerd Life shirt! http://p.sf.net/sfu/newrelic_d2d_apr
> _______________________________________________
> Semediawiki-user mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/semediawiki-user
>
>
>
------------------------------------------------------------------------------
Try New Relic Now & We'll Send You this Cool Shirt
New Relic is the only SaaS-based application performance monitoring service
that delivers powerful full stack analytics. Optimize and monitor your
browser, app, & servers with just a few lines of code. Try New Relic
and get this awesome Nerd Life shirt! http://p.sf.net/sfu/newrelic_d2d_apr
_______________________________________________
Semediawiki-user mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/semediawiki-user