Re: [Zope-dev] Problem using External Method

2001-01-24 Thread Shane Hathaway

"Espen S. Frederiksen" wrote:
 
 The problem occur when I try to split up the function as
 shown below. I would like to store the data list, update it
 if nessesary and return it when appropriate. Am I making it
 unessesary complex when I use the class? Is there maybe a
 way to declare the data list global within the module? Or
 is there another, possibly different, way to do this?

Take out all the "import __main__" statements and you should be fine.

Python lets you access two namespaces at once: the "local" namespace and
the "global" namespace.  Were it not for the global namespace, you would
need to do something like "import __main__".  But since globals are
there, everything available at the module level is also available at the
function level.

Shane

 class Testclass:
 def setdata(self,val1,val2,val3):
 self.data = [val1,val2,val3]
 def updatedata(self, index):
 self.data[index] = self.data[index]+1
 def display(self):
 return self.data
 
 x = Testclass()
 
 def createdata(var1, var2, var3):
 import __main__
 x.setdata(var1, var2, var3)
 
 def update(index):
 import __main__
 x.updatedata(index)
 
 def returndata():
 import __main__
 return x.display()

___
Zope-Dev maillist  -  [EMAIL PROTECTED]
http://lists.zope.org/mailman/listinfo/zope-dev
**  No cross posts or HTML encoding!  **
(Related lists - 
 http://lists.zope.org/mailman/listinfo/zope-announce
 http://lists.zope.org/mailman/listinfo/zope )




[Zope-dev] Re: DTML block parsing - better then C/C++

2001-01-24 Thread Jon Franz

This allowance for nested comments, as long as they are properly nested,
is more then many laguages, such as C/C++, give you in the way of allowing
nested comments - So I think its more then acceptable in its current form -
good job!

OK, I have developed a new patch that almost completely fixes this
issue. In fact I am happier with it in general than my first patch.
There is only one flaw, although you can nest comments inside of one
another, and you can have any manner of broken dtml inside, if you open
another comment tag inside it, it must be properly balanced or you will
get a parse error. Here are some examples:

___
Zope-Dev maillist  -  [EMAIL PROTECTED]
http://lists.zope.org/mailman/listinfo/zope-dev
**  No cross posts or HTML encoding!  **
(Related lists - 
 http://lists.zope.org/mailman/listinfo/zope-announce
 http://lists.zope.org/mailman/listinfo/zope )




[Zope-dev] ZSQL method - Can it 'resolve' a property value?

2001-01-24 Thread Schmidt, Allen J.

I have an index_html which runs queries that count the number of items in a
category and displays the number next to each category which is a link to
the SearchResults page that will pass the name of the property to the next
query. This is how I do the count part:

(dtml-in countAnnouncementsdtml-var announcements null=""/dtml-in)

I have a sql method for each count query and each uses a property (like
announcements above) that contains a list of numbers (i.e. Announcements
has: '001','002','003','004' )
So the query does a WHERE category IN ('001','002','003','004') statement by
resolving the property and getting the list of numbers. This part works
well.

Now,...
When I try to do the same thing on the SearchResults page, using a new sql
method, I cannot get the property to resolve. I try using an attribute of
the category for testing so it prompts for the category name when I test it.
I use the MULTIPLE attribute with a DTML-SQLTEST to produce the "WHERE IN"
type of query. I type in the name of the property that contains the list of
numbers and all I get for the query is:  WHERE category =
('nameOfProperty')

This makes less sense as I am describing it, but it may be clear to someone.


Thanks

Allen

___
Zope-Dev maillist  -  [EMAIL PROTECTED]
http://lists.zope.org/mailman/listinfo/zope-dev
**  No cross posts or HTML encoding!  **
(Related lists - 
 http://lists.zope.org/mailman/listinfo/zope-announce
 http://lists.zope.org/mailman/listinfo/zope )




[Zope-dev] Mapping multiple IP addresses/domains to one Zope

2001-01-24 Thread Aaron Gillette

My company has many sites which share some content. Each site uses a
different IP address. I would like to bring all of these sites into one
instance of Zope on an NT machine. I am looking at the possibility of either
1) running Zope behind IIS, or 2) running Zserver exclusively. Personally,
I'd rather take the time in advance to learn how to do the whole thing in
Zope, as I envision switching to a Linux server in the near future, and I
believe that this would ease the migration.

My question is this: How do I map different IP addresses/domains to
different Zope folders? I am pretty new to Python (but learning fast!), so
any snippets of sample code would be much obliged.

Thanks in advance,

Aaron Gillette


___
Zope-Dev maillist  -  [EMAIL PROTECTED]
http://lists.zope.org/mailman/listinfo/zope-dev
**  No cross posts or HTML encoding!  **
(Related lists - 
 http://lists.zope.org/mailman/listinfo/zope-announce
 http://lists.zope.org/mailman/listinfo/zope )




RE: [Zope-dev] Old to new registerClass

2001-01-24 Thread Brian Lloyd

 Im hacking around IEMethod and it uses an old style of class 
 initialisation
 in the __init__.py along the lines of:
 
   misc_ = { 'imagef':'foo','imageg':'goo', }
   lang_= { 'en':'lang_en','sv':'lang_sv', }
 
 I want to put this into a modern style product initialisation
 (context.registerClass). Looking at this functions API it didn't become
 readily apparent how I can pass in these values. This would be 
 nice to do so
 I don't have any hacking of dtml to do. Has anyone done this / got any
 advice?

Hi Andy - the modern product init doesn't currently provide 
any special handling of misc_ (though it probably should in 
the future to make registration an explicit operation). If
a misc_ mapping is found in your __init__.py by the product
initialization code, its items will be installed in the 
misc_ object of the top-level application object. So you'll 
want to do something like:


from Globals import ImageFile

misc_={'imagef': ImageFile('foo.gif', globals()),
   'imageg': ImageFile('goo.gif', globals()),
  }

When your product is initialized, the items in your misc_ 
will be installed in the application objects' misc_, and 
you can refer to them thereafter in your dtml as:

  dtml-var BASEPATH1/misc_/imagef
  dtml-var BASEPATH1/misc_/imageg

etc. I don't know what 'lang_' does, so I'm not sure what 
to advise you there...

Brian Lloyd[EMAIL PROTECTED]
Software Engineer  540.371.6909  
Digital Creations  http://www.digicool.com 





___
Zope-Dev maillist  -  [EMAIL PROTECTED]
http://lists.zope.org/mailman/listinfo/zope-dev
**  No cross posts or HTML encoding!  **
(Related lists - 
 http://lists.zope.org/mailman/listinfo/zope-announce
 http://lists.zope.org/mailman/listinfo/zope )




Re: [Zope-dev] Problem using External Method

2001-01-24 Thread Shane Hathaway

On Wed, 24 Jan 2001, Espen Sorbye Frederiksen wrote:
 I did what you suggested, but I am still a bit stuck. Maybe I call them
 wrong in my code. I use the call below but get an error.

 dtml-call expr="createdata('test1','test2','test3')"
 dtml-var expr="returndata()"

 Error Type: AttributeError
 Error Value: data

 any suggestions what I do wrong,

I suggest you run Zope in "-D" mode so you can see tracebacks easily.
They can pinpoint the exact source of problems like this.

Shane


___
Zope-Dev maillist  -  [EMAIL PROTECTED]
http://lists.zope.org/mailman/listinfo/zope-dev
**  No cross posts or HTML encoding!  **
(Related lists - 
 http://lists.zope.org/mailman/listinfo/zope-announce
 http://lists.zope.org/mailman/listinfo/zope )




Re: [Zope-dev] Mapping multiple IP addresses/domains to one Zope

2001-01-24 Thread Toby Dickenson

On Wed, 24 Jan 2001 10:07:29 -0600, "Aaron Gillette"
[EMAIL PROTECTED] wrote:

My company has many sites which share some content. Each site uses a
different IP address. I would like to bring all of these sites into one
instance of Zope on an NT machine. I am looking at the possibility of either
1) running Zope behind IIS, or 2) running Zserver exclusively.

Is this server accessible to untrusted users? If yes, then go for IIS.
ZServer on its own isnt sufficiently bullet-proof.

 Personally,
I'd rather take the time in advance to learn how to do the whole thing in
Zope, as I envision switching to a Linux server in the near future, and I
believe that this would ease the migration.

Yes, its safe to copy zope databases between platforms, and zope
itself is very platform-neutral.

My question is this: How do I map different IP addresses/domains to
different Zope folders? I am pretty new to Python (but learning fast!), so
any snippets of sample code would be much obliged.

Search on www.zope.org for SiteAccess. 

Toby Dickenson
[EMAIL PROTECTED]

___
Zope-Dev maillist  -  [EMAIL PROTECTED]
http://lists.zope.org/mailman/listinfo/zope-dev
**  No cross posts or HTML encoding!  **
(Related lists - 
 http://lists.zope.org/mailman/listinfo/zope-announce
 http://lists.zope.org/mailman/listinfo/zope )




Re: [Zope-dev] Mapping multiple IP addresses/domains to one Zope

2001-01-24 Thread Aaron Gillette

Sorry, but I don't think I phrased my original question very well. I'll give
it another try.

What I'm trying to do is have Zope somehow map an IP address to a specific
subfolder within the ZODB. For example, I've got one subfolder that should
serve DOMAIN1.COM which is located at the IP address XXX.XXX.XXX.1, a second
subfolder should serve DOMAIN2.COM which is located at the IP address
XXX.XXX.XXX.2, etc... How can this be accomplished?

If there is a way to do it behind IIS, that'd be great.

SiteAccess could then take care of the conversion of the root domain name (I
think).

I hope I've cleared things up a bit.

Thanks,

Aaron Gillette

- Original Message -
From: "Toby Dickenson" [EMAIL PROTECTED]
To: "Aaron Gillette" [EMAIL PROTECTED]
Cc: [EMAIL PROTECTED]
Sent: Wednesday, January 24, 2001 10:22 AM
Subject: Re: [Zope-dev] Mapping multiple IP addresses/domains to one Zope


On Wed, 24 Jan 2001 10:07:29 -0600, "Aaron Gillette"
[EMAIL PROTECTED] wrote:

My company has many sites which share some content. Each site uses a
different IP address. I would like to bring all of these sites into one
instance of Zope on an NT machine. I am looking at the possibility of
either
1) running Zope behind IIS, or 2) running Zserver exclusively.

Is this server accessible to untrusted users? If yes, then go for IIS.
ZServer on its own isnt sufficiently bullet-proof.

 Personally,
I'd rather take the time in advance to learn how to do the whole thing in
Zope, as I envision switching to a Linux server in the near future, and I
believe that this would ease the migration.

Yes, its safe to copy zope databases between platforms, and zope
itself is very platform-neutral.

My question is this: How do I map different IP addresses/domains to
different Zope folders? I am pretty new to Python (but learning fast!), so
any snippets of sample code would be much obliged.

Search on www.zope.org for SiteAccess.

Toby Dickenson
[EMAIL PROTECTED]


___
Zope-Dev maillist  -  [EMAIL PROTECTED]
http://lists.zope.org/mailman/listinfo/zope-dev
**  No cross posts or HTML encoding!  **
(Related lists - 
 http://lists.zope.org/mailman/listinfo/zope-announce
 http://lists.zope.org/mailman/listinfo/zope )




Re: [Zope-dev] Old to new registerClass

2001-01-24 Thread Johan Carlsson

 Brian Lloyd
 etc. I don't know what 'lang_' does, so I'm not sure what 
 to advise you there...
 

Hi Andy, 
As far as I can see the land_ directory doesn't seam to do anything.
You could try to just remove it.
(It wasn't me that put it there.)

As for the most part of the Images defined in the misc_ structure,
I suppose all of the except the IEMethod.gif (needed outside) 
could be defined in the IEMethod class instead of the module level. 
They are really not so useful outside the scope of the IEMethod object itself.
This should apply to the JavaScript-files and CSS-files as well.
(Well it was me who put those files there, but that was a long time ago ;-)

Regards,
Johan Carlsson

___
Zope-Dev maillist  -  [EMAIL PROTECTED]
http://lists.zope.org/mailman/listinfo/zope-dev
**  No cross posts or HTML encoding!  **
(Related lists - 
 http://lists.zope.org/mailman/listinfo/zope-announce
 http://lists.zope.org/mailman/listinfo/zope )




Re: [Zope-dev] Old to new registerClass

2001-01-24 Thread Andy McKay

Lang is used in this line:

document.write("SCR"+"IPT src=\"misc_/IEMethod/lang_"+lang+"\"
type=\"text/javascript\"/SCR"+"IPT");

Kind of a bizarre line, but it looks like its setting the script source.
Thanks, just doing a quick ZWiki-IEMethod merge so that you can edit a ZWiki
standard style or using IEMethod.

Thanks for the code.

--
  Andy McKay.


- Original Message -
From: "Johan Carlsson" [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: Wednesday, January 24, 2001 8:44 AM
Subject: Re: [Zope-dev] Old to new registerClass


  Brian Lloyd
  etc. I don't know what 'lang_' does, so I'm not sure what
  to advise you there...
 

 Hi Andy,
 As far as I can see the land_ directory doesn't seam to do anything.
 You could try to just remove it.
 (It wasn't me that put it there.)

 As for the most part of the Images defined in the misc_ structure,
 I suppose all of the except the IEMethod.gif (needed outside)
 could be defined in the IEMethod class instead of the module level.
 They are really not so useful outside the scope of the IEMethod object
itself.
 This should apply to the JavaScript-files and CSS-files as well.
 (Well it was me who put those files there, but that was a long time ago
;-)

 Regards,
 Johan Carlsson

 ___
 Zope-Dev maillist  -  [EMAIL PROTECTED]
 http://lists.zope.org/mailman/listinfo/zope-dev
 **  No cross posts or HTML encoding!  **
 (Related lists -
  http://lists.zope.org/mailman/listinfo/zope-announce
  http://lists.zope.org/mailman/listinfo/zope )



___
Zope-Dev maillist  -  [EMAIL PROTECTED]
http://lists.zope.org/mailman/listinfo/zope-dev
**  No cross posts or HTML encoding!  **
(Related lists - 
 http://lists.zope.org/mailman/listinfo/zope-announce
 http://lists.zope.org/mailman/listinfo/zope )




Re: [Zope-dev] Old to new registerClass

2001-01-24 Thread Andy McKay

I nuked it and everything is just fine, its defined in misc. Anyway works
fine, will post a "package" shortly after some testing.
--
  Andy McKay.


- Original Message -
From: "Johan Carlsson" [EMAIL PROTECTED]
To: "Andy McKay" [EMAIL PROTECTED]
Sent: Wednesday, January 24, 2001 9:39 AM
Subject: Re: [Zope-dev] Old to new registerClass


  Lang is used in this line:
 
  document.write("SCR"+"IPT src=\"misc_/IEMethod/lang_"+lang+"\"
  type=\"text/javascript\"/SCR"+"IPT");

 I think that:
 The "lang" Javascript variable is either set to "sv" or "en" so the script
include
 file should look for either "lang_sv" or "lang_en".
 The dictionary lang_ defined in __init__ isn't, as far as I can see, used
anywhere.

 So you don't need to worry about it much.

  Kind of a bizarre line, but it looks like its setting the script source.
  Thanks, just doing a quick ZWiki-IEMethod merge so that you can edit a
ZWiki
  standard style or using IEMethod.

 Great, one less thing for me to do :-)

 Johan



___
Zope-Dev maillist  -  [EMAIL PROTECTED]
http://lists.zope.org/mailman/listinfo/zope-dev
**  No cross posts or HTML encoding!  **
(Related lists - 
 http://lists.zope.org/mailman/listinfo/zope-announce
 http://lists.zope.org/mailman/listinfo/zope )




Re: [Zope-dev] Mapping multiple IP addresses/domains to one Zope

2001-01-24 Thread Michael Bernstein

Aaron Gillette wrote:
 
 My company has many sites which share some content. Each site uses a
 different IP address. I would like to bring all of these sites into one
 instance of Zope on an NT machine. I am looking at the possibility of either

 1) running Zope behind IIS, or 

 2) running Zserver exclusively.

You have a third possibility, which is to run Zope behid
Apache on NT. I would guess that this list has more
experience with Apache rewrite rules than IIS.

This setup should also be fairly easy to migrate to Linux.

Personally, I've found it more convenient to point all my
domains to a single IP address, and let Zope (with help from
SiteAccess) handle the rest. This has been easier, even
though Zope is behind Apache, as Zope Access Rules are
easier to create (IMO) than dealing with name or IP based
virtual hosting under Apache. Those Apache rewrite rules are
horribly cryptic.

HTH,

Michael Bernstein.

___
Zope-Dev maillist  -  [EMAIL PROTECTED]
http://lists.zope.org/mailman/listinfo/zope-dev
**  No cross posts or HTML encoding!  **
(Related lists - 
 http://lists.zope.org/mailman/listinfo/zope-announce
 http://lists.zope.org/mailman/listinfo/zope )




Re: [Zope-dev] Local roles and security of ZClass instances inSpecialists

2001-01-24 Thread Itai Tavor

Hi Steve,

This is a nice idea... but I can't get it to work. it works fine when 
changing properties:

   WHEN OBJECT CHANGED CALL self.checkForPermission(REQUEST)

But is ignored for accessing properties:

   WITH self.checkForPermission(REQUEST) COMPUTE spam='eggs'

simply fails to set spam if checkForPermission raises an exception, 
because ZPatterns catches all exceptions in COMPUTE clauses (I never 
understood the point of this, BTW. It just gets in the way of 
debugging. Wouldn't catching just AttributeError and KeyError be 
enough?) and the exception gets dumped to the console. Which could 
actually be considered to work, because the method doing the access 
will fail... but that would be ugly and definitely not what I want.

Also, I want a solution that would work regardless of the storage 
method - I don't think this one won't work for ZODB storage. In a 
Rack using persistent storage and having a property 'spam', the 
SkinScript clause:

   WITH self COMPUTE spam='eggs'

will be ignored. So the SkinScript can be used to control access only 
if it's already being used to load the properties.

Which all comes down to having to do the security checks in all the 
methods that access the object :-( Unless you can show me something I 
missed?


Steve Spicklemire wrote:

Hi Itai,

I'm sure there's something clever you could do here with
an attribute provider for you user object that supplied
__roles__ dynamically somehow, but I'd need to think
about that more... one easy way to limit who can
see different stuff is to use a wrapper around
your access methods (e.g., SQL queries) that checks for
security:

e.g.,

WITH [ QUERY ] LookupAttributesAndCheckForPermission(REQUEST) 
COMPUTE foo, bar, baz

where LookupAttributesAndCheckForPermission get's everything it needs out of
the REQUEST.

It's a crude tool.. but it's simple. When I get some time to think clearly..
I'll try to come up with something more general. Hopefully you'll also get
some other suggestions...

-steve
  "Itai" == Itai Tavor [EMAIL PROTECTED] writes:

 Itai Hi,

 Itai I'm trying to work out a security strategy for data stored
 Itai in Specialists, where specific users need access to specific
 Itai data instances.

 Itai For example: A Customer object is linked to a Person and
 Itai Address objects. The customer needs permission to edit the
 Itai her - and only her - Address object. Using the Owner local
 Itai role won't work, because customers can be registered by site
 Itai managers and customer support people, in which case Owner
 Itai won't be the customer.

 Itai I can solve this by giving the customer a local role when
 Itai creating her Address object:

 Itai  Customers.addCustomer(REQUEST): ni =
 Itai container.addItem(some_id)
 Itai container.Addresses.addAddressFor(ni.id, REQUEST)

 Itai  Addresses.addAddressFor(for_id, REQUEST): ni =
 Itai container.addItem(some_id) ni.manage_addLocalRole(for_id,
 Itai 'EditMyDetails')

 Itai But this can be a lot of work - If an Address object can
 Itai also be created for a CreditCard object, addCreditCard will
 Itai have to both set its own local role, and pass the customer
 Itai id on to Address...

 Itai But the main problem is that I'm not sure if it will work at
 Itai all - can local roles be set for DataSkins that aren't
 Itai stored in the ZODB?  From what I can see ZPatterns doesn't
 Itai support this, so I'll have to do it
 Itai myself. __ac_local_roles__ can't be accessed in a SkinScript
 Itai - so will I have to override has_local_roles,
 Itai get_local_roles and get_local_roles_for_userid and call them
 Itai from the SkinScript? This is getting hairy...

 Itai Without local roles, all I can think of is explicitly
 Itai checking that the logged in user is the right customer in
 Itai all the methods that display and edit the object, which is
 Itai very ugly. Plus it would require Address to know a
 Itai customer_id even when it actually belongs to a CreditCard,
 Itai not a Customer... there goes Demeter. Or I can add a
 Itai findUserID to Address, CreditCard and Customer, all of which
 Itai pass the request upwards until one is reached that actually
 Itai knows the customer. Still ugly.

 Itai TIA for Any comments/suggestions.

 Itai Itai -- Itai Tavor "Je sautille, donc je suis."  C3Works
 Itai [EMAIL PROTECTED] - Kermit the Frog

 Itai "If you haven't got your health, you haven't got anything"


 Itai ___ Zope-Dev
 Itai maillist - [EMAIL PROTECTED]
 Itai http://lists.zope.org/mailman/listinfo/zope-dev ** No cross
 Itai posts or HTML encoding!  ** (Related lists -
 Itai http://lists.zope.org/mailman/listinfo/zope-announce
 Itai http://lists.zope.org/mailman/listinfo/zope )

-- 
--
Itai Tavor  -- "Je sautille, donc 

[Zope-dev] Possible TransparentFolders bug?

2001-01-24 Thread Itai Tavor

Hi,

The TransparentFolders Product seems to make everything 
transparent... not just transparent folders.

Zope/
 Folder_A/
 method_A
 Folder_B/ (transparent folder)
 method_B

I'd expect the only effect of the transparent folder to be that 
/Folder_A/method_B would work. But /method_A and /method_B also work. 
Tested in Zope 2.3b2 and 2.3b3 with TransparentFolders 0.3.
-- 
--
Itai Tavor  -- "Je sautille, donc je suis."--
[EMAIL PROTECTED]--   - Kermit the Frog --
-- 'Supposing a tree fell down, Pooh, when we were underneath it?' --
-- 'Supposing it didn't,' said Pooh after careful thought. --


___
Zope-Dev maillist  -  [EMAIL PROTECTED]
http://lists.zope.org/mailman/listinfo/zope-dev
**  No cross posts or HTML encoding!  **
(Related lists - 
 http://lists.zope.org/mailman/listinfo/zope-announce
 http://lists.zope.org/mailman/listinfo/zope )