Re: [Zope-dev] when did transaction lose the ability to be usable as a context manager?
Chris Withers wrote: > Hi All, > > I used to do this: > > >>> import transaction > >>> with transaction: > ... print 'hello' > ... > Traceback (most recent call last): >File "", line 1, in > AttributeError: __exit__ > > When did that stop working and what should I now do instead? > > cheers, > > Chris > You can use pure hackery to work around this: - t.py - def __enter__(*args): print 'enter', args def __exit__(*args): print 'exit', args def fixup(): import sys, types self = sys.modules[__name__] mymod = type(__name__, (types.ModuleType,), globals()) sys.modules[__name__] = mymod(__name__) fixup() -- t1.py --- #!python2.7 import t with t: print "transaction" and the output is: C:\Temp>t1.py enter (,) transaction exit (, None, None, None) This is hackery though, and watch out for globals as the globals() dict known to the functions in t.py is no longer the same dict visible to modules that import it so changes to one won't be visible in the other and any functions in the module will behave like methods (so you have to give them a 'self' parameter). Much better just to change the code to define an object and import that from the module. ___ Zope-Dev maillist - Zope-Dev@zope.org https://mail.zope.org/mailman/listinfo/zope-dev ** No cross posts or HTML encoding! ** (Related lists - https://mail.zope.org/mailman/listinfo/zope-announce https://mail.zope.org/mailman/listinfo/zope )
[Zope-dev] Re: Installer for Windows (quick question)
"Sidnei da Silva" <[EMAIL PROTECTED]> wrote: > Since I'm going to be building the installer for Windows I would like > to quickly ask if anyone expects multiple Zope installs to live > side-by-side. The existing installer atempted that but I don't believe > it was very successful. > > I would like to know if anyone has multiple Zope installations on > Windows side-by-side and if they consider that important. > Yes and yes. Same as Martin Aspeli's reasons: testing on multiple plone versions. I think the main thing is to be sure that the installation doesn't add any zope specific folders to PythonPath in the registry. The Plone installation for example adds (or added) some folders to PythonPath which meant that multiple plones using the same major python version would try to share parts of the Plone installation. Not adding folders to the pythonpath registry key allows coexistence, and there are more than enough ways to add folders to pythonpath without using the registry. ___ Zope-Dev maillist - Zope-Dev@zope.org http://mail.zope.org/mailman/listinfo/zope-dev ** No cross posts or HTML encoding! ** (Related lists - http://mail.zope.org/mailman/listinfo/zope-announce http://mail.zope.org/mailman/listinfo/zope )
[Zope-dev] Re: Re: Re: Re: favicon.ico for 2.10?
Chris Withers wrote: > Duncan Booth wrote: >> What may be more significant is that simply retrieving favicon.ico >> into IE displays garbage. I don't know why; IE seems perfectly >> capable of displaying it on the address bar or favourites, but in the >> main browser window it displays a short curved line and nothing else. > > Is the method that's returning it setting the right content type? > I've tried 3 mime types: application/octet_stream: The icon displays correctly in Firefox and incorrectly in IE, other favicon.ico files I've tried with this mime type display correctly in IE. image/x-icon: The same incorrect display in IE and correct display in FF. image/vnd.microsoft.icon: Still displays correctly in FF, but IE decides to dump it as characters instead of displaying a graphic at all. ___ Zope-Dev maillist - Zope-Dev@zope.org http://mail.zope.org/mailman/listinfo/zope-dev ** No cross posts or HTML encoding! ** (Related lists - http://mail.zope.org/mailman/listinfo/zope-announce http://mail.zope.org/mailman/listinfo/zope )
[Zope-dev] Re: Re: Re: favicon.ico for 2.10?
Lennart Regebro wrote: > Anu I have added a favicon.ico to trunk. For some reason it doesn't > show up in the Bookmark list of Firefox. If this is a caching problem, > or something else, I don't know yet. If anybody knows, tell me and > I'll fix it, > > For your viewing pleasure, I attached the big Z gif I used to create > the icons, the GIMP file with transparent and non-transparent versions > in 16x16, 32x32 and 48x48, and the resulting icon. > I checked it on IE and Windows Explorer in all the different sizes I could find and it looks great almost all of the time. Unfortunately in the properties tabs it looks absolutely terrible in IE with a 120dpi display (such as my laptop), but I put that down to IE stupidity. What may be more significant is that simply retrieving favicon.ico into IE displays garbage. I don't know why; IE seems perfectly capable of displaying it on the address bar or favourites, but in the main browser window it displays a short curved line and nothing else. ___ Zope-Dev maillist - Zope-Dev@zope.org http://mail.zope.org/mailman/listinfo/zope-dev ** No cross posts or HTML encoding! ** (Related lists - http://mail.zope.org/mailman/listinfo/zope-announce http://mail.zope.org/mailman/listinfo/zope )
[Zope-dev] Re: Re: favicon.ico for 2.10?
Chris McDonough wrote: > There's a nice little Mac freeware app named IcoMaker for > creating .ico files from GIF files. .ico files are actually > containers for various icon sizes and color depths and this app > allows you to create an .ico file out of up to six sizes/depths. I > stole the favico from zope.org and made one using IcoMaker with a > single size/depth (16x16/16colors). It's attached. I haven't tried > it in IE. If it doesn't work for whatever reason, maybe someone else > who has more icon-foo can do a more thorough job. > That one works, at least in those cases where IE is displaying the icon at 16x16. Some higher resolution images in the file would be useful though for situations where it decides to display larger icons, otherwise it looks pretty blocky. So far I've found at least 4 different icon sizes used in IE and one outside. From smallest to largest: address bar and favourites toolbar are smallest (1), the links toolbar uses a larger icon (2), favourite properties has the icon on two tabs in different sizes 'web document' (3) and 'General' (4). And of course IE's favourites are actually just a folder, so you need a suitable icon for Explorer's icon view (5). I haven't measured these, but I would guess the sizes I saw were 16, 24, 32, 48, and 64 pixels. There's an icon maker at http://favicon.ru/en/ which will do 16,32 and 48 pixel images online, but I don't have a decent starting image. ___ Zope-Dev maillist - Zope-Dev@zope.org http://mail.zope.org/mailman/listinfo/zope-dev ** No cross posts or HTML encoding! ** (Related lists - http://mail.zope.org/mailman/listinfo/zope-announce http://mail.zope.org/mailman/listinfo/zope )
[Zope-dev] Re: favicon.ico for 2.10?
Florent Guillaume wrote: > kit BLAKE wrote: >> 2006/4/24, Jens Vagelpohl <[EMAIL PROTECTED]>: >>> Yeah, that's nice. Does it work as a PNG, though? I was under the >>> impression (and thought the spec requires) that favicons must be >>> *.ico files. >> >> A PNG favicon will work in the Mozilla family, but not in IE. >> kit > > However I'd be surprised if a .gif didn't work. > So far as I can tell, neither .png nor .gif work for favicon.ico in IE. It will display a gif/png named favicon.ico in the browser, but it won't use it as an icon on the address bar/favourites. ___ Zope-Dev maillist - Zope-Dev@zope.org http://mail.zope.org/mailman/listinfo/zope-dev ** No cross posts or HTML encoding! ** (Related lists - http://mail.zope.org/mailman/listinfo/zope-announce http://mail.zope.org/mailman/listinfo/zope )
Re: [Zope-dev] ZEO question.
> > There is a second line to mess with, something about os.ppid I think. > We should really have these changes made to the source > Yes, you have to change line 310: open(zeo_pid,'w').write("%s %s" % (os.getppid(), os.getpid())) to: open(zeo_pid,'w').write("%s" % (os.getpid())) I have posted a report on the ZEO Tracker for both these changes. -- Duncan Booth [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 )
[Zope-dev] ZEO question.
> And now onto the reason I was looking for that list: > > -WinNT 4.0 > -Zope 2.3.1b1 > -ZEO 0.4.1 > > E:\Zope\2.3.1b1>python lib/python/ZEO/start.py -p 8000 > Traceback (innermost last): > File "lib/python/ZEO/start.py", line 315, in ? > if __name__=='__main__': main(sys.argv) > File "lib/python/ZEO/start.py", line 297, in main > signal.signal(signal.SIGHUP, handler) > AttributeError: SIGHUP > > What does that mean and how can I fix it? It means that ZEO isn't compatible with NT. simply comment out line 297 of start.py and it should be fine. > > Finally, how can I get the storage server to use the Data.fs from my > INSTANCE_HOME rather than the SOFTWARE_HOME, which I presume the above > does? I think the default is to use INSTANCE_HOME/var/Data.fs so you should be happy. BTW, I have managed to get ZEO running as an NT service complete with Core Session in a mounted BerkeleyDB 3.2 storage. -- Duncan Booth [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] manage_main don't work with Mozilla
On 15 Mar 2001, you wrote in local.zope.dev: > >Matt wrote: >> should have a corresponding right? In which case >>>it should not have a trailing slash. They are only needed for single >>tags that have no corresponding close, eg etc. > > I agree but in the management interface of Zope it's not the case. > You >have Some stuff... and you should have > stuff . That's the reason why it doesn't work anymore >Mozilla. It just seems to be one place in zope's code. OFS/dtml/main.dtml, line 43 needs the spurious slash removing. ___ 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] BerkeleyStorage with BerkeleyDB 3.2
I wanted to get BerkeleyStorage installed on my Windows system. Since there is a nice downloadable binary version of the Python bindings for version 3.2, I downloaded and installed that, then modified BerkeleyStorage.py to support the new interface instead of the old one. If anyone wants a copy, see http://www.zope.org/Members/Duncan/BerkeleyStorage -- Duncan Booth [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] dtml-var tag suggestion
> I have been using dtml to create dynamic JavaScripts for some forms I am > creating. In doing this I came upon the standard problem of inserting > strings containing double quotes into a JavaScript such as where title = > '"Quoted String"': > > form.select.options[0].text = ""; > > And you wind up with this rendered: > > form.select.options[0].text = ""Quoted String""; > Given that, like Python, javascript accepts strings either single or double quoted, you could try using backquotes to escape the string: form.select.options[0].text = ; should (untested) give you: form.select.options[0].text = '"Quoted String"'; Provided title is a string, this will escape any quotes and, for that matter, unprintable characters, and wrap either single or double quotes round the outside. If title is a method then you need to call it first: -- Duncan Booth [EMAIL PROTECTED] int month(char *p){return(124864/((p[0]+p[1]-p[2]&0x1f)+1)%12)["\5\x8\3" "\6\7\xb\1\x9\xa\2\0\4"];} // Who said my code was obscure? http://dales.rmplc.co.uk/Duncan ___ 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] Repeating a piece of HTML code
> > > > > > > > > > Replace movie_rating with the variable that represents the movie rating. > > What about ? > Fine, except that he wants the tag repeated the appropriate number of times. Try putting the tag into the dtml-var statement and you get something along the lines of (untested): ' % (_.chr(34), _.chr(34))) * movie_rating"> at which point the dtml-in starts to look more appealing. Of course if you rename star.gif as star_gif you could try: which has a certain neatness. -- Duncan Booth [EMAIL PROTECTED] int month(char *p){return(124864/((p[0]+p[1]-p[2]&0x1f)+1)%12)["\5\x8\3" "\6\7\xb\1\x9\xa\2\0\4"];} // Who said my code was obscure? http://dales.rmplc.co.uk/Duncan ___ 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] Recursion
> There would seem to be two ways to 'fix' this, I'll leave it as an exercise > for the reader to discuss which is best. > > Option 1: > def foo(self,counter=None): > some code > if bar == somewhat: > self.foo(counter=some_int) Option 1 has a problem. If you give it a different name in dtml, e.g. bar and call it: then self is a reference to the folder and self.foo doesn't exist. If there is a different method 'foo' in the folder that other method will be called instead. > > Option 2: > def foo(self,counter=None): > some code > if bar == somewhat: > foo(self,counter=some_int) > This one should work as advertised. (Unless you redefine foo in the python module in which case you get what you deserve). -- Duncan Booth [EMAIL PROTECTED] int month(char *p){return(124864/((p[0]+p[1]-p[2]&0x1f)+1)%12)["\5\x8\3" "\6\7\xb\1\x9\xa\2\0\4"];} // Who said my code was obscure? http://dales.rmplc.co.uk/Duncan ___ 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] Create an empty DTML Method
> I want to write some dtml code that will add a DTML method that is > totally empty. The add_DTMLMethod method in Zope puts in the default > Zope content. How do I avoid that? > Try: manage_addDTMLMethod(id='test1', title='This is a test', file='') The file parameter can be a file like object or a string. -- Duncan Booth [EMAIL PROTECTED] int month(char *p){return(124864/((p[0]+p[1]-p[2]&0x1f)+1)%12)["\5\x8\3" "\6\7\xb\1\x9\xa\2\0\4"];} // Who said my code was obscure? http://dales.rmplc.co.uk/Duncan ___ 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] Zope 2.2.0a1 problem in select_trigger
I just installed 2.2.0alpha1 onto an NT machine that already had two copies of Zope running happily on it. The new copy of Zope refuses to start with the following traceback: Traceback (innermost last): File "", line 1, in ? File "z2.py", line 524, in ? import ZServer File "D:\zope2\ZServer\__init__.py", line 123, in ? from HTTPServer import zhttp_server, zhttp_handler File "D:\zope2\ZServer\HTTPServer.py", line 116, in ? from HTTPResponse import make_response File "D:\zope2\ZServer\HTTPResponse.py", line 97, in ? from PubCore.ZEvent import Wakeup File "D:\zope2\ZServer\PubCore\ZEvent.py", line 91, in ? Wakeup=trigger().pull_trigger File "D:\zope2\ZServer\medusa\select_trigger.py", line 103, in __init__ a.bind (self.address) File "", line 1, in bind socket.error: (10048, 'winsock error') I ran it under pdb and it is trying to bind a socket to 127.9.9.9, port 1. Zope 2.1.6 had this code inside a loop so that if the bind failed it subtracted 1 from the port number and then tried again until it found a free port (or gave up after trying 50), but the loop has been removed in the new release. (copied to the Collector) -- Duncan Booth [EMAIL PROTECTED] int month(char *p){return(124864/((p[0]+p[1]-p[2]&0x1f)+1)%12)["\5\x8\3" "\6\7\xb\1\x9\xa\2\0\4"];} // Who said my code was obscure? http://dales.rmplc.co.uk/Duncan ___ 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] Slow startup times
> A number of times the subject of slow startup times has been raised, > because it's particularly annoying while developing python products. > I've always found it very snappy (restart in less than 4 seconds), but > yesterday I found a machine where it was much slower (20 seconds). > > With the patch below, all my machines can now restart Zope in under 3 > seconds ;-) It now takes my zope on localhost about 5 seconds to restart, but that is much better than the 36 seconds it took before. Thank you very much for this patch. -- Duncan Booth [EMAIL PROTECTED] int month(char *p){return(124864/((p[0]+p[1]-p[2]&0x1f)+1)%12)["\5\x8\3" "\6\7\xb\1\x9\xa\2\0\4"];} // Who said my code was obscure? http://dales.rmplc.co.uk/Duncan ___ 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] Slow startup times
> A number of times the subject of slow startup times has been raised, > because it's particularly annoying while developing python products. > I've always found it very snappy (restart in less than 4 seconds), but > yesterday I found a machine where it was much slower (20 seconds). > > With the patch below, all my machines can now restart Zope in under 3 > seconds ;-) It now takes my zope on localhost about 5 seconds to restart, but that is much better than the 36 seconds it took before. Thank you very much for this patch. -- Duncan Booth [EMAIL PROTECTED] int month(char *p){return(124864/((p[0]+p[1]-p[2]&0x1f)+1)%12)["\5\x8\3" "\6\7\xb\1\x9\xa\2\0\4"];} // Who said my code was obscure? http://dales.rmplc.co.uk/Duncan ___ 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] Methods through the Web (security?)
> While I'm at it, is there any way to make DTML methods accessible to > objects (such as other DTML methods) but not through URLs other than by a > tortuous series of proxy roles? I've expressed views about an 'execute' > permission in the past but these have fallen on deaf ears. > You could probably do something useful using siteaccess if you strictly enforced a naming convention across your site. I have wondered about lower casing all incoming URLs so as to make them effectively case independant and this would have a side effect of making all mixed/upper case objects inaccessble. Or you might have a convention that everything web callable had an extension and prevent access to any methods without a dot in the id. Of course siteaccess can be bypassed, but it should be possible to disable this. -- Duncan Booth [EMAIL PROTECTED] int month(char *p){return(124864/((p[0]+p[1]-p[2]&0x1f)+1)%12)["\5\x8\3" "\6\7\xb\1\x9\xa\2\0\4"];} // Who said my code was obscure? http://dales.rmplc.co.uk/Duncan ___ 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 )