RE: [Zope] Best Practice for including Javascript in Zope Applications

2008-01-04 Thread Matt Hollingsworth
Hello,

Ok, I came up with a solution that I like; today I spent a little while
making it so I don't have to load things into memory before they are served.
Now it works quite nicely for serving out js/css/gui pics.  I won't post
what I did right now, as I haven't really cleaned it up and I'm ashamed of
how it looks at the moment,  but I'll post the usage of it to see if anyone
would like to use it after I clean it up:

...
from util import FileSystemResource #it's just in a utility module for my
current project at the moment
...

MyZopeObject(Implicit,Item,Whatever):

#"js" and "css" are paths that are considered relative to my package
directory (not the cwd for zope).  It can be absolute too, if desired.
js = FileSystemResource("js","Javascript Repository") 
css = FileSystemResource("css","CSS Repository")

Now, say that there is ext-all.js in a directory called
"/path/to/zope/Products/MyProduct/js/".  You could then link to the java
script file by going to http://domain.com:8080/myZopeObject/js/ext-all.js.
In particular, in dtml, I have a standard_html_header that looks something
like this:

==standard_html_header.dtml==



























This is a title.


==!End standard_html_header.dtml==

Then in MyZopeObject, I wrap up my DTML in a method like so:

.

_main = DTMLFile("dtml/main",globals())
def main(self):
main_js=["ext-all.js","main.js"]

return _main(self.REQUEST,local_js = main_js)


I did the whole local_js thing so I could control what JS got dropped into
what pages without having to write a different header for each one.  I will
probably also do the same thing for the css just in case I want
page-specific css files.

This is what I'm doing at the moment, and it's working great.  If this would
be useful to someone else, I'll give it more than an hour and a half of
thought, rewrite it more intelligently, and make it available.  Otherwise,
thanks to everyone for their comments!

-Matt

-Original Message-
From: Tim Nash [mailto:[EMAIL PROTECTED] 
Sent: Thursday, January 03, 2008 12:38 PM
To: Matt Hollingsworth
Cc: zope@zope.org
Subject: Re: [Zope] Best Practice for including Javascript in Zope
Applications

Matt,
  Please keep us updated on your strategy for serving extjs. I am also
considering making my application a product for distribution but I was
thinking along the lines of an install script for macs that would set
up the apache webserver. I also like your approach.

BTW, I haven't done it, but couldn't you just store an object in zodb
that has a pointer to  your video on the filesystem and access the
video via a zope product? But maybe that is what LocalFS does, I
haven't checked.

see ya in the extjs forum. Just do a search for "zope"
Tim


On 1/2/08, Matt Hollingsworth <[EMAIL PROTECTED]> wrote:
> Yep!  I have had very good luck with it so far; my little hack that I
posted
> works like a (klutzy) charm and ExtJS is great with zope.  The ExtJS folks
> are very well organized, and the library is quite powerful.  It's working
> great.  However, my application doesn't have quite the segregation that
> yours does; ExtJS and zope (DTML in particular) are much more
intermingled,
> and can't be easily separated.  This application is actually a frontend
for
> a Java library that controls instruments at CERN (a research lab I work
> for), and I love the solution that it has presented.  It works like a
charm.
> (in case you're curious, it makes use of a wonderful python library I ran
> across called JPype (http://jpype.sourceforge.net) to execute the Java
code)
>
> I am going to be accessing Zope through apache with the VHM, but there are
> multiple reasons why I don't want to serve the js through apache.  This
same
> principle is the reason that I don't want to upload things through FTP or
> WebDAV.  I'm making a product, and I would like to keep it atomic, i.e., I
> want the only install procedure to be "copy product folder to
> instance/Products".  Uploading via WebDAV, or hosting the javascript using
> separate software, defeats that purpose.
>
> The solution that Tom proposed (LocalFS) seems to be what I want, but the
> problem is that I think it is way too out of date; it crashed my zope
server
> (2.10.5) when I installed it.  It says nothing can be found after I add an
> instance through the ZMI, and this is after I fixed a deprecated import (
> from OFS.content_types import find_binary -> from zope.app.content_types
> import find binary).  I had to completely remove the product to get my
Zope
> instance to work again.
>
> I'm getting the feeling that there isn't really a (recent) canned solution
> for accessing file system content, which is... strange at best,
considering
> all the power that zope has at its disposal.  You would think that
accessing
> the file system would be present just because it is so simple to do.  I'm
> not complaining, as I'm *very* happy with zope, I'm just surprised :).  I

Re: [Zope] Defining a Variable

2008-01-04 Thread Victor Subervi
Thank you both. However, it still doesn't work :( I have replaced "getQuote"
with "getQuote()", but to no avail. Other ideas?
*Error Type: RuntimeError
Error Value: external method could not be called because it is None*
*TIA,*
*Victor*

On Jan 3, 2008 2:26 PM, Dieter Maurer <[EMAIL PROTECTED]> wrote:

> Victor Subervi wrote at 2008-1-2 14:44 -0400:
> > ...
> >
> >
> >
> > 
> >  
>
> As Andreas already has pointed out, you probably need "getQuote()"
> rather than "getQuote" (as the name suggests, it is a method not a
> value).
>
> >   
>
> "?var" in a path expression means: replace "?var" by the value of "var".
>
> Therefore, if "num" contains the right value, the above should work.
>
>
>
> --
> Dieter
>
___
Zope maillist  -  Zope@zope.org
http://mail.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists - 
 http://mail.zope.org/mailman/listinfo/zope-announce
 http://mail.zope.org/mailman/listinfo/zope-dev )


Re: [Zope] Defining a Variable

2008-01-04 Thread David Bear
On Wed, Jan 02, 2008 at 02:44:24PM -0400, Victor Subervi wrote:
> Hi;
> I have this in a page template:
> 
> 
> 
> 
>  
>   
>
>
> 
>  The quotes
> 
>
>   
>  
> 
> 
> 
> 
> Now, I thought that was the correct way to call the variable "num" (that is,
> with the question mark: "?num"). Apparently, I'm mistaken. I've even tried
> defining it this way:

I didn't see a followup on this post, so I thought I would add my
ignorance to the discussion.

first, I don't think you can assign a variable name to a python
function using tal and then have tal 'call' the function.

second, I think what you do want is the get the results of calling
getQuote into the variable called 'num', and then use those results
elsewhere.

I think tal variables can all be first class python objects. If not,
any standard python object works -- in other words, a list, tupple,
string, dictionary, etc. If you have your own object, it will need to
have an iterator method defined for it -- but then, I wouldn't know
how to make the new class known to zope.


> 
>   
> to make sure that num was properly assigned. What am I missing? Also, if I
> have a dir called "scripts" in which "getQuote" exists, and "scirpts" is in
> the path, shouldn't that notation work okay?

acquisition will find many things. What does getQuote return though?

> TIA,
> Victor

> ___
> Zope maillist  -  Zope@zope.org
> http://mail.zope.org/mailman/listinfo/zope
> **   No cross posts or HTML encoding!  **
> (Related lists - 
>  http://mail.zope.org/mailman/listinfo/zope-announce
>  http://mail.zope.org/mailman/listinfo/zope-dev )


-- 
David Bear
phone:  602-496-0424
fax:602-496-0955
College of Public Programs/ASU
University Center Rm 622
411 N Central
Phoenix, AZ 85007-0685
 "Beware the IP portfolio, everyone will be suspect of trespassing"
___
Zope maillist  -  Zope@zope.org
http://mail.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists - 
 http://mail.zope.org/mailman/listinfo/zope-announce
 http://mail.zope.org/mailman/listinfo/zope-dev )