Re: [SMW-devel] Set a SMW property programmatically in PHP?

2015-06-29 Thread Jason Ji
Hi Nischay, Markus, and Yaron,

Thanks for your feedback. I replied to Yaron but neglected to reply-all to
the list: I did indeed ended up going with just manually embedding a
{{#set:}} in the page programmatically because it seemed overall safer and
easier to manage. Cindy Cicalese actually gave me the same warning about
having to re-set the data on page refreshes. :)

--
Jason Ji
jason.y...@gmail.com

On Mon, Jun 29, 2015 at 2:06 PM, Nischay Nahata 
wrote:

> Hi Jason,
>
> As both the SMW gurus said it can be dangerous but I think there is a way
> to do it, I have a small implementation where I am already using it.
>
> For this to work you need to have the information stored in a second
> source as well to be able to update the information on page refreshes (I
> use a separate db table). The way to update this property-value is to use
> the updateDataBefore hook and update the value by fetching it from the
> alternate source - of course there is some redundancy here but I guess you
> already knew that by now.
>
> Regards,
> Nischay Nahata
>
> On Mon, Jun 29, 2015 at 9:37 PM, Markus Krötzsch <
> mar...@semantic-mediawiki.org> wrote:
>
>> On 29.06.2015 17:16, Yaron Koren wrote:
>> > Hi Jason,
>> >
>> > If you're talking about making a change to the semantic data of a page
>> > that is not reflected in that page's wikitext, that sounds like a bad
>> > idea - the new data would be removed as soon as the page was edited and
>> > saved again.
>>
>> Indeed, one has to be very careful here. The key is to make the change
>> at the correct place to ensure that the data is not lost on updates or
>> refreshs, which may not always trigger all MediaWiki hooks that you
>> would use during normal parsing. In particular, semantic data is always
>> secondary data which comes (mostly) from the content of the page and (in
>> rare cases) from other metadata of the page (as for SMW's Modification
>> date property).
>>
>> There are safe ways for setting properties from PHP, especially from
>> within own parser functions. SMW's own #set parser function has examples
>> on how to do this. Setting special properties like Modification date is
>> more tricky.
>>
>> What you are trying to do sounds dangerous though, since it seems that
>> you are trying to set the value of something that is controlled by
>> another extension. If this is the case, you should let the other
>> extension control it and insert into the page text whatever is necessary
>> to get the value that you want. You cannot change SMW data to be
>> different from what is actually given in the page -- doing so will only
>> cause a temporary inconsistency in the database that will be "fixed" as
>> soon as the page is stored/refreshed again. SMW data does not have an
>> independent existence or history. It must be regenerated reliably on
>> every refresh of the page.
>>
>> Regards,
>>
>> Markus
>>
>> >
>> > -Yaron
>> >
>> > On Thu, Jun 25, 2015 at 3:42 PM, Jason Ji > > > wrote:
>> >
>> > Hi SMW community,
>> >
>> > I have a hopefully simple question. Is there a way to set an SMW
>> > property for a page programmatically in PHP? Suppose I have access
>> > to any of the relevant information, like the page ID.
>> >
>> > For context, I'm writing an extension which, among other things,
>> > creates wiki pages using $wikipage->doEditContent(), and I'd like to
>> > be able to set a semantic title
>> >  property
>> > on the page at that point.
>> >
>> > Thanks!
>> >
>> > --
>> > Jason Ji
>> > jason.y...@gmail.com 
>> >
>> >
>>  
>> --
>> > Monitor 25 network devices or servers for free with OpManager!
>> > OpManager is web-based network management software that monitors
>> > network devices and physical & virtual servers, alerts via email &
>> sms
>> > for fault. Monitor 25 devices for free with no restriction.
>> Download now
>> > http://ad.doubleclick.net/ddm/clk/292181274;119417398;o
>> > ___
>> > Semediawiki-devel mailing list
>> > Semediawiki-devel@lists.sourceforge.net
>> > 
>> > https://lists.sourceforge.net/lists/listinfo/semediawiki-devel
>> >
>> >
>> >
>> >
>> > --
>> > WikiWorks · MediaWiki Consulting · http://wikiworks.com
>> >
>> >
>> >
>> --
>> > Monitor 25 network devices or servers for free with OpManager!
>> > OpManager is web-based network management software that monitors
>> > network devices and physical & virtual servers, alerts via email & sms
>> > for fault. Monitor 25 devices for free with no restriction. Download now
>> > http://ad.doubleclick.net/ddm/clk/292181274;119417398;o
>> >
>> >
>> >
>> > __

Re: [SMW-devel] Set a SMW property programmatically in PHP?

2015-06-29 Thread Nischay Nahata
Hi Jason,

As both the SMW gurus said it can be dangerous but I think there is a way
to do it, I have a small implementation where I am already using it.

For this to work you need to have the information stored in a second source
as well to be able to update the information on page refreshes (I use a
separate db table). The way to update this property-value is to use
the updateDataBefore hook and update the value by fetching it from the
alternate source - of course there is some redundancy here but I guess you
already knew that by now.

Regards,
Nischay Nahata

On Mon, Jun 29, 2015 at 9:37 PM, Markus Krötzsch <
mar...@semantic-mediawiki.org> wrote:

> On 29.06.2015 17:16, Yaron Koren wrote:
> > Hi Jason,
> >
> > If you're talking about making a change to the semantic data of a page
> > that is not reflected in that page's wikitext, that sounds like a bad
> > idea - the new data would be removed as soon as the page was edited and
> > saved again.
>
> Indeed, one has to be very careful here. The key is to make the change
> at the correct place to ensure that the data is not lost on updates or
> refreshs, which may not always trigger all MediaWiki hooks that you
> would use during normal parsing. In particular, semantic data is always
> secondary data which comes (mostly) from the content of the page and (in
> rare cases) from other metadata of the page (as for SMW's Modification
> date property).
>
> There are safe ways for setting properties from PHP, especially from
> within own parser functions. SMW's own #set parser function has examples
> on how to do this. Setting special properties like Modification date is
> more tricky.
>
> What you are trying to do sounds dangerous though, since it seems that
> you are trying to set the value of something that is controlled by
> another extension. If this is the case, you should let the other
> extension control it and insert into the page text whatever is necessary
> to get the value that you want. You cannot change SMW data to be
> different from what is actually given in the page -- doing so will only
> cause a temporary inconsistency in the database that will be "fixed" as
> soon as the page is stored/refreshed again. SMW data does not have an
> independent existence or history. It must be regenerated reliably on
> every refresh of the page.
>
> Regards,
>
> Markus
>
> >
> > -Yaron
> >
> > On Thu, Jun 25, 2015 at 3:42 PM, Jason Ji  > > wrote:
> >
> > Hi SMW community,
> >
> > I have a hopefully simple question. Is there a way to set an SMW
> > property for a page programmatically in PHP? Suppose I have access
> > to any of the relevant information, like the page ID.
> >
> > For context, I'm writing an extension which, among other things,
> > creates wiki pages using $wikipage->doEditContent(), and I'd like to
> > be able to set a semantic title
> >  property
> > on the page at that point.
> >
> > Thanks!
> >
> > --
> > Jason Ji
> > jason.y...@gmail.com 
> >
> >
>  
> --
> > Monitor 25 network devices or servers for free with OpManager!
> > OpManager is web-based network management software that monitors
> > network devices and physical & virtual servers, alerts via email &
> sms
> > for fault. Monitor 25 devices for free with no restriction. Download
> now
> > http://ad.doubleclick.net/ddm/clk/292181274;119417398;o
> > ___
> > Semediawiki-devel mailing list
> > Semediawiki-devel@lists.sourceforge.net
> > 
> > https://lists.sourceforge.net/lists/listinfo/semediawiki-devel
> >
> >
> >
> >
> > --
> > WikiWorks · MediaWiki Consulting · http://wikiworks.com
> >
> >
> >
> --
> > Monitor 25 network devices or servers for free with OpManager!
> > OpManager is web-based network management software that monitors
> > network devices and physical & virtual servers, alerts via email & sms
> > for fault. Monitor 25 devices for free with no restriction. Download now
> > http://ad.doubleclick.net/ddm/clk/292181274;119417398;o
> >
> >
> >
> > ___
> > Semediawiki-devel mailing list
> > Semediawiki-devel@lists.sourceforge.net
> > https://lists.sourceforge.net/lists/listinfo/semediawiki-devel
> >
>
>
>
> --
> Monitor 25 network devices or servers for free with OpManager!
> OpManager is web-based network management software that monitors
> network devices and physical & virtual servers, alerts via email & sms
> for fault. Monitor 25 devices for free with no restriction. Download now
> http://ad.doubleclick.net/ddm/clk/29

Re: [SMW-devel] Set a SMW property programmatically in PHP?

2015-06-29 Thread Markus Krötzsch
On 29.06.2015 17:16, Yaron Koren wrote:
> Hi Jason,
>
> If you're talking about making a change to the semantic data of a page
> that is not reflected in that page's wikitext, that sounds like a bad
> idea - the new data would be removed as soon as the page was edited and
> saved again.

Indeed, one has to be very careful here. The key is to make the change 
at the correct place to ensure that the data is not lost on updates or 
refreshs, which may not always trigger all MediaWiki hooks that you 
would use during normal parsing. In particular, semantic data is always 
secondary data which comes (mostly) from the content of the page and (in 
rare cases) from other metadata of the page (as for SMW's Modification 
date property).

There are safe ways for setting properties from PHP, especially from 
within own parser functions. SMW's own #set parser function has examples 
on how to do this. Setting special properties like Modification date is 
more tricky.

What you are trying to do sounds dangerous though, since it seems that 
you are trying to set the value of something that is controlled by 
another extension. If this is the case, you should let the other 
extension control it and insert into the page text whatever is necessary 
to get the value that you want. You cannot change SMW data to be 
different from what is actually given in the page -- doing so will only 
cause a temporary inconsistency in the database that will be "fixed" as 
soon as the page is stored/refreshed again. SMW data does not have an 
independent existence or history. It must be regenerated reliably on 
every refresh of the page.

Regards,

Markus

>
> -Yaron
>
> On Thu, Jun 25, 2015 at 3:42 PM, Jason Ji  > wrote:
>
> Hi SMW community,
>
> I have a hopefully simple question. Is there a way to set an SMW
> property for a page programmatically in PHP? Suppose I have access
> to any of the relevant information, like the page ID.
>
> For context, I'm writing an extension which, among other things,
> creates wiki pages using $wikipage->doEditContent(), and I'd like to
> be able to set a semantic title
>  property
> on the page at that point.
>
> Thanks!
>
> --
> Jason Ji
> jason.y...@gmail.com 
>
> 
> --
> Monitor 25 network devices or servers for free with OpManager!
> OpManager is web-based network management software that monitors
> network devices and physical & virtual servers, alerts via email & sms
> for fault. Monitor 25 devices for free with no restriction. Download now
> http://ad.doubleclick.net/ddm/clk/292181274;119417398;o
> ___
> Semediawiki-devel mailing list
> Semediawiki-devel@lists.sourceforge.net
> 
> https://lists.sourceforge.net/lists/listinfo/semediawiki-devel
>
>
>
>
> --
> WikiWorks · MediaWiki Consulting · http://wikiworks.com
>
>
> --
> Monitor 25 network devices or servers for free with OpManager!
> OpManager is web-based network management software that monitors
> network devices and physical & virtual servers, alerts via email & sms
> for fault. Monitor 25 devices for free with no restriction. Download now
> http://ad.doubleclick.net/ddm/clk/292181274;119417398;o
>
>
>
> ___
> Semediawiki-devel mailing list
> Semediawiki-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/semediawiki-devel
>


--
Monitor 25 network devices or servers for free with OpManager!
OpManager is web-based network management software that monitors 
network devices and physical & virtual servers, alerts via email & sms 
for fault. Monitor 25 devices for free with no restriction. Download now
http://ad.doubleclick.net/ddm/clk/292181274;119417398;o
___
Semediawiki-devel mailing list
Semediawiki-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/semediawiki-devel


Re: [SMW-devel] Set a SMW property programmatically in PHP?

2015-06-29 Thread Yaron Koren
Hi Jason,

If you're talking about making a change to the semantic data of a page that
is not reflected in that page's wikitext, that sounds like a bad idea - the
new data would be removed as soon as the page was edited and saved again.

-Yaron

On Thu, Jun 25, 2015 at 3:42 PM, Jason Ji  wrote:

> Hi SMW community,
>
> I have a hopefully simple question. Is there a way to set an SMW property
> for a page programmatically in PHP? Suppose I have access to any of the
> relevant information, like the page ID.
>
> For context, I'm writing an extension which, among other things, creates
> wiki pages using $wikipage->doEditContent(), and I'd like to be able to set
> a semantic title 
> property on the page at that point.
>
> Thanks!
>
> --
> Jason Ji
> jason.y...@gmail.com
>
>
> --
> Monitor 25 network devices or servers for free with OpManager!
> OpManager is web-based network management software that monitors
> network devices and physical & virtual servers, alerts via email & sms
> for fault. Monitor 25 devices for free with no restriction. Download now
> http://ad.doubleclick.net/ddm/clk/292181274;119417398;o
> ___
> Semediawiki-devel mailing list
> Semediawiki-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/semediawiki-devel
>
>


-- 
WikiWorks · MediaWiki Consulting · http://wikiworks.com
--
Monitor 25 network devices or servers for free with OpManager!
OpManager is web-based network management software that monitors 
network devices and physical & virtual servers, alerts via email & sms 
for fault. Monitor 25 devices for free with no restriction. Download now
http://ad.doubleclick.net/ddm/clk/292181274;119417398;o___
Semediawiki-devel mailing list
Semediawiki-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/semediawiki-devel