Abort in the 'onCreate' tag

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

Abort in the 'onCreate' tag

Al3x
Hi all,

I need to put an abort within the onCreate tag of a Custom Type. In fact I need to check in the constructor if a cached version exists, if so , I load the HTML cached in the Content_body and abort the script, but it seems that doing that always returns the current type name : (so I have the type name added at the end of my html...)

define_type: 'test' ;
       
        define_tag: 'onCreate' ;
             abort;
        /define_tag;

/define_type;

var: 'obj' = test ; // returns test !

How can avoid that the type name is returned ? I've tried with no success :

output_none;
abort;
/output_none;

null: abort ;

Using lasso 8.5.x on OS X 10.5

Thank you !


Reply | Threaded
Open this post in threaded view
|

Re: Abort in the 'onCreate' tag

Ke Carlton-3
This should do it:

onCreate;
   return(abort);
/onCreate;

Ke

On 18 March 2010 10:38, Al3x <[hidden email]> wrote:

>
> Hi all,
>
> I need to put an abort within the onCreate tag of a Custom Type. In fact I
> need to check in the constructor if a cached version exists, if so , I load
> the HTML cached in the Content_body and abort the script, but it seems that
> doing that always returns the current type name : (so I have the type name
> added at the end of my html...)
>
> define_type: 'test' ;
>
>        define_tag: 'onCreate' ;
>             abort;
>        /define_tag;
>
> /define_type;
>
> var: 'obj'      =       test ; // returns test !
>
> How can avoid that the type name is returned ? I've tried with no success :
>
> output_none;
> abort;
> /output_none;
>
> null: abort ;
>
> Using lasso 8.5.x on OS X 10.5
>
> Thank you !
>
>
>
> --
> View this message in context: http://old.nabble.com/Abort-in-the-%27onCreate%27-tag-tp27943861p27943861.html
> Sent from the Lasso - Talk mailing list archive at Nabble.com.
>
>
> --
> This list is a free service of LassoSoft: http://www.LassoSoft.com/
> Search the list archives: http://www.ListSearch.com/Lasso/Browse/
> Manage your subscription: http://www.ListSearch.com/Lasso/
>
>

--
This list is a free service of LassoSoft: http://www.LassoSoft.com/
Search the list archives: http://www.ListSearch.com/Lasso/Browse/
Manage your subscription: http://www.ListSearch.com/Lasso/


Reply | Threaded
Open this post in threaded view
|

Re: Abort in the 'onCreate' tag

Göran Törnquist-2
In reply to this post by Al3x
Simple answer is: not possible.

You can't change anything of what the constructor returns. The onCreate
tag is there only to provide you with the means to do proper
initialization. In Lasso you need to create a separate tag to do this.
In other languages you have other options.

Example:

define_type('myType');
     local('somedata' = null);
     define_tag('onCreate');
         self->'someData' = date;    //just bogus data for the example
     /define_tag;
/define_type;

define_tag('myTypeFactory');
     return(var('myTypeCache') === null ? myType | $myTypeCache);
/define_tag;

var('myData' = myTypeFactory);

/Göran

On 3/18/10 11:38 AM, Al3x wrote:

> Hi all,
>
> I need to put an abort within the onCreate tag of a Custom Type. In fact I
> need to check in the constructor if a cached version exists, if so , I load
> the HTML cached in the Content_body and abort the script, but it seems that
> doing that always returns the current type name : (so I have the type name
> added at the end of my html...)
>
> define_type: 'test' ;
>
> define_tag: 'onCreate' ;
>     abort;
> /define_tag;
>
> /define_type;
>
> var: 'obj' = test ; // returns test !
>
> How can avoid that the type name is returned ? I've tried with no success :
>
> output_none;
> abort;
> /output_none;
>
> null: abort ;
>
> Using lasso 8.5.x on OS X 10.5
>
> Thank you !
>
>
>
>    


--
This message has been scanned for viruses and
dangerous content by MailScanner, and is
believed to be clean.


--
This list is a free service of LassoSoft: http://www.LassoSoft.com/
Search the list archives: http://www.ListSearch.com/Lasso/Browse/
Manage your subscription: http://www.ListSearch.com/Lasso/


Reply | Threaded
Open this post in threaded view
|

Re: Abort in the 'onCreate' tag

Bil Corry-3
In reply to this post by Al3x
Al3x wrote on 3/18/2010 3:38 AM:
> I need to put an abort within the onCreate tag of a Custom Type. In fact I
> need to check in the constructor if a cached version exists, if so , I load
> the HTML cached in the Content_body and abort the script, but it seems that
> doing that always returns the current type name : (so I have the type name
> added at the end of my html...)

Somewhat of a hack, but it works:

=========================================================
[
'hello ';
define_type('test');
  local('tagname') = tag_name;
  define_tag('onCreate');
    process("[define_atend({content_body->removetrailing('"+(self->'tagname')+"')})]");
    abort;
  /define_tag;
/define_type;

var('obj') = test ;
'world';
]

LP8  =>  hello
=========================================================


- Bil

--
This list is a free service of LassoSoft: http://www.LassoSoft.com/
Search the list archives: http://www.ListSearch.com/Lasso/Browse/
Manage your subscription: http://www.ListSearch.com/Lasso/


Reply | Threaded
Open this post in threaded view
|

Re: Abort in the 'onCreate' tag

Al3x
In reply to this post by Göran Törnquist-2

Thank you !

I've created a method to check the cache and then call it in every methods of my controller

Göran Törnquist-2 wrote
Simple answer is: not possible.

You can't change anything of what the constructor returns. The onCreate
tag is there only to provide you with the means to do proper
initialization. In Lasso you need to create a separate tag to do this.
In other languages you have other options.
Reply | Threaded
Open this post in threaded view
|

Re: Abort in the 'onCreate' tag

Douglas Burchard
In reply to this post by Al3x
On Mar 18, 2010, at 3:38 AM, Al3x wrote:

> How can avoid that the type name is returned ? I've tried with no success

Just getting around to catching up on LassoTalk...

If you don't mind the type *never* returning it's own name, just add an onConvert tag that returns an empty string:

<?LassoScript

        Define_Type('Test');

                Define_Tag('onCreate');
                        Abort;
                /Define_Tag;

                Define_Tag('onConvert');
                        Return('');
                /Define_Tag;

        /Define_Type;

        Test;

?>

--
Douglas Burchard, President
DouglasBurchard.com, Web Applications
15024 NE 66th Street
Redmond, WA  98052, USA

direct: (206) 227-8161
[hidden email]
http://www.douglasburchard.com/




--
This list is a free service of LassoSoft: http://www.LassoSoft.com/
Search the list archives: http://www.ListSearch.com/Lasso/Browse/
Manage your subscription: http://www.ListSearch.com/Lasso/


Reply | Threaded
Open this post in threaded view
|

Re: Abort in the 'onCreate' tag

Bil Corry-3
Douglas Burchard wrote on 3/22/2010 11:10 PM:
> If you don't mind the type *never* returning it's own name, just add an onConvert tag that returns an empty string:

Ha, yes, that's the way...

- Bil

--
This list is a free service of LassoSoft: http://www.LassoSoft.com/
Search the list archives: http://www.ListSearch.com/Lasso/Browse/
Manage your subscription: http://www.ListSearch.com/Lasso/


Reply | Threaded
Open this post in threaded view
|

Re: Abort in the 'onCreate' tag

Johan Solve
In reply to this post by Douglas Burchard
On Tue, Mar 23, 2010 at 7:10 AM, Douglas Burchard
<[hidden email]> wrote:
> On Mar 18, 2010, at 3:38 AM, Al3x wrote:
>                Define_Tag('onConvert');
>                        Return('');
>                /Define_Tag;

Or just return, right?

                Define_Tag('onConvert');
                        Return;
                /Define_Tag;



--
Mvh
Johan Sölve
____________________________________
Montania System AB
Halmstad   Stockholm   Malmö
http://www.montania.se

Johan Sölve
Mobil +46 709-51 55 70
[hidden email]

Kristinebergsvägen 17, S-302 41 Halmstad, Sweden
Telefon +46 35-136800 |  Fax +46 35-136801

--
This list is a free service of LassoSoft: http://www.LassoSoft.com/
Search the list archives: http://www.ListSearch.com/Lasso/Browse/
Manage your subscription: http://www.ListSearch.com/Lasso/


Reply | Threaded
Open this post in threaded view
|

Re: Abort in the 'onCreate' tag

Douglas Burchard
On Mar 23, 2010, at 9:06 AM, Johan Solve wrote:

> On Tue, Mar 23, 2010 at 7:10 AM, Douglas Burchard wrote:
>
>> On Mar 18, 2010, at 3:38 AM, Al3x wrote:
>>                Define_Tag('onConvert');
>>                        Return('');
>>                /Define_Tag;
>
> Or just return, right?
>
>                Define_Tag('onConvert');
>                        Return;
>                /Define_Tag;

Yes, but I *really* like being explicit.

For example, I also use more parentheses than most, but have had less problems upgrading over the years (no guarantees with Lasso9 though).


--
Douglas Burchard, President
DouglasBurchard.com, Web Applications
15024 NE 66th Street
Redmond, WA  98052, USA

direct: (206) 227-8161
[hidden email]
http://www.douglasburchard.com/




--
This list is a free service of LassoSoft: http://www.LassoSoft.com/
Search the list archives: http://www.ListSearch.com/Lasso/Browse/
Manage your subscription: http://www.ListSearch.com/Lasso/


Reply | Threaded
Open this post in threaded view
|

Re: Abort in the 'onCreate' tag

Göran Törnquist-2
In reply to this post by Johan Solve
On 3/23/10 5:06 PM, Johan Solve wrote:

> On Tue, Mar 23, 2010 at 7:10 AM, Douglas Burchard
> <[hidden email]>  wrote:
>    
>> On Mar 18, 2010, at 3:38 AM, Al3x wrote:
>>                 Define_Tag('onConvert');
>>                         Return('');
>>                 /Define_Tag;
>>      
> Or just return, right?
>
>                  Define_Tag('onConvert');
>                          Return;
>                  /Define_Tag;
>    
Well if you're going to return null (which is implied by the Return
without params), then why not this? :)

Define_Tag('onConvert');
/Define_Tag;

/Göran

--
This message has been scanned for viruses and
dangerous content by MailScanner, and is
believed to be clean.


--
This list is a free service of LassoSoft: http://www.LassoSoft.com/
Search the list archives: http://www.ListSearch.com/Lasso/Browse/
Manage your subscription: http://www.ListSearch.com/Lasso/