Skip to search.

Breaking News Visit Yahoo! News for the latest.

×Close this window

ClearSilver

The Yahoo! Groups Product Blog

Check it out!

Group Information

  • Members: 335
  • Category: Open Source
  • Founded: Jul 2, 2001
  • Language: English
? Already a member? Sign in to Yahoo!

Yahoo! Groups Tips

Did you know...
Message search is now enhanced, find messages faster. Take it for a spin.

Messages

Advanced
Messages Help
Messages 131 - 160 of 1451   Oldest  |  < Older  |  Newer >  |  Newest
Messages: Show Message Summaries Sort by Date ^  
#131 From: Martin Baker <martinb@...>
Date: Thu Sep 18, 2003 5:34 am
Subject: anyone running mod_python?
martinb@...
Send Email Send Email
 
I'm experimenting with ClearSilver and I have an Apache box running
mod_python, not PyApache. I notice that CSPage.py assumes things that
aren't true in my environment, which I'm guessing are due to the
differences between mod_python and PyApache.

I'm just curious if others out there are running mod_python, and if so, if
they encountered any quirks they'd like to tell me about.

FYI, a few issues I've encountered. Let me know if these are better
directed to blong, not the group.

mod_python/CSPage issues:
CSPage.Context looks for sys.argv. mod_python doesn't define sys.argv, so
this gave me an error. Easily faked.

mod_python ignores stdout - outgoing data must be sent via a special
"request object", again, easily solved by a wrapper for stdout, although
assigning sys.stdout to the req object would probably work, too.

It appears that you have to output "HTTP/1.1 200 OK" (or otherwise)
yourself. Successful runs of my script would lack this header and
"Connection: close" so I'd see "Content-type: text/html" displayed on the
page.

Relative includes don't appear to work in the cs file. I find this odd
because they worked fine with static.cgi.

A couple other small issues with the setup as-is (I know it's pre-1.0):

There are lots of hardcoded references to "/neo/..." etc., e.g. the
following in my error logs (I created the directory after this, but are
there others lurking?):

Unable to dump_bug
Traceback (most recent call last):
   File
"/home/martinb/src/clearsilver-0.9.3/python/examples/base/handle_error.py",
line 49, in handleException
     if dump: dump_bug(lvl, "handleException", msg, string.join(tb_list,
""))
   File
"/home/martinb/src/clearsilver-0.9.3/python/examples/base/handle_error.py",
line 89, in dump_bug
     hdf.writeFile(tpath)
Error: Traceback (innermost last):
   File "neo_hdf.c", line 1121, in hdf_write_file()
IOError: Unable to open /neo/data/bugs/tmp/1063857724.2286_1.atoz for
writing: [2] No such file or directory

---------

Also: "import odb" gives an error: unable to load tstart (I had seen no
reason to include examples/trans in my sys.path). Since all tstart does is
add dirs to sys.path for the translation stuff, it's weird that odb should
try to include it.

This stuff rocks. To paraphrase Douglas Adams, it is almost, but not
quite, entirely unlike PHP. Great job guys!

Martin

#132 From: Brandon Long <blong@...>
Date: Thu Sep 18, 2003 6:07 am
Subject: Re: anyone running mod_python?
blong42
Send Email Send Email
 
On 09/17/03 Martin Baker uttered the following other thing:
> I'm experimenting with ClearSilver and I have an Apache box running
> mod_python, not PyApache. I notice that CSPage.py assumes things that
> aren't true in my environment, which I'm guessing are due to the
> differences between mod_python and PyApache.
>
> I'm just curious if others out there are running mod_python, and if so, if
> they encountered any quirks they'd like to tell me about.

Scott's image server works under mod_python, and although I've installed
it, I haven't looked that closely at it to see the difference.

http://www.dotfunk.com/projects/image_server

> FYI, a few issues I've encountered. Let me know if these are better
> directed to blong, not the group.
>
> mod_python/CSPage issues:
> CSPage.Context looks for sys.argv. mod_python doesn't define sys.argv, so
> this gave me an error. Easily faked.
>
> mod_python ignores stdout - outgoing data must be sent via a special
> "request object", again, easily solved by a wrapper for stdout, although
> assigning sys.stdout to the req object would probably work, too.
>
> It appears that you have to output "HTTP/1.1 200 OK" (or otherwise)
> yourself. Successful runs of my script would lack this header and
> "Connection: close" so I'd see "Content-type: text/html" displayed on the
> page.

Hmm, the image_server has a cspage.py which is similar to CSPage.py, but
it seems to have some added smarts for mod_python, including hooking
into the right parts of the mod_python apache module.

> Relative includes don't appear to work in the cs file. I find this odd
> because they worked fine with static.cgi.

There's nothing in the underlying HDF code that should care, at a guess
the difference is cgi code does a chdir to the directory before exec'ing
the cgi, and mod_python probably isn't.  os.getcwd() will tell you.

> A couple other small issues with the setup as-is (I know it's pre-1.0):
>
> There are lots of hardcoded references to "/neo/..." etc., e.g. the
> following in my error logs (I created the directory after this, but are
> there others lurking?):
>
> Unable to dump_bug
> Traceback (most recent call last):
>   File
> "/home/martinb/src/clearsilver-0.9.3/python/examples/base/handle_error.py",
> line 49, in handleException
>     if dump: dump_bug(lvl, "handleException", msg, string.join(tb_list,
> ""))
>   File
> "/home/martinb/src/clearsilver-0.9.3/python/examples/base/handle_error.py",
> line 89, in dump_bug
>     hdf.writeFile(tpath)
> Error: Traceback (innermost last):
>   File "neo_hdf.c", line 1121, in hdf_write_file()
> IOError: Unable to open /neo/data/bugs/tmp/1063857724.2286_1.atoz for
> writing: [2] No such file or directory

Yeah, that's a known one.  The configure script also looks for /neo/opt
for python and other things, but if it doesn't exist it should be fine.
I don't know of any other hard coded things...

Not sure what to do with the above one, I can just have a module variable
for it.

> Also: "import odb" gives an error: unable to load tstart (I had seen no
> reason to include examples/trans in my sys.path). Since all tstart does is
> add dirs to sys.path for the translation stuff, it's weird that odb should
> try to include it.

hmm, I thought we'd removed all of the tstart's... its how we set up the
sys.path for all of our code.  The theory is there is a tstart in every
directory which sets up the paths for something to run in that
directory.  Its not specific to trans... (t actually stands for Trakken)

Actually, looking in tstart, I guess Dave added one specific to trans.
Though, it looks like I've already removed the import from odb, it'll be
gone in the next release.

Brandon
--
  "We don't understand the software, and sometimes we don't understand
   the hardware, but we can *see* the blinking lights!" -- Unknown
                                            http://www.fiction.net/blong/

#133 From: "Chris Trimble" <trimble@...>
Date: Thu Sep 18, 2003 5:33 pm
Subject: RE: anyone running mod_python?
ctrimble
Send Email Send Email
 
I've been using mod_python on Apache on W2K for an internal website for about,
oh, 4-6 months now.  It's being served off of my machine, queries SQL_server and
such.  Very solid, just keeps on running (thankfully -- because now I don't have
time to maintain it).  The structure of the script was based on Hassan's code. 
I don't have anything in my code that outputs "HTTP/1.1 200 OK", but maybe
that's because I'm using Scott's "ModPythonContext" object.

  - Chris



-----Original Message-----
From: Martin Baker [mailto:martinb@...]
Sent: Wednesday, September 17, 2003 10:34 PM
To: clearsilver@yahoogroups.com
Subject: anyone running mod_python?


I'm experimenting with ClearSilver and I have an Apache box running
mod_python, not PyApache. I notice that CSPage.py assumes things that
aren't true in my environment, which I'm guessing are due to the
differences between mod_python and PyApache.

I'm just curious if others out there are running mod_python, and if so, if
they encountered any quirks they'd like to tell me about.

FYI, a few issues I've encountered. Let me know if these are better
directed to blong, not the group.

mod_python/CSPage issues:
CSPage.Context looks for sys.argv. mod_python doesn't define sys.argv, so
this gave me an error. Easily faked.

mod_python ignores stdout - outgoing data must be sent via a special
"request object", again, easily solved by a wrapper for stdout, although
assigning sys.stdout to the req object would probably work, too.

It appears that you have to output "HTTP/1.1 200 OK" (or otherwise)
yourself. Successful runs of my script would lack this header and
"Connection: close" so I'd see "Content-type: text/html" displayed on the
page.

Relative includes don't appear to work in the cs file. I find this odd
because they worked fine with static.cgi.

A couple other small issues with the setup as-is (I know it's pre-1.0):

There are lots of hardcoded references to "/neo/..." etc., e.g. the
following in my error logs (I created the directory after this, but are
there others lurking?):

Unable to dump_bug
Traceback (most recent call last):
   File
"/home/martinb/src/clearsilver-0.9.3/python/examples/base/handle_error.py",
line 49, in handleException
     if dump: dump_bug(lvl, "handleException", msg, string.join(tb_list,
""))
   File
"/home/martinb/src/clearsilver-0.9.3/python/examples/base/handle_error.py",
line 89, in dump_bug
     hdf.writeFile(tpath)
Error: Traceback (innermost last):
   File "neo_hdf.c", line 1121, in hdf_write_file()
IOError: Unable to open /neo/data/bugs/tmp/1063857724.2286_1.atoz for
writing: [2] No such file or directory

---------

Also: "import odb" gives an error: unable to load tstart (I had seen no
reason to include examples/trans in my sys.path). Since all tstart does is
add dirs to sys.path for the translation stuff, it's weird that odb should
try to include it.

This stuff rocks. To paraphrase Douglas Adams, it is almost, but not
quite, entirely unlike PHP. Great job guys!

Martin


Yahoo! Groups Sponsor
ADVERTISEMENT




To unsubscribe from this group, send an email to:
ClearSilver-unsubscribe@yahoogroups.com



Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.

#134 From: Brandon Long <blong@...>
Date: Mon Oct 20, 2003 11:37 pm
Subject: Announce ClearSilver 0.9.6
blong42
Send Email Send Email
 
Its been awhile since I've made a public release, so I figured I'd wrap
up the recent changes into a new release.

The main new feature in this release is the ability to set up a callback
for handling Client data.  HTTP/1.1 specifies that there is client data
(entity-data) for only PUT and POST requests.  The CGI Kit comes with
default handlers for the following:
   Method Type
   POST   application/x-www-form-urlencoded (default HTTP/1.1 type)
   POST   multipart/form-data (RFC 2388)
   PUT    anytype (raw data upload)

With the new callback system, you can now write handlers for XML-RPC and
SOAP, or whatever special method/types you want.  See the documentation
in cgi/cgi.h for more information.

Also, we extended the text to html conversion to make it more
controllable.  You can now set whether to have links open in new
windows, to associate CSS classes with links, and to have links use a
"bounce URL" for click tracking or referer hiding.

Additionally, we added some "nice to have" cgi_set_valuef and
cgi_get_valuef functions for doing printf-style format strings in C.

There were also bug fixes, as always, and some more documentation
especially of the HDF C API.

Get it while its hot.
http://www.clearsilver.net/downloads/

Brandon
--
  "We don't understand the software, and sometimes we don't understand
   the hardware, but we can *see* the blinking lights!" -- Unknown
                                            http://www.fiction.net/blong/

#135 From: Scott Hassan <hassan-yahoo@...>
Date: Thu Oct 23, 2003 5:59 pm
Subject: example 2
scotthassan
Send Email Send Email
 
The code is incorrect for example 2 at the bottom of the following
page:

http://www.clearsilver.net/docs/python/examples.cst

It needs to have a call to render():

   import neo_cgi
   import neo_util  # you must import neo_cgi first...
   import neo_cs    # you must import neo_cgi first...

   hdf = neo_util.HDF()  # create an HDF dataset
   hdf.setValue("hdf.loadpaths.0","/my/path")  # setup a load path
   hdf.readFile("my_file.hdf") # read some HDF data
   hdf.setValue("CGI.foo","bar")

   cs = neo_cs.CS(hdf)

   cs.parseStr("") # parse a string
   print cs.render()

   cs.parseFile("my_file.cst") # parse a file from disk
   print cs.render()

Cheers,

Scott

#136 From: "neurondata" <dkeehn@...>
Date: Sun Oct 26, 2003 10:44 pm
Subject: Using HTML Tidy on CS templates
neurondata
Send Email Send Email
 
Is there any way to force tidy to ignore the following:

<?cs if:count > #0 ?>

I've tried a variety of configuration settings but to
no avail.

tidy insists on the following result:

<?cs if:count ?>
#0 ?>

#137 From: Alan Braverman <alanb@...>
Date: Wed Nov 5, 2003 1:51 am
Subject: ClearSilver under Solaris
alanb42
Send Email Send Email
 
Is anyone using ClearSilver under Solaris?  A friend is thinking of
using Python + ClearSilver and simply wants to know if it compiles and
works under Solaris.

Thanks,
Alan

#138 From: Dan Janowski <danj@...>
Date: Wed Nov 5, 2003 2:14 pm
Subject: Re: ClearSilver under Solaris
djjanowski
Send Email Send Email
 
I am running clearsilver + ruby on solaris. It does build and does work
quite well.

Dan

On Tuesday, Nov 4, 2003, at 20:51 America/New_York, Alan Braverman
wrote:

> Is anyone using ClearSilver under Solaris?  A friend is thinking of
> using Python + ClearSilver and simply wants to know if it compiles and
> works under Solaris.
>
> Thanks,
> Alan
>
>
> ------------------------ Yahoo! Groups Sponsor
> ---------------------~-->
> Buy Ink Cartridges or Refill Kits for your HP, Epson, Canon or Lexmark
> Printer at MyInks.com. Free s/h on orders $50 or more to the US &
> Canada.
> http://www.c1tracking.com/l.asp?cid=5511
> http://us.click.yahoo.com/mOAaAA/3exGAA/qnsNAA/W4wwlB/TM
> ---------------------------------------------------------------------
> ~->
>
> To unsubscribe from this group, send an email to:
> ClearSilver-unsubscribe@yahoogroups.com
>
>
>
> Your use of Yahoo! Groups is subject to
> http://docs.yahoo.com/info/terms/
>
>
>

#139 From: Jan-Henrik Haukeland <cs@...>
Date: Thu Nov 27, 2003 2:36 am
Subject: [patch] Comparing strings in csparse.c
cs@...
Send Email Send Email
 
Here's a patch for comparing strings in cs/csparse.c.:eval_expr_string.

Instead of using a plain strcmp when testing two string a new compare
function is used. It behaves like strcmp but with an extra quasi regex
feature[1], e.g. if the strings a and b is equal upto the '*' char
they are assumed to be equal[2].

In other words '*' can be used as a wildcard when two strings are
compared. For example the following two strings are equal:

    "/doc/installation/unix/index.csp" == "/doc/*"

This can be very useful when testing URIs as demonstrated in this
example snippet, where a "tab" is turned on or off depending on the
Request URI.

<A <?cs if:Request.URI=="/doc/*"?>class=tab-selected<?cs /if ?>
    HREF="/doc/">Documentation</A>


[1] The functionality is similar to url-mapping for Java Servlets, but
using POSIX regex(7) directly could be even more powerful, if it's not
to resource demanding?

[2] None of the parameter strings can start with '*' which makes sense
in URI "pattern" testing but otherwise maybe not? (it's easy to fix
though)

--
Jan-Henrik Haukeland

#140 From: Brandon Long <blong@...>
Date: Thu Nov 27, 2003 8:33 am
Subject: Re: [patch] Comparing strings in csparse.c
blong42
Send Email Send Email
 
On 11/27/03 Jan-Henrik Haukeland uttered the following other thing:
>
> Here's a patch for comparing strings in cs/csparse.c.:eval_expr_string.
>
> Instead of using a plain strcmp when testing two string a new compare
> function is used. It behaves like strcmp but with an extra quasi regex
> feature[1], e.g. if the strings a and b is equal upto the '*' char
> they are assumed to be equal[2].
>
> In other words '*' can be used as a wildcard when two strings are
> compared. For example the following two strings are equal:
>
>    "/doc/installation/unix/index.csp" == "/doc/*"
>
> This can be very useful when testing URIs as demonstrated in this
> example snippet, where a "tab" is turned on or off depending on the
> Request URI.
>
> <A <?cs if:Request.URI=="/doc/*"?>class=tab-selected<?cs /if ?>
>    HREF="/doc/">Documentation</A>
>
>
> [1] The functionality is similar to url-mapping for Java Servlets, but
> using POSIX regex(7) directly could be even more powerful, if it's not
> to resource demanding?
>
> [2] None of the parameter strings can start with '*' which makes sense
> in URI "pattern" testing but otherwise maybe not? (it's easy to fix
> though)

I'd prefer not to overload string equality with this.

If anything, I'd probably bring in the =~ operator from perl.

Hmm, or I'd have to actually bring in some regex matching function.

Ie, we could do:
<?cs if:Request.URI =~ "^/doc/" ?>

or:
<?cs if:re.match(Request.URI, "^/doc/") ?>

#1 would require adding the operator (we have room for one more before I
have to do a bunch of re-working to the parser), and then the supporting
code.  Not too hard.  We could even have it set match variables (like
$1, $2)... ugh, we're recreating perl.

#2 would require making the built-in function calls more powerful,
capable of taking more than one argument (and re-working the parser to
make that possible).

Brandon
--
  "The end move in politics is always to pick up a gun."
         -- R. Buckminster Fuller
                                            http://www.fiction.net/blong/

#141 From: Jan-Henrik Haukeland <cs@...>
Date: Fri Nov 28, 2003 2:06 am
Subject: Re: [patch] memory leak
cs@...
Send Email Send Email
 
I noticed that I lost 24 bytes when running linclude. Unfortunately I
haven't used time to investigate if things could be done better, the
included patch simply plugs the hole blindely (but correctly I belive).

Ps. Seems that the same hole can be found in csparse.c:lvar_eval, from
reading the code I can see that the same logic is used there. (This is
not patched!). (I've just started using clearsilver and haven't got
around to lvar yet :)

--
Jan-Henrik Haukeland

#142 From: David Jeske <jeske@...>
Date: Fri Nov 28, 2003 7:12 am
Subject: Re: [patch] Comparing strings in csparse.c
jeskeca
Send Email Send Email
 
-- Brandon Long wrote:
> <?cs if:re.match(Request.URI, "^/doc/") ?>

I like the simplicity of this.

Allowing multiple arguments in functions seems like a good idea.

#143 From: Brandon Long <blong@...>
Date: Sun Nov 30, 2003 4:34 am
Subject: Re: [patch] memory leak
blong42
Send Email Send Email
 
Cool, thanks, it'll be fixed in the next release.

Brandon

On 11/28/03 Jan-Henrik Haukeland uttered the following other thing:
>
> I noticed that I lost 24 bytes when running linclude. Unfortunately I
> haven't used time to investigate if things could be done better, the
> included patch simply plugs the hole blindely (but correctly I belive).
>
> Ps. Seems that the same hole can be found in csparse.c:lvar_eval, from
> reading the code I can see that the same logic is used there. (This is
> not patched!). (I've just started using clearsilver and haven't got
> around to lvar yet :)


--
   šUnlike the U.K. House of Commons, which runs on ritual, and thus
    rarely heartfelt, insults, the U.S. Congress runs on ritual, and thus
    often insincere, compliments..."  - Paul Coe Clark III, eWeek

#144 From: David Terrell <dbt@...>
Date: Thu Dec 4, 2003 10:22 pm
Subject: crash in csparse
dave_terrell
Send Email Send Email
 
platform: OpenBSD 3.1 i386

test18.cs dumps core

#0  0x400a7dea in calloc ()
#1  0x728a in call_eval (parse=0x1d140, node=0x17600, next=0xdfbfd1e8)
     at csparse.c:2700
#2  0x7ed2 in render_node (parse=0x1d140, node=0x17600) at csparse.c:3070
#3  0x7f3a in cs_render (parse=0x1d140, ctx=0x0, cb=0x179c <output>)
     at csparse.c:3087
#4  0x1956 in main (argc=3, argv=0xdfbfd280) at cstest.c:85

The rest look ok...

#145 From: David Terrell <dbt@...>
Date: Fri Jan 2, 2004 9:05 pm
Subject: how should this work?
dave_terrell
Send Email Send Email
 
I would have thought that one of the first three would work, but
only the last one does, which is obviously a problem... Ideas?  (Yes
I could probably refactor the dataset to use indexes, but I probably
have the same problem anyway).

Dataset:

stats.0.fields.0.name = count
stats.0.fields.1.name = year
stats.0.records.0 = 0
stats.0.records.0.count = 2
stats.0.records.0.year = 1998
stats.0.records.1 = 1
stats.0.records.1.count = 4
stats.0.records.1.year = 1999

template:

<?cs each:stat = stats ?>
<table>
<?cs each:record = stat.records ?>
  <tr>
   <?cs each:field = stat.fields ?>
    <td class="<?cs var:field ?>">
     var: <?cs var:record[field] ?><br>
     evar: <?cs evar:record[field] ?><br>
     lvar: <?cs lvar:record[value(field)] ?><br>
     field: <?cs lvar:record[year] ?><br>
     "field": <?cs var:record["year"] ?><br>
    </td>
   <?cs /each ?>
  </tr>
<?cs /each ?>
</table>
<?cs /each ?>

#146 From: David Terrell <dbt@...>
Date: Fri Jan 2, 2004 9:19 pm
Subject: Re: how should this work?
dave_terrell
Send Email Send Email
 
On Fri, Jan 02, 2004 at 03:05:51PM -0600, David Terrell wrote:
> I would have thought that one of the first three would work, but
> only the last one does, which is obviously a problem... Ideas?  (Yes
> I could probably refactor the dataset to use indexes, but I probably
> have the same problem anyway).

Never mind, obviously what I wanted was:
<?cs var:record[field.name] ?>

Sorry for the confusion.

> stats.0.fields.1.name = year
> ...
> stats.0.records.0.year = 1998

#147 From: Chris Green <cmg@...>
Date: Tue Jan 6, 2004 6:37 pm
Subject: [patch] RPM Spec + Makefile
cmgsprout
Send Email Send Email
 
1 patch and 1 spec file

The patch is to fix clearsilver-0.9.7/Makefile from calling
scripts/document.py directly and instead call "python
scripts/document.py"

It may be worth making all 3 of the scripts in the scripts directory
to use the #!/usr/bin/env python instead of the 3 different
paths they currently use.
Spec file changes:
- remove wdb.h since it's not in the UTL_SRC (under what conditions if
   any is this built?)
- remove ClearSilver.bs since it wasn't being installed anymore under
perl 5.8.1 ( this may be wrong - I'm on Mandrake 9. )
- %{perl_prefix}/share/man/man3/ClearSilver.3pm* instead of .gz to
take any form of non compression, .gzip or .bzip2
- added previous patch
hris Green <cmg@...>
You now have 14 minutes to reach minimum safe distance.

#148 From: Brandon Long <blong@...>
Date: Tue Jan 6, 2004 7:37 pm
Subject: Re: [patch] RPM Spec + Makefile
blong42
Send Email Send Email
 
Thanks!

Brandon

On 01/06/04 Chris Green uttered the following other thing:
> 1 patch and 1 spec file
>
> The patch is to fix clearsilver-0.9.7/Makefile from calling
> scripts/document.py directly and instead call "python
> scripts/document.py"
>
> It may be worth making all 3 of the scripts in the scripts directory
> to use the #!/usr/bin/env python instead of the 3 different
> paths they currently use.
>
>
>
>
> Yahoo! Groups Links
>
> To visit your group on the web, go to:
>  http://groups.yahoo.com/group/ClearSilver/
>
> To unsubscribe from this group, send an email to:
>  ClearSilver-unsubscribe@yahoogroups.com
>
> Your use of Yahoo! Groups is subject to:
>  http://docs.yahoo.com/info/terms/
>


>
> Spec file changes:
> - remove wdb.h since it's not in the UTL_SRC (under what conditions if
>   any is this built?)
> - remove ClearSilver.bs since it wasn't being installed anymore under
> perl 5.8.1 ( this may be wrong - I'm on Mandrake 9. )
> - %{perl_prefix}/share/man/man3/ClearSilver.3pm* instead of .gz to
> take any form of non compression, .gzip or .bzip2
> - added previous patch
>


> Chris Green <cmg@...>
> You now have 14 minutes to reach minimum safe distance.


--
   "Crazed with coding, he finally did something hideous and criminal -
    the kind of thing that most people think software engineers are
    capable of anyway.  It's all those long hours in front of the screen,
    huddled in rooms full of servers, drinking caffeinated drinks and
    eating Fritos."  -- Annalee Newitz
                            http://www.sfbg.com/SFLife/tech/42.html

#149 From: Chris Green <cmg@...>
Date: Thu Jan 8, 2004 9:59 pm
Subject: C: Getting nested items with <?cs> syntax in cgi
cmgsprout
Send Email Send Email
 
Hey Folks,

( long email -- I think there's a bug in loading a dataset using
hdf_set_value versus loading it from a file )

I'm currently working on a project to migrate out of a very simple
expansion templating system to using clearsilver. I've think I've
exhusted everything short of trying to use the ddd method you have in
cgi.c to figure it out..  Get t

My HDF::

cmg {
   copyright {
     0 = testing please work
     1 = ugh
   }
   please {
     dance = works
   }
}

  <?cs var:cmg.copyright.0 ?> does not print anything when expanded by my
code, but does when using static.cgi included with the distribution.

Is there any method that is required to be bound as a callback to get
index access to hdf from a clearsilver template working?  I ran into
this with html_escape and it's filter friends...

This

     cgi.AddKey("cmg.copyright.0", "testing please work");
     cgi.AddKey("cmg.copyright.1", "ugh");
     cgi.AddKey("cmg.please.dance", "works");

where AddKey is a wrapper around

     hdf_set_value(hdf,name,value); <- Could this be the wrong method
                                       to be using?


My rendering code (below) should only have 1 unknown feature:
cs_mkstring which appends everything on to a character
buffer. hdf_write() does spit out the data set the way it should look
to me...

only 2 cs tags:
       =<?cs var:html_escape(cmg.copyright.0.name) ?>=
       <?cs var:html_escape(cmg.please.dance) ?>

I found the cs_dump method too:

yields:

        literal
        literal
        var (null)
        literal
        var (null)
        literal

which renders as:
                    ==
		    works


Here's my Code: Sorry it's not in a compilable form

     CSPARSE *cparse = NULL;
     NEOERR *err = NULL;
     char *csOutBuf = NULL; // This must be initialized to NULL for cs_mkstring

     //  This is from clearsilver-0.9.7/cgi.c
     do
     {
         err = cs_init (&cparse, hdf);
         if (err != STATUS_OK) break;
         err = cs_register_strfunc(cparse, "url_escape", cgi_url_escape);
         if (err != STATUS_OK) break;
         err = cs_register_strfunc(cparse, "html_escape",
cgi_html_escape_strfunc);
         if (err != STATUS_OK) break;
         err = cs_register_strfunc(cparse, "text_html", cgi_text_html_strfunc);
         if (err != STATUS_OK) break;
         err = cs_register_strfunc(cparse, "js_escape", cgi_js_escape);
         if (err != STATUS_OK) break;
         err = cs_register_strfunc(cparse, "html_strip", cgi_html_strip_strfunc);
         if (err != STATUS_OK) break;
     } while (0);

     if(err)
     {
         nerr_log_error(err);
         return false;
     }

     err = cs_parse_string(cparse, outStr, strlen(outStr));

     if(err)
     {
         nerr_log_error(err);
         return false;
     }

     /* now, fill in the csOutbuf with the cs_mkstring function*/
     err = cs_render(cparse, &csOutBuf, cs_mkstring);
     cs_destroy(&cparse);

     if(err)
     {
         nerr_log_error(err);
         return safety;
     }

Any help you all can offer would be greatly appreciated. I'm pulling
my hair out.

The biggestest difference I can see is I'm

    1) Creating HDF dataset on the fly,
    2) Using cs_parse_string rather than parse_file but cs_parse_file
       is a wrapper...

AHAH!  It's something to do with 1.

     hdf_write_file(hdf, "/tmp/dataset");
     hdf_destroy(&hdf);
     char *data = readFromFile("/tmp/dataset");
     hdf_init(&hdf);
     hdf_read_string(hdf, data);

Magically makes things work as expected... Any ideas?

--
Chris Green <cmg@...>
Warning: time of day goes back, taking countermeasures.

#150 From: Brandon Long <blong@...>
Date: Thu Jan 8, 2004 10:35 pm
Subject: Re: C: Getting nested items with <?cs> syntax in cgi
blong42
Send Email Send Email
 
It doesn't look like you're doing anything wrong that I can see.

hdf_read_file (and the read_string equiv) both use the same
function, _set_value, to set up data values that hdf_set_value uses.

Which means it might be an order of operation issue, or more likely
something getting messed up in the data structure.

Do you do anything with the dataset besides set values?  Ie, deleting
nodes or sorting, etc?  There have been some bugs in those, but they've
all been fixed as of v0.9.7 (well, the ones we know of).

Outside of the obvious one, which I'm guessing is just from copying it
here:
>       =<?cs var:html_escape(cmg.copyright.0.name) ?>=
your example dataset is only cmg.copyright.0 without the .name

The other thing to try would be to rearrange the cmg.copyright
statements, maybe there is something weird the first time you call
cgi.AddKey (I assume this is actually c++?)

Otherwise, it'll take a debugger.  In place of the launching the X based
debugger, you might try something like the cgi_debug_init code, which
just takes a file of k=v pairs per line, each of which is a CGI env var.

Or, if you can distill this to a program which actually causes the
problem, I can debug it.

Brandon

On 01/08/04 Chris Green uttered the following other thing:
> Hey Folks,
>
> ( long email -- I think there's a bug in loading a dataset using
> hdf_set_value versus loading it from a file )
>
> I'm currently working on a project to migrate out of a very simple
> expansion templating system to using clearsilver. I've think I've
> exhusted everything short of trying to use the ddd method you have in
> cgi.c to figure it out..  Get t
>
> My HDF::
>
> cmg {
>   copyright {
>     0 = testing please work
>     1 = ugh
>   }
>   please {
>     dance = works
>   }
> }
>
>  <?cs var:cmg.copyright.0 ?> does not print anything when expanded by my
> code, but does when using static.cgi included with the distribution.
>
> Is there any method that is required to be bound as a callback to get
> index access to hdf from a clearsilver template working?  I ran into
> this with html_escape and it's filter friends...
>
> This
>
>     cgi.AddKey("cmg.copyright.0", "testing please work");
>     cgi.AddKey("cmg.copyright.1", "ugh");
>     cgi.AddKey("cmg.please.dance", "works");
>
> where AddKey is a wrapper around
>
>     hdf_set_value(hdf,name,value); <- Could this be the wrong method
>                                       to be using?
>
>
> My rendering code (below) should only have 1 unknown feature:
> cs_mkstring which appends everything on to a character
> buffer. hdf_write() does spit out the data set the way it should look
> to me...
>
> only 2 cs tags:
>       =<?cs var:html_escape(cmg.copyright.0.name) ?>=
>       <?cs var:html_escape(cmg.please.dance) ?>
>
> I found the cs_dump method too:
>
> yields:
>
>        literal
>        literal
>        var (null)
>        literal
>        var (null)
>        literal
>
> which renders as:
>                    ==
> 		   works
>
>
> Here's my Code: Sorry it's not in a compilable form
>
>     CSPARSE *cparse = NULL;
>     NEOERR *err = NULL;
>     char *csOutBuf = NULL; // This must be initialized to NULL for cs_mkstring
>
>     //  This is from clearsilver-0.9.7/cgi.c
>     do
>     {
>         err = cs_init (&cparse, hdf);
>         if (err != STATUS_OK) break;
>         err = cs_register_strfunc(cparse, "url_escape", cgi_url_escape);
>         if (err != STATUS_OK) break;
>         err = cs_register_strfunc(cparse, "html_escape",
cgi_html_escape_strfunc);
>         if (err != STATUS_OK) break;
>         err = cs_register_strfunc(cparse, "text_html", cgi_text_html_strfunc);
>         if (err != STATUS_OK) break;
>         err = cs_register_strfunc(cparse, "js_escape", cgi_js_escape);
>         if (err != STATUS_OK) break;
>         err = cs_register_strfunc(cparse, "html_strip",
cgi_html_strip_strfunc);
>         if (err != STATUS_OK) break;
>     } while (0);
>
>     if(err)
>     {
>         nerr_log_error(err);
>         return false;
>     }
>
>     err = cs_parse_string(cparse, outStr, strlen(outStr));
>
>     if(err)
>     {
>         nerr_log_error(err);
>         return false;
>     }
>
>     /* now, fill in the csOutbuf with the cs_mkstring function*/
>     err = cs_render(cparse, &csOutBuf, cs_mkstring);
>     cs_destroy(&cparse);
>
>     if(err)
>     {
>         nerr_log_error(err);
>         return safety;
>     }
>
> Any help you all can offer would be greatly appreciated. I'm pulling
> my hair out.
>
> The biggestest difference I can see is I'm
>
>    1) Creating HDF dataset on the fly,
>    2) Using cs_parse_string rather than parse_file but cs_parse_file
>       is a wrapper...
>
> AHAH!  It's something to do with 1.
>
>     hdf_write_file(hdf, "/tmp/dataset");
>     hdf_destroy(&hdf);
>     char *data = readFromFile("/tmp/dataset");
>     hdf_init(&hdf);
>     hdf_read_string(hdf, data);
>
> Magically makes things work as expected... Any ideas?
>
> --
> Chris Green <cmg@...>
> Warning: time of day goes back, taking countermeasures.
>
>
>
>
>
>
> Yahoo! Groups Links
>
> To visit your group on the web, go to:
>  http://groups.yahoo.com/group/ClearSilver/
>
> To unsubscribe from this group, send an email to:
>  ClearSilver-unsubscribe@yahoogroups.com
>
> Your use of Yahoo! Groups is subject to:
>  http://docs.yahoo.com/info/terms/
>

--
    "Of the delights of this world man cares most for sexual intercourse,
      yet he has left it out of his heaven." -- Mark Twain
                                            http://www.fiction.net/blong/

#151 From: Chris Green <cmg@...>
Date: Fri Jan 9, 2004 1:05 am
Subject: Re: C: Getting nested items with <?cs> syntax in cgi
cmgsprout
Send Email Send Email
 
Brandon Long wrote:

>It doesn't look like you're doing anything wrong that I can see.
>
>hdf_read_file (and the read_string equiv) both use the same
>function, _set_value, to set up data values that hdf_set_value uses.
>
>Which means it might be an order of operation issue, or more likely
>something getting messed up in the data structure.
>
>Do you do anything with the dataset besides set values?  Ie, deleting
>nodes or sorting, etc?  There have been some bugs in those, but they've
>all been fixed as of v0.9.7 (well, the ones we know of).
>
>
Nope, nothing other than adding the 4 nodes.

>Outside of the obvious one, which I'm guessing is just from copying it
>here:
>
>
>>      =<?cs var:html_escape(cmg.copyright.0.name) ?>=
>>
>>
>your example dataset is only cmg.copyright.0 without the .name
>
>
I changed the dataset too many times figuring out the problem.  I'll
create a non-cgi replication of this if I can.   I need to do that just
to debug this thing cause I hate the spinlock gdb stuff.

>The other thing to try would be to rearrange the cmg.copyright
>statements, maybe there is something weird the first time you call
>cgi.AddKey (I assume this is actually c++?)
>
>
Yup, it is.   Nothing is really fancy with it since the contructor for
cgi does hdf_init and addkey then write spat out a good dataset and then
rereading it back in worked around it.

>Otherwise, it'll take a debugger.  In place of the launching the X based
>debugger, you might try something like the cgi_debug_init code, which
>just takes a file of k=v pairs per line, each of which is a CGI env var.
>
>Or, if you can distill this to a program which actually causes the
>problem, I can debug it.
>

I'll do that and send you a copy tommorrow. Printed out a copy of
neo_hdf to read. Thanks!

Chris

#152 From: Chris Green <cmg@...>
Date: Fri Jan 9, 2004 3:48 am
Subject: Re: C: Getting nested items with <?cs> syntax in cgi
cmgsprout
Send Email Send Email
 
Chris Green <cmg@...> writes:

> Brandon Long wrote:
>
>>It doesn't look like you're doing anything wrong that I can see.

Thanks for the confirmation. Sorry for wasting your time.  Ended up
that the strings were being inserted into the dataset as

  "cmg.copyright.0.name " instead of  "cmg.copyright.0.name"

ARGh.  Sorry for wasting your time :^)
--
Chris Green <cmg@...>
I've had a perfectly wonderful evening. But this wasn't it.
      -- Groucho Marx

#153 From: David jeske <jeske@...>
Date: Fri Jan 9, 2004 8:38 am
Subject: Re: C: Getting nested items with <?cs> syntax in cgi
jeskeca
Send Email Send Email
 
-- Chris Green wrote:
> "cmg.copyright.0.name " instead of "cmg.copyright.0.name"

That seems like some kind of bug, since dump/reload is supposed to
produce the same dataset. This either means that we should have a way
to escape space in keynames in HDF datafiles, or we should prevent
them from occuring in keys.
I'm sure Brandon will have an idea of which makes more sense.

#154 From: Chris Green <cmg@...>
Date: Fri Jan 9, 2004 2:33 pm
Subject: Re: C: Getting nested items with <?cs> syntax in cgi
cmgsprout
Send Email Send Email
 
> -- Chris Green wrote:
>> "cmg.copyright.0.name " instead of "cmg.copyright.0.name"
>
> That seems like some kind of bug, since dump/reload is supposed to
> produce the same dataset. This either means that we should have a way
> to escape space in keynames in HDF datafiles, or we should prevent
> them from occuring in keys.
> I'm sure Brandon will have an idea of which makes more sense.
>

I'll have to concur since I don't know of a way to access something
with a trailing space from a <?cs var:... ?> and that it doesn't
persist against the load/write cycle

Here's a sample piece of code that I've been playing to test

I've been using the followign to compile

gcc hdftest.c -o hdftest -I/usr/local/include/ClearSilver -lneo_cgi -lneo_cs
-lneo_utl -lz

--
Chris Green <cmg@...>
Laugh and the world laughs with you, snore and you sleep alone.

#155 From: Chris Green <cmg@...>
Date: Fri Jan 9, 2004 4:07 pm
Subject: small site errors...
cmgsprout
Send Email Send Email
 
More pestering... :)

How are the c api docs generated?  It seems to be missing things like
hdf_write_file(), hdf_read_from_fp() etc..  Would it be possible to
get an alphabetical index in addition to the what looks like file
order index?

Here's a few errors I've noted on the docs section.

http://www.clearsilver.net/docs/man_templates.hdf#loop

  guaruntee ->  guarantee

http://www.clearsilver.net/docs/perl/

The Perl module for ClearSilver is not contained in the main
download. You'll need to get it here.

from the link:

"ClearSilver 0.7.2 and later distributions include ClearSilver.pm" Should
include a link to original page

http://www.clearsilver.net/downloads/

Downloads -> Contrib (perl-cs-0.7.0-2.tar.gz [website]) should be marked as
obsolete
--
Chris Green <cmg@...>
"I have no ability to read string
        handling code in a gaim window" -- me

#156 From: Brandon Long <blong@...>
Date: Fri Jan 9, 2004 11:03 pm
Subject: Re: C: Getting nested items with <?cs> syntax in cgi
blong42
Send Email Send Email
 
On 01/09/04 Chris Green uttered the following other thing:
> David jeske <jeske@...> writes:
>
> > -- Chris Green wrote:
> >> "cmg.copyright.0.name " instead of "cmg.copyright.0.name"
> >
> > That seems like some kind of bug, since dump/reload is supposed to
> > produce the same dataset. This either means that we should have a way
> > to escape space in keynames in HDF datafiles, or we should prevent
> > them from occuring in keys.
> > I'm sure Brandon will have an idea of which makes more sense.
> >
>
> I'll have to concur since I don't know of a way to access something
> with a trailing space from a <?cs var:... ?> and that it doesn't
> persist against the load/write cycle

Current, hdf_set_value doesn't do any validation of the variable name,
and the current HDF file format is certainly not guarunteed to have an
exact representation of the data.

So, using hdf_set_value you can set varnames that can't be represented
in the HDF file format, and can't be accessed in CS because of lack of
escaping/etc.

The main things that come to mind are space issues (HDF values from the
file format won't guaruntee whitespace compatibility, mostly in trailing
or preceding whitespace), and certain characters like =, :, etc.

Brandon
--
  "We [the Net] get portrayed in a crappy light...  This time it's a cult.
   Usually, it's that we're all child pornographers."
                     -- Internet Defender, _Washington Post_, 3-29-97
                                            http://www.fiction.net/blong/

#157 From: Brandon Long <blong@...>
Date: Fri Jan 9, 2004 11:34 pm
Subject: Re: small site errors...
blong42
Send Email Send Email
 
On 01/09/04 Chris Green uttered the following other thing:
> More pestering... :)
>
> How are the c api docs generated?  It seems to be missing things like
> hdf_write_file(), hdf_read_from_fp() etc..  Would it be possible to
> get an alphabetical index in addition to the what looks like file
> order index?

They are generated using scripts/document.py (make hdf).  It works by
reading the comments in the header files, and its far from perfect.  The
information in the header files is the latest version.  The web site
version is definitely somewhat lacking.  hdf_write_file is there, but
hfd_read_from_fp is an internal function, so its not documented.

The rest of the errors you've pointed out I've now fixed.

Brandon
--
   "i mean theres always the golden rule   but what if i LIKE things done to
   me that the Bible says i cannot posibly enjoy     can i do them to others"
         - Anne Nowinski
                                            http://www.fiction.net/blong/

#158 From: Ryan King <ryan@...>
Date: Thu Jan 22, 2004 9:35 pm
Subject: Clearsilver cookie security hole?
ryanaking
Send Email Send Email
 

The cgi_cookie_set C function never sets the 'secure' flag on the Set-Cookie: directive, which means that if I set a cookie in a CGI at https://mydomain.com/something, and then later the user visits http://mydomain.com/, that cookie will travel in the clear over the network. This is especially bad for sites that use session cookies to maintain a logged-in state for a user... (it becomes extremely easy to hijack the user's session). I recommend that an additional argument be provided to the cgi_cookie_set function in the ClearSilver C API to allow setting of the secure flag...

Cheers,
Ryan


http://www.ietf.org/rfc/rfc2109.txt


#159 From: cs@...
Date: Fri Jan 23, 2004 5:46 pm
Subject: FYI: ServerPages
cs@...
Send Email Send Email
 
I thought you may be interested to know that we have used ClearSilver
to implement "ClearSilverServerPages" (csp). You can read about CSP
here: http://zild.org/doc/serverpage.csp (yes, that is a "live"
serverpage). A few example pages can also be viewed at this URL:
http://zild.org/examples/serverpages/index.csp

Cheers!
--
Jan-Henrik Haukeland

#160 From: David Jeske <jeske@...>
Date: Fri Jan 23, 2004 10:12 pm
Subject: Re: Clearsilver cookie security hole?
jeskeca
Send Email Send Email
 
Hi Ryan,

This sounds like a great suggestion. I'm guessing we would probably
do two things:

- add a magic HDF variable which will make all cookie sets include
"secure"
- add a new "cgi_cookie_set_secure" function

This way we won't break existing users who are calling
cgi_cookie_set.

Brandon???

-- Ryan King wrote:
> The cgi_cookie_set C function never sets the 'secure' flag on the
> Set-Cookie: directive, which means that if I set a cookie in a CGI
> at https://mydomain.com/something, and then later the user visits
> http://mydomain.com/, that cookie will travel in the clear over the
> network. This is especially bad for sites that use session cookies
> to maintain a logged-in state for a user... (it becomes extremely
> easy to hijack the user's session). I recommend that an
> additional argument be provided to the cgi_cookie_set function
> in the ClearSilver C API to allow setting of the secure flag...
>
> Cheers,
> Ryan
>
> http://www.ietf.org/rfc/rfc2109.txt

Messages 131 - 160 of 1451   Oldest  |  < Older  |  Newer >  |  Newest
Add to My Yahoo!      XML What's This?

Copyright © 2010 Yahoo! Inc. All rights reserved.
Privacy Policy - Terms of Service - Guidelines NEW - Help