Proposed feature: #include inline

View: New views
8 Messages — Rating Filter:   Alert me  

Proposed feature: #include inline

by R. Tyler Ballance-5 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

I'm not going to write up a CHEP for this just yet, but I came across a
usecase for `#include inline` version `#include raw` today.

When watching a production server run through a particular template I
realized that we were using `#include raw` far too much, resulting in a
large amount of open(2) and read(2) calls (to be expected, duh).

What we *really* want to do however, is an `#include inline` which would
be processed and the contents of the included file inlined at *compile
time* instead of raw's inclusion at run time.

Thoughts?

Tavis, if you've no enormous objections, I think this would be a
reasonable addition.


Cheers

-R. Tyler Ballance
Slide, Inc.


------------------------------------------------------------------------------
Enter the BlackBerry Developer Challenge  
This is your chance to win up to $100,000 in prizes! For a limited time,
vendors submitting new applications to BlackBerry App World(TM) will have
the opportunity to enter the BlackBerry Developer Challenge. See full prize  
details at: http://p.sf.net/sfu/Challenge
_______________________________________________
Cheetahtemplate-discuss mailing list
Cheetahtemplate-discuss@...
https://lists.sourceforge.net/lists/listinfo/cheetahtemplate-discuss

attachment0 (204 bytes) Download Attachment

Re: Proposed feature: #include inline

by Tavis Rudd :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

I don't like #include in general, but I can't see anything wrong with
this addition to it.

Anyone else got a good suggestion for an alternate name that makes it very
clear that this happens at compile time?

Tavis

On Tue, 14 Jul 2009, R. Tyler Ballance wrote:

> I'm not going to write up a CHEP for this just yet, but I came across a
> usecase for `#include inline` version `#include raw` today.
>
> When watching a production server run through a particular template I
> realized that we were using `#include raw` far too much, resulting in a
> large amount of open(2) and read(2) calls (to be expected, duh).
>
> What we *really* want to do however, is an `#include inline` which would
> be processed and the contents of the included file inlined at *compile
> time* instead of raw's inclusion at run time.
>
> Thoughts?
>
> Tavis, if you've no enormous objections, I think this would be a
> reasonable addition.
>
>
> Cheers
>
> -R. Tyler Ballance
> Slide, Inc.
>

------------------------------------------------------------------------------
Enter the BlackBerry Developer Challenge  
This is your chance to win up to $100,000 in prizes! For a limited time,
vendors submitting new applications to BlackBerry App World(TM) will have
the opportunity to enter the BlackBerry Developer Challenge. See full prize  
details at: http://p.sf.net/sfu/Challenge
_______________________________________________
Cheetahtemplate-discuss mailing list
Cheetahtemplate-discuss@...
https://lists.sourceforge.net/lists/listinfo/cheetahtemplate-discuss

Re: Proposed feature: #include inline

by R. Tyler Ballance-5 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


On Tue, 14 Jul 2009, Tavis Rudd wrote:

> I don't like #include in general, but I can't see anything wrong with  
> this addition to it.
>
> Anyone else got a good suggestion for an alternate name that makes it
> very clear that this happens at compile time?

Perhaps a direct `#inline` directive? Not that I feel too wonderful
about adding a new directive (since I've not yet got the documentation
up to par yet)

>
> Tavis
>
> On Tue, 14 Jul 2009, R. Tyler Ballance wrote:
>
>> I'm not going to write up a CHEP for this just yet, but I came across a
>> usecase for `#include inline` version `#include raw` today.
>>
>> When watching a production server run through a particular template I
>> realized that we were using `#include raw` far too much, resulting in a
>> large amount of open(2) and read(2) calls (to be expected, duh).
>>
>> What we *really* want to do however, is an `#include inline` which would
>> be processed and the contents of the included file inlined at *compile
>> time* instead of raw's inclusion at run time.
>>
>> Thoughts?
>>
>> Tavis, if you've no enormous objections, I think this would be a
>> reasonable addition.
>>
>>
>> Cheers
>>
>> -R. Tyler Ballance
>> Slide, Inc.
>>
-R. Tyler Ballance
Slide, Inc.


------------------------------------------------------------------------------
Enter the BlackBerry Developer Challenge  
This is your chance to win up to $100,000 in prizes! For a limited time,
vendors submitting new applications to BlackBerry App World(TM) will have
the opportunity to enter the BlackBerry Developer Challenge. See full prize  
details at: http://p.sf.net/sfu/Challenge
_______________________________________________
Cheetahtemplate-discuss mailing list
Cheetahtemplate-discuss@...
https://lists.sourceforge.net/lists/listinfo/cheetahtemplate-discuss

attachment0 (204 bytes) Download Attachment

Re: Proposed feature: #include inline

by Tavis Rudd :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


On Tue, 14 Jul 2009, R. Tyler Ballance wrote:

>
> On Tue, 14 Jul 2009, Tavis Rudd wrote:
>
>> I don't like #include in general, but I can't see anything wrong with
>> this addition to it.
>>
>> Anyone else got a good suggestion for an alternate name that makes it
>> very clear that this happens at compile time?
>
> Perhaps a direct `#inline` directive? Not that I feel too wonderful
> about adding a new directive (since I've not yet got the documentation
> up to par yet)

Nah.  I think it belongs with #include.

#include-during-compile ? (feels a bit long to type, but then I'd never
type this myself ;)

>>
>> Tavis
>>
>> On Tue, 14 Jul 2009, R. Tyler Ballance wrote:
>>
>>> I'm not going to write up a CHEP for this just yet, but I came across a
>>> usecase for `#include inline` version `#include raw` today.
>>>
>>> When watching a production server run through a particular template I
>>> realized that we were using `#include raw` far too much, resulting in a
>>> large amount of open(2) and read(2) calls (to be expected, duh).
>>>
>>> What we *really* want to do however, is an `#include inline` which would
>>> be processed and the contents of the included file inlined at *compile
>>> time* instead of raw's inclusion at run time.
>>>
>>> Thoughts?
>>>
>>> Tavis, if you've no enormous objections, I think this would be a
>>> reasonable addition.
>>>
>>>
>>> Cheers
>>>
>>> -R. Tyler Ballance
>>> Slide, Inc.
>>>
> -R. Tyler Ballance
> Slide, Inc.
>

------------------------------------------------------------------------------
Enter the BlackBerry Developer Challenge  
This is your chance to win up to $100,000 in prizes! For a limited time,
vendors submitting new applications to BlackBerry App World(TM) will have
the opportunity to enter the BlackBerry Developer Challenge. See full prize  
details at: http://p.sf.net/sfu/Challenge
_______________________________________________
Cheetahtemplate-discuss mailing list
Cheetahtemplate-discuss@...
https://lists.sourceforge.net/lists/listinfo/cheetahtemplate-discuss

Re: Proposed feature: #include inline

by Tavis Rudd :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Btw, this is the way #include worked originally but it confused so many
people that we made it run-time.

On Tue, 14 Jul 2009, R. Tyler Ballance wrote:

>
> On Tue, 14 Jul 2009, Tavis Rudd wrote:
>
>> I don't like #include in general, but I can't see anything wrong with
>> this addition to it.
>>
>> Anyone else got a good suggestion for an alternate name that makes it
>> very clear that this happens at compile time?
>
> Perhaps a direct `#inline` directive? Not that I feel too wonderful
> about adding a new directive (since I've not yet got the documentation
> up to par yet)
>
>>
>> Tavis
>>
>> On Tue, 14 Jul 2009, R. Tyler Ballance wrote:
>>
>>> I'm not going to write up a CHEP for this just yet, but I came across a
>>> usecase for `#include inline` version `#include raw` today.
>>>
>>> When watching a production server run through a particular template I
>>> realized that we were using `#include raw` far too much, resulting in a
>>> large amount of open(2) and read(2) calls (to be expected, duh).
>>>
>>> What we *really* want to do however, is an `#include inline` which would
>>> be processed and the contents of the included file inlined at *compile
>>> time* instead of raw's inclusion at run time.
>>>
>>> Thoughts?
>>>
>>> Tavis, if you've no enormous objections, I think this would be a
>>> reasonable addition.
>>>
>>>
>>> Cheers
>>>
>>> -R. Tyler Ballance
>>> Slide, Inc.
>>>
> -R. Tyler Ballance
> Slide, Inc.
>

------------------------------------------------------------------------------
Enter the BlackBerry Developer Challenge  
This is your chance to win up to $100,000 in prizes! For a limited time,
vendors submitting new applications to BlackBerry App World(TM) will have
the opportunity to enter the BlackBerry Developer Challenge. See full prize  
details at: http://p.sf.net/sfu/Challenge
_______________________________________________
Cheetahtemplate-discuss mailing list
Cheetahtemplate-discuss@...
https://lists.sourceforge.net/lists/listinfo/cheetahtemplate-discuss

Re: Proposed feature: #include inline

by Paul-398 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Webpy does this
r_include = re_compile(r'(?!\\)#include \"(.*?)\"', re.M)
def __compiletemplate(template, base=None, isString=False):
    if isString:
        text = template
    else:
        text = open('templates/'+template).read()
    # implement #include at compile-time
    def do_include(match):
        text = open('templates/'+match.groups()[0]).read()
        return text
    while r_include.findall(text):
        text = r_include.sub(do_include, text)
    #text = '#encoding UTF-8\n'+text
    execspace = _compiletemplate.bases.copy()
    tmpl_compiler = Compiler(source=text, mainClassName='GenTemplate')
    tmpl_compiler.addImportedVarNames(execspace.keys())
    exec str(tmpl_compiler) in execspace
    if base:
        _compiletemplate.bases[base] = execspace['GenTemplate']

    return execspace['GenTemplate']



On Tue, Jul 14, 2009 at 4:57 PM, Tavis Rudd <tavis@...> wrote:
I don't like #include in general, but I can't see anything wrong with
this addition to it.

Anyone else got a good suggestion for an alternate name that makes it very
clear that this happens at compile time?

Tavis

On Tue, 14 Jul 2009, R. Tyler Ballance wrote:

> I'm not going to write up a CHEP for this just yet, but I came across a
> usecase for `#include inline` version `#include raw` today.
>
> When watching a production server run through a particular template I
> realized that we were using `#include raw` far too much, resulting in a
> large amount of open(2) and read(2) calls (to be expected, duh).
>
> What we *really* want to do however, is an `#include inline` which would
> be processed and the contents of the included file inlined at *compile
> time* instead of raw's inclusion at run time.
>
> Thoughts?
>
> Tavis, if you've no enormous objections, I think this would be a
> reasonable addition.
>
>
> Cheers
>
> -R. Tyler Ballance
> Slide, Inc.
>

------------------------------------------------------------------------------
Enter the BlackBerry Developer Challenge
This is your chance to win up to $100,000 in prizes! For a limited time,
vendors submitting new applications to BlackBerry App World(TM) will have
the opportunity to enter the BlackBerry Developer Challenge. See full prize
details at: http://p.sf.net/sfu/Challenge
_______________________________________________
Cheetahtemplate-discuss mailing list
Cheetahtemplate-discuss@...
https://lists.sourceforge.net/lists/listinfo/cheetahtemplate-discuss



--
BidEgg - Worlds best low price Auction site
http://bidegg.com

------------------------------------------------------------------------------
Enter the BlackBerry Developer Challenge  
This is your chance to win up to $100,000 in prizes! For a limited time,
vendors submitting new applications to BlackBerry App World(TM) will have
the opportunity to enter the BlackBerry Developer Challenge. See full prize  
details at: http://p.sf.net/sfu/Challenge
_______________________________________________
Cheetahtemplate-discuss mailing list
Cheetahtemplate-discuss@...
https://lists.sourceforge.net/lists/listinfo/cheetahtemplate-discuss

Re: Proposed feature: #include inline

by Paul-398 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

this is the right way to do i at compile time we wont hav any issues at all

On Tue, Jul 14, 2009 at 5:13 PM, Tavis Rudd <tavis@...> wrote:
Btw, this is the way #include worked originally but it confused so many
people that we made it run-time.

On Tue, 14 Jul 2009, R. Tyler Ballance wrote:

>
> On Tue, 14 Jul 2009, Tavis Rudd wrote:
>
>> I don't like #include in general, but I can't see anything wrong with
>> this addition to it.
>>
>> Anyone else got a good suggestion for an alternate name that makes it
>> very clear that this happens at compile time?
>
> Perhaps a direct `#inline` directive? Not that I feel too wonderful
> about adding a new directive (since I've not yet got the documentation
> up to par yet)
>
>>
>> Tavis
>>
>> On Tue, 14 Jul 2009, R. Tyler Ballance wrote:
>>
>>> I'm not going to write up a CHEP for this just yet, but I came across a
>>> usecase for `#include inline` version `#include raw` today.
>>>
>>> When watching a production server run through a particular template I
>>> realized that we were using `#include raw` far too much, resulting in a
>>> large amount of open(2) and read(2) calls (to be expected, duh).
>>>
>>> What we *really* want to do however, is an `#include inline` which would
>>> be processed and the contents of the included file inlined at *compile
>>> time* instead of raw's inclusion at run time.
>>>
>>> Thoughts?
>>>
>>> Tavis, if you've no enormous objections, I think this would be a
>>> reasonable addition.
>>>
>>>
>>> Cheers
>>>
>>> -R. Tyler Ballance
>>> Slide, Inc.
>>>
> -R. Tyler Ballance
> Slide, Inc.
>

------------------------------------------------------------------------------
Enter the BlackBerry Developer Challenge
This is your chance to win up to $100,000 in prizes! For a limited time,
vendors submitting new applications to BlackBerry App World(TM) will have
the opportunity to enter the BlackBerry Developer Challenge. See full prize
details at: http://p.sf.net/sfu/Challenge
_______________________________________________
Cheetahtemplate-discuss mailing list
Cheetahtemplate-discuss@...
https://lists.sourceforge.net/lists/listinfo/cheetahtemplate-discuss



--
BidEgg - Worlds best low price Auction site
http://bidegg.com

------------------------------------------------------------------------------
Enter the BlackBerry Developer Challenge  
This is your chance to win up to $100,000 in prizes! For a limited time,
vendors submitting new applications to BlackBerry App World(TM) will have
the opportunity to enter the BlackBerry Developer Challenge. See full prize  
details at: http://p.sf.net/sfu/Challenge
_______________________________________________
Cheetahtemplate-discuss mailing list
Cheetahtemplate-discuss@...
https://lists.sourceforge.net/lists/listinfo/cheetahtemplate-discuss

Re: Proposed feature: #include inline

by Paul-398 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

#include is fine

On Tue, Jul 14, 2009 at 5:03 PM, Tavis Rudd <tavis@...> wrote:

On Tue, 14 Jul 2009, R. Tyler Ballance wrote:
>
> On Tue, 14 Jul 2009, Tavis Rudd wrote:
>
>> I don't like #include in general, but I can't see anything wrong with
>> this addition to it.
>>
>> Anyone else got a good suggestion for an alternate name that makes it
>> very clear that this happens at compile time?
>
> Perhaps a direct `#inline` directive? Not that I feel too wonderful
> about adding a new directive (since I've not yet got the documentation
> up to par yet)

Nah.  I think it belongs with #include.

#include-during-compile ? (feels a bit long to type, but then I'd never
type this myself ;)

>>
>> Tavis
>>
>> On Tue, 14 Jul 2009, R. Tyler Ballance wrote:
>>
>>> I'm not going to write up a CHEP for this just yet, but I came across a
>>> usecase for `#include inline` version `#include raw` today.
>>>
>>> When watching a production server run through a particular template I
>>> realized that we were using `#include raw` far too much, resulting in a
>>> large amount of open(2) and read(2) calls (to be expected, duh).
>>>
>>> What we *really* want to do however, is an `#include inline` which would
>>> be processed and the contents of the included file inlined at *compile
>>> time* instead of raw's inclusion at run time.
>>>
>>> Thoughts?
>>>
>>> Tavis, if you've no enormous objections, I think this would be a
>>> reasonable addition.
>>>
>>>
>>> Cheers
>>>
>>> -R. Tyler Ballance
>>> Slide, Inc.
>>>
> -R. Tyler Ballance
> Slide, Inc.
>

------------------------------------------------------------------------------
Enter the BlackBerry Developer Challenge
This is your chance to win up to $100,000 in prizes! For a limited time,
vendors submitting new applications to BlackBerry App World(TM) will have
the opportunity to enter the BlackBerry Developer Challenge. See full prize
details at: http://p.sf.net/sfu/Challenge
_______________________________________________
Cheetahtemplate-discuss mailing list
Cheetahtemplate-discuss@...
https://lists.sourceforge.net/lists/listinfo/cheetahtemplate-discuss



--
BidEgg - Worlds best low price Auction site
http://bidegg.com

------------------------------------------------------------------------------
Enter the BlackBerry Developer Challenge  
This is your chance to win up to $100,000 in prizes! For a limited time,
vendors submitting new applications to BlackBerry App World(TM) will have
the opportunity to enter the BlackBerry Developer Challenge. See full prize  
details at: http://p.sf.net/sfu/Challenge
_______________________________________________
Cheetahtemplate-discuss mailing list
Cheetahtemplate-discuss@...
https://lists.sourceforge.net/lists/listinfo/cheetahtemplate-discuss