From tree at basistech.com Sat Oct 19 07:58:45 2002 From: tree at basistech.com (Tom Emerson) Date: Fri, 18 Oct 2002 17:58:45 -0400 Subject: [albatross-users] Albatross 1.0 manual, US Letter Message-ID: <15792.33813.435759.75049@magrathea.basistech.com> Like some others on the list, I have not been able to print the PDF version of the (excellent) Albatross manual on the Object Craft website. I recall reading someone say it is a problem with pdflatex. Since I really want a hard copy of this, I generated my own PDF by first generating a PostScript version of the manual directly using mkhowto, sized to US Letter. Then I converted it to PDF using Acrobat Distiller 5. I was able to print this just fine on my Windows XP Pro box, and I can read it without a hitch in Reader 5 on my FreeBSD machine. You can find my PDF at http://cymru.basistech.com/~tree/albatross-usletter.pdf Share and enjoy. Ni! -tree -- Tom Emerson Basis Technology Corp. Software Architect http://www.basistech.com "Beware the lollipop of mediocrity: lick it once and you suck forever" From tchur at optushome.com.au Sat Oct 19 12:21:52 2002 From: tchur at optushome.com.au (Tim Churches) Date: Sat, 19 Oct 2002 12:21:52 +1000 Subject: [albatross-users] Albatross 1.0 manual, US Letter References: <15792.33813.435759.75049@magrathea.basistech.com> Message-ID: <3DB0C1C0.728E8BEB@optushome.com.au> Tom Emerson wrote: > > Like some others on the list, I have not been able to print the PDF > version of the (excellent) Albatross manual on the Object Craft > website. I recall reading someone say it is a problem with pdflatex. Yes, the problem is that the PostScript emitted by pdflatex produces a PDF which crashes Acrobat 5 (but not earlier versions) when GhostScript is used to create the PDF. > > Since I really want a hard copy of this, I generated my own PDF by > first generating a PostScript version of the manual directly using > mkhowto, sized to US Letter. Then I converted it to PDF using Acrobat > Distiller 5. I was able to print this just fine on my Windows XP Pro > box, and I can read it without a hitch in Reader 5 on my FreeBSD machine. The OC guys sent me a Postscript version of the manual and I was also able to create an A4 version with Acrobat Distiller 5 which then printed without crashing. Tim C > > You can find my PDF at > > http://cymru.basistech.com/~tree/albatross-usletter.pdf > > Share and enjoy. Ni! > > -tree > > -- > Tom Emerson Basis Technology Corp. > Software Architect http://www.basistech.com > "Beware the lollipop of mediocrity: lick it once and you suck forever" > _______________________________________________ > Albatross-users mailing list > Albatross-users at object-craft.com.au > https://www.object-craft.com.au/cgi-bin/mailman/listinfo/albatross-users From brian at runeblade.com Sun Oct 20 01:56:20 2002 From: brian at runeblade.com (Brian Brown) Date: Sat, 19 Oct 2002 09:56:20 -0600 Subject: [albatross-users] Albatross 1.0 manual, US Letter In-Reply-To: <3DB0C1C0.728E8BEB@optushome.com.au> Message-ID: <4F5E2366-E37B-11D6-A8F7-003065F89450@runeblade.com> Strange... I had no problems with the pdfs on my MacOSX box using acrobat 5... printed great. When I tried to build the manual from sources, though, my latex distro was missing one of the .sty files that was used to make the manual.. Brian On Friday, October 18, 2002, at 08:21 PM, Tim Churches wrote: > Tom Emerson wrote: >> >> Like some others on the list, I have not been able to print the PDF >> version of the (excellent) Albatross manual on the Object Craft >> website. I recall reading someone say it is a problem with pdflatex. > > Yes, the problem is that the PostScript emitted by pdflatex produces > a PDF which crashes Acrobat 5 (but not earlier versions) when > GhostScript > is used to create the PDF. > >> >> Since I really want a hard copy of this, I generated my own PDF by >> first generating a PostScript version of the manual directly using >> mkhowto, sized to US Letter. Then I converted it to PDF using Acrobat >> Distiller 5. I was able to print this just fine on my Windows XP Pro >> box, and I can read it without a hitch in Reader 5 on my FreeBSD >> machine. > > The OC guys sent me a Postscript version of the manual and I was also > able to create an A4 version with Acrobat Distiller 5 which then printed > without crashing. > > Tim C > >> >> You can find my PDF at >> >> http://cymru.basistech.com/~tree/albatross-usletter.pdf >> >> Share and enjoy. Ni! >> >> -tree >> >> -- >> Tom Emerson Basis Technology >> Corp. >> Software Architect >> http://www.basistech.com >> "Beware the lollipop of mediocrity: lick it once and you suck >> forever" >> _______________________________________________ >> Albatross-users mailing list >> Albatross-users at object-craft.com.au >> https://www.object-craft.com.au/cgi- >> bin/mailman/listinfo/albatross-users > _______________________________________________ > Albatross-users mailing list > Albatross-users at object-craft.com.au > https://www.object-craft.com.au/cgi-bin/mailman/listinfo/albatross-users From rbb at techgame.net Wed Oct 23 02:17:16 2002 From: rbb at techgame.net (Brian Brown) Date: Tue, 22 Oct 2002 10:17:16 -0600 Subject: [albatross-users] context locals question In-Reply-To: <3DB0C1C0.728E8BEB@optushome.com.au> Message-ID: Albatrossians, Let me first say that I absolutely love this toolkit... after hanging on with Zope for years, and seeing it get more and more complex and unmanageable, this is just what the doctor ordered. Anyway... I am using a couple of variables that I am putting into ctx.locals, each one is a dictionary that I use for menu structures on the web site. One is a menu that stays the same and one is a menu that I want to be context dependent. The problem seems to be that if I don't explicitly set this dict in every page module, it goes reverts back to the empty dict that I first initialized. What I have tried to do is create a get and set method at the context level, but this doesn't always seem to work. Is there some other place I should be trying to keep track of a value like this context dependent menu? Thanks! Brian From mxr at itga.com.au Wed Oct 23 08:31:56 2002 From: mxr at itga.com.au (Michael Rembach) Date: Wed, 23 Oct 2002 08:31:56 +1000 Subject: [albatross-users] This example is broken Message-ID: <3DB5D1DC.2182166E@itga.com.au> http://www.object-craft.com.au/cgi-bin/alsamp/random/random.py/tree Template traceback (most recent call last): Traceback (most recent call last): File "/usr/lib/python2.2/site-packages/albatross/app.py", line 148, in run self.save_session(ctx) File "/usr/lib/python2.2/site-packages/albatross/app.py", line 207, in save_session ctx.save_session() File "/usr/lib/python2.2/site-packages/albatross/session.py", line 69, in save_session text = self.encode_session() File "/usr/lib/python2.2/site-packages/albatross/context.py", line 510, in encode_session cPickle.dumps(value, 1) PicklingError: Can't pickle tree.Node: it's not the same object as tree.Node -- Michael Rembach From andrewm at object-craft.com.au Thu Oct 24 11:11:32 2002 From: andrewm at object-craft.com.au (Andrew McNamara) Date: Thu, 24 Oct 2002 11:11:32 +1000 Subject: [albatross-users] context locals question In-Reply-To: Message from Brian Brown of "Tue, 22 Oct 2002 10:17:16 CST." References: Message-ID: <20021024011132.E22A83C065@coffee.object-craft.com.au> > Let me first say that I absolutely love this toolkit... after hanging >on with Zope for years, and seeing it get more and more complex and >unmanageable, this is just what the doctor ordered. > >Anyway... I am using a couple of variables that I am putting into >ctx.locals, each one is a dictionary that I use for menu structures on >the web site. One is a menu that stays the same and one is a menu that I >want to be context dependent. The problem seems to be that if I don't >explicitly set this dict in every page module, it goes reverts back to >the empty dict that I first initialized. What I have tried to do is >create a get and set method at the context level, but this doesn't >always seem to work. Is there some other place I should be trying to >keep track of a value like this context dependent menu? Are you calling ctx.add_session_vars( ... ) for the variables in question? Which context mixin are you using? -- Andrew McNamara, Senior Developer, Object Craft http://www.object-craft.com.au/ From djc at object-craft.com.au Thu Oct 24 12:54:51 2002 From: djc at object-craft.com.au (Dave Cole) Date: 24 Oct 2002 12:54:51 +1000 Subject: [albatross-users] This example is broken In-Reply-To: <3DB5D1DC.2182166E@itga.com.au> References: <3DB5D1DC.2182166E@itga.com.au> Message-ID: > http://www.object-craft.com.au/cgi-bin/alsamp/random/random.py/tree > Template traceback (most recent call last): > > Traceback (most recent call last): > File "/usr/lib/python2.2/site-packages/albatross/app.py", line 148, in > run > self.save_session(ctx) > File "/usr/lib/python2.2/site-packages/albatross/app.py", line 207, in > save_session > ctx.save_session() > File "/usr/lib/python2.2/site-packages/albatross/session.py", line 69, > in save_session > text = self.encode_session() > File "/usr/lib/python2.2/site-packages/albatross/context.py", line > 510, in encode_session > cPickle.dumps(value, 1) > PicklingError: Can't pickle tree.Node: it's not the same object as > tree.Node It seems that there have been some big changes with extra checks in the cPickle module between Python 2.1 and 2.2... Now all of a sudden the pickler is trying to import the module that a class belongs to. I suspect that the code is getting confused by our use of imp.find_module(name, [dirname]) to import the module which contains the definition of the Node class. I need to do some more experiments. - Dave diff -u Python-2.1/Modules/cPickle.c Python-2.2/Modules/cPickle.c [snip] static int save_global(Picklerobject *self, PyObject *args, PyObject *name) { - PyObject *global_name = 0, *module = 0; + PyObject *global_name = 0, *module = 0, *mod = 0, *moddict = 0, *klass = 0; char *name_str, *module_str; int module_size, name_size, res = -1; @@ -1648,6 +1698,29 @@ module_str = PyString_AS_STRING((PyStringObject *)module); name_str = PyString_AS_STRING((PyStringObject *)global_name); + mod = PyImport_ImportModule(module_str); + if (mod == NULL) { + /* Py_ErrClear(); ?? */ + cPickle_ErrFormat(PicklingError, + "Can't pickle %s: it's not found as %s.%s", + "OSS", args, module, global_name); + goto finally; + } + moddict = PyModule_GetDict(mod); /* borrowed ref */ + klass = PyDict_GetItemString(moddict, name_str); /* borrowed ref */ + if (klass == NULL) { + cPickle_ErrFormat(PicklingError, + "Can't pickle %s: it's not found as %s.%s", + "OSS", args, module, global_name); + goto finally; + } + if (klass != args) { + cPickle_ErrFormat(PicklingError, + "Can't pickle %s: it's not the same object as %s.%s", + "OSS", args, module, global_name); + goto finally; + } + if ((*self->write_func)(self, &global, 1) < 0) goto finally; -- http://www.object-craft.com.au From rbb at techgame.net Thu Oct 24 13:59:20 2002 From: rbb at techgame.net (Brian Brown) Date: Wed, 23 Oct 2002 21:59:20 -0600 Subject: [albatross-users] context locals question In-Reply-To: <20021024011132.E22A83C065@coffee.object-craft.com.au> References: <20021024011132.E22A83C065@coffee.object-craft.com.au> Message-ID: <1035431960.3db77018c24cf@www.teuton.org> Quoting Andrew McNamara : > > Let me first say that I absolutely love this toolkit... after hanging > >on with Zope for years, and seeing it get more and more complex and > >unmanageable, this is just what the doctor ordered. > > > >Anyway... I am using a couple of variables that I am putting into > >ctx.locals, each one is a dictionary that I use for menu structures on > >the web site. One is a menu that stays the same and one is a menu that I > >want to be context dependent. The problem seems to be that if I don't > >explicitly set this dict in every page module, it goes reverts back to > >the empty dict that I first initialized. What I have tried to do is > >create a get and set method at the context level, but this doesn't > >always seem to work. Is there some other place I should be trying to > >keep track of a value like this context dependent menu? > > Are you calling ctx.add_session_vars( ... ) for the variables in question? No, I was not...but I tried that late last night and it works wonderfully. > > Which context mixin are you using? > SessionAppContext Thanks! > -- > Andrew McNamara, Senior Developer, Object Craft > http://www.object-craft.com.au/ > -- Brian Brown TechGame Networks, LLC. Technology is a Game; Shouldn't you be winning? From djc at object-craft.com.au Thu Oct 24 15:56:55 2002 From: djc at object-craft.com.au (Dave Cole) Date: 24 Oct 2002 15:56:55 +1000 Subject: [albatross-users] This example is broken In-Reply-To: References: <3DB5D1DC.2182166E@itga.com.au> Message-ID: >>>>> "Dave" == Dave Cole writes: Dave> It seems that there have been some big changes with extra checks Dave> in the cPickle module between Python 2.1 and 2.2... Dave> Now all of a sudden the pickler is trying to import the module Dave> that a class belongs to. I suspect that the code is getting Dave> confused by our use of imp.find_module(name, [dirname]) to Dave> import the module which contains the definition of the Node Dave> class. Dave> I need to do some more experiments. I found the sequence of code which causes the problem: >>> import cPickle, copy >>> o = copy._EmptyClass() >>> reload(copy) >>> cPickle.dumps(o, 1) The funny thing is that it only fails for binary pickles. The exception is caused by code which was added for 2.2 and is still in 2.3. - Dave -- http://www.object-craft.com.au From mxr at itga.com.au Fri Oct 25 10:27:51 2002 From: mxr at itga.com.au (Michael Rembach) Date: Fri, 25 Oct 2002 10:27:51 +1000 Subject: [albatross-users] Dynamic question Message-ID: <3DB89007.F450C8F6@itga.com.au> Hi all, I have a question. My question is: Can you dynamically set the name of a macro ? Say I have a boilerplate template like so Application - <al-usearg name='title'>





If I wanted the "whatever" to be different depending on a value in my Python program, is that possible ? -- Michael Rembach "I remembered you on trains, so now you're on every train I hear" - Something For Kate From djc at object-craft.com.au Mon Oct 28 12:48:39 2002 From: djc at object-craft.com.au (Dave Cole) Date: 28 Oct 2002 12:48:39 +1100 Subject: [albatross-users] Albatross 1.01 released In-Reply-To: References: Message-ID: OVERVIEW Albatross is a small toolkit for developing highly stateful web applications. The toolkit has been designed to take a lot of the pain out of constructing intranet applications although you can also use Albatross for deploying publicly accessed web applications. In slightly more than 2600 lines of Python (according to pycount) you get the following: * An extensible HTML templating system similar to DTML including tags for: - Conditional processing. - Macro definition and expansion. - Sequence iteration and pagination. - Tree browsing. - Lookup tables to translate Python values to arbitrary template text. * Application classes which offer the following features: - Optional server side or browser side sessions. - The ability to place Python code for each page in a dynamically loaded module, or to place all page processing code in a single mainline. * The ability to deploy applications either as CGI or via mod_python by changing less than 10 lines of code. The toolkit application functionality is defined by a collection of fine grained mixin classes. Nine different application types and five different execution contexts are prepackaged, you are able to define your own drop in replacements for any of the mixins to alter any aspect of the toolkit semantics. Application deployment is controlled by your choice of either cgi or mod_python Request class. It should be possible to develop a Request class for FastCGI or Medusa to allow applications to be deployed on those platforms with minimal changes. Albatross comes with over 130 pages of documentation. HTML, PDF and PostScript formatted documentation is available from the toolkit homepage. The toolkit homepage: http://www.object-craft.com.au/projects/albatross/ The Albatross mailing list subscription and archives: http://object-craft.com.au/cgi-bin/mailman/listinfo/albatross-users INCOMPATIBLE CHANGES * Prevent variables starting with an underscore from being merged into the context local namespace from request objects. This prevents attackers spoofing variables such as __page__, and any user variables such as authentication data. * Updated documentation to explain underscore prefixed names in execution context are protected from browser modification. BUGS FIXED * Applied bugfix from Detlef Lannert - null attributes would raise a TypeError (for example: ). Once fixed, this exposed another bug where an attribute with a null value would lose it's value altogether (XHTML requires attributes to have a value, null or otherwise). * Exception text is now escaped before being sent to browser. * The PageModuleMixin does not reload a page module if was previously loaded by unpickling the session. This is to avoid a problem with new code in the Python 2.2 pickle/cPickle module which causes the following to fail. import pickle, copy o = copy._EmptyClass() reload(copy) pickle.dumps(o, 1) * Pickling errors are now trapped by looking for the PickleError exception. * Bug prevented nameexpr from being used in and . * Radio input was converting "value_attr" to str(), but not "value", which was causing the "checked" test to fail if value was anything but a string. Also changed checkbox input to convert both to strings before doing the comparison. -- http://www.object-craft.com.au -- http://www.object-craft.com.au From gnb at itga.com.au Tue Oct 29 11:07:47 2002 From: gnb at itga.com.au (Gregory Bond) Date: Tue, 29 Oct 2002 11:07:47 +1100 Subject: [albatross-users] Albatross 1.01 released In-Reply-To: Your message of 28 Oct 2002 12:48:39 +1100. Message-ID: <200210290007.LAA29579@lightning.itga.com.au> The FreeBSD port of Albatross has been updated to v1.01. From neel at mediapulse.com Tue Oct 29 14:27:21 2002 From: neel at mediapulse.com (Michael Neel) Date: Mon, 28 Oct 2002 22:27:21 -0500 Subject: [albatross-users] Form state problem In-Reply-To: Message-ID: <000001c27efb$1788af40$0400a8c0@clapton> Hi all, The following albatross template code is giving me some trouble and I can't see why: Enable Custom Form
Displayed Field Name Ordering
All the fields are set in the session and set to None or as an empty list. The problem is if I check the first checkbox (One) the value of order[0] becomes "yes". I've had this same code work on a one page form, but now has trouble when it one form of many in a sequence. I'm not doing anything to the values (yet), just trying to make sure the state gets set on all fields before going on. Any clues would be greatly appreciated. Thanks, Mike From gnb at itga.com.au Tue Oct 29 14:54:24 2002 From: gnb at itga.com.au (Gregory Bond) Date: Tue, 29 Oct 2002 14:54:24 +1100 Subject: [albatross-users] Form state problem In-Reply-To: Your message of Mon, 28 Oct 2002 22:27:21 -0500. Message-ID: <200210290354.OAA29280@lightning.itga.com.au> The only thing that looks odd to me is: > > value="Step 6 ->"> 2 input buttons with the same name ("submit"), which will be confusing.... this might cause the navigation to be going not where you expect which might explain why it works as a 1-pager but not a more complex form. From neel at mediapulse.com Wed Oct 30 02:33:39 2002 From: neel at mediapulse.com (Michael C. Neel) Date: Tue, 29 Oct 2002 10:33:39 -0500 Subject: [albatross-users] Form state problem Message-ID: No, this is okay, I've done it for a long time on a lot of projects. The only "submit" that is sent is the button clicked. You can check this out by setting the method to get and looking at the URL string. I've played around more with the original problem, and still can't see anything wrong in the template, so I guess it's time to walk though the albatross code and see how nameexpr is handled. Mike -----Original Message----- From: Gregory Bond [mailto:gnb at itga.com.au] Sent: Monday, October 28, 2002 10:54 PM To: Michael C. Neel Cc: albatross-users at object-craft.com.au Subject: Re: [albatross-users] Form state problem The only thing that looks odd to me is: > > value="Step 6 ->"> 2 input buttons with the same name ("submit"), which will be confusing.... this might cause the navigation to be going not where you expect which might explain why it works as a 1-pager but not a more complex form. From djc at object-craft.com.au Wed Oct 30 10:27:45 2002 From: djc at object-craft.com.au (Dave Cole) Date: 30 Oct 2002 10:27:45 +1100 Subject: [albatross-users] Form state problem In-Reply-To: <000001c27efb$1788af40$0400a8c0@clapton> References: <000001c27efb$1788af40$0400a8c0@clapton> Message-ID: > Hi all, The following albatross template code is giving me some > trouble and I can't see why: > > > Enable > Custom Form > > > > > > > > > > > > > > > > > > >
DisplayedField NameOrdering
> expr="r.value()[0]">
value="Step 6 ->">
>
> > All the fields are set in the session and set to None or as an > empty list. The problem is if I check the first checkbox (One) the > value of order[0] becomes "yes". I've had this same code work on a > one page form, but now has trouble when it one form of many in a > sequence. I'm not doing anything to the values (yet), just trying > to make sure the state gets set on all fields before going on. Any > clues would be greatly appreciated. Are you doing something like this in your code: ctx.locals.chkbox = ctx.locals.order = [] ctx.add_session_vars('chkbox', 'order') That is the thing I can think would lead to the problem you are seeing. If chkbox and order refer to the same list then setting one will also set the other. You should be initialising like this ctx.locals.chkbox = [] ctx.locals.order = [] ctx.add_session_vars('chkbox', 'order') - Dave -- http://www.object-craft.com.au From djc at object-craft.com.au Wed Oct 30 10:34:13 2002 From: djc at object-craft.com.au (Dave Cole) Date: 30 Oct 2002 10:34:13 +1100 Subject: [albatross-users] Dynamic question In-Reply-To: <3DB89007.F450C8F6@itga.com.au> References: <3DB89007.F450C8F6@itga.com.au> Message-ID: > Hi all, > I have a question. > > My question is: > Can you dynamically set the name of a macro ? > > Say I have a boilerplate template like so > > > > > > Application - <al-usearg name='title'> > > title="/newweb.css"> > > >

> > >
> >
> > > >

> > > > If I wanted the "whatever" to be different depending on a value in > my Python program, is that possible ? Yes and no. You can't be fully dynamic but you can get close. Then have a lookup table which looks like this: To use this in your code you would just set ctx.locals.expand_this to either 'this or 'that'. - Dave -- http://www.object-craft.com.au From djc at object-craft.com.au Wed Oct 30 10:36:29 2002 From: djc at object-craft.com.au (Dave Cole) Date: 30 Oct 2002 10:36:29 +1100 Subject: [albatross-users] Dynamic question In-Reply-To: References: <3DB89007.F450C8F6@itga.com.au> Message-ID: > > If I wanted the "whatever" to be different depending on a value in > > my Python program, is that possible ? > > Yes and no. You can't be fully dynamic but you can get close. > > > > Then have a lookup table which looks like this: > > > > > > > > > > > To use this in your code you would just set ctx.locals.expand_this to > either 'this or 'that'. Oops - slight problem in the lookup... The expr attribute in must be a literal string. - Dave -- http://www.object-craft.com.au From mxr at itga.com.au Wed Oct 30 10:43:50 2002 From: mxr at itga.com.au (Michael Rembach) Date: Wed, 30 Oct 2002 10:43:50 +1100 Subject: [albatross-users] Dynamic question References: <3DB89007.F450C8F6@itga.com.au> Message-ID: <3DBF1D36.62738944@itga.com.au> Dave, Thanks for this solution. I have found another way to do this, but it requires templating. I use and expression to include the macro file and all of my form macros have the same name ie form. So by resolving the include will bring up different form. Loving the program at the moment, may even have a prototype up by days end. Thanks -- Michael Rembach ITG Australia From neel at mediapulse.com Wed Oct 30 10:44:40 2002 From: neel at mediapulse.com (Michael C. Neel) Date: Tue, 29 Oct 2002 18:44:40 -0500 Subject: [albatross-users] Form state problem Message-ID: Ah, young grasshopper is schooled... Yes, that's exactly what I did, even though Learning Python p.64 warns of this. Everything works fine now. Thanks, Mike -----Original Message----- From: Dave Cole [mailto:djc at object-craft.com.au] Sent: Tuesday, October 29, 2002 6:28 PM To: Michael C. Neel Cc: albatross-users at object-craft.com.au Subject: Re: [albatross-users] Form state problem > Hi all, The following albatross template code is giving me some > trouble and I can't see why: > > > Enable > Custom Form > > > > > > > > > > > > > > > > > > >
DisplayedField NameOrdering
> expr="r.value()[0]">
value="Step 6 ->">
>
> > All the fields are set in the session and set to None or as an > empty list. The problem is if I check the first checkbox (One) the > value of order[0] becomes "yes". I've had this same code work on a > one page form, but now has trouble when it one form of many in a > sequence. I'm not doing anything to the values (yet), just trying > to make sure the state gets set on all fields before going on. Any > clues would be greatly appreciated. Are you doing something like this in your code: ctx.locals.chkbox = ctx.locals.order = [] ctx.add_session_vars('chkbox', 'order') That is the thing I can think would lead to the problem you are seeing. If chkbox and order refer to the same list then setting one will also set the other. You should be initialising like this ctx.locals.chkbox = [] ctx.locals.order = [] ctx.add_session_vars('chkbox', 'order') - Dave -- http://www.object-craft.com.au From djc at object-craft.com.au Wed Oct 30 10:56:20 2002 From: djc at object-craft.com.au (Dave Cole) Date: 30 Oct 2002 10:56:20 +1100 Subject: [albatross-users] Dynamic question In-Reply-To: <3DBF1D36.62738944@itga.com.au> References: <3DB89007.F450C8F6@itga.com.au> <3DBF1D36.62738944@itga.com.au> Message-ID: > Dave, Thanks for this solution. I have found another way to do > this, but it requires templating. > > > > > I use and expression to include the macro file and all of my form > macros have the same name ie form. So by resolving the include will > bring up different form. The only (minor) downside to your approach is that you end up with multiple macros identified by the same name ('form'). > Loving the program at the moment, may even have a prototype up by > days end. Yay. - Dave -- http://www.object-craft.com.au From djc at object-craft.com.au Wed Oct 30 11:13:05 2002 From: djc at object-craft.com.au (Dave Cole) Date: 30 Oct 2002 11:13:05 +1100 Subject: [albatross-users] Form state problem In-Reply-To: References: Message-ID: >>>>> "Michael" == Michael C Neel writes: Michael> Ah, young grasshopper is schooled... Yes, that's exactly Michael> what I did, even though Learning Python p.64 warns of this. Michael> Everything works fine now. Have you considered using a small class to group values instead of using parallel arrays? class OrderInput: def __init__(self, cfid, name): self.cfid = cfid self.name = name self.checked = 'on' self.order = '' def albatross_alias(self): return 'order%s' % self.cfid ctx.locals.orders = [OrderInput(1, 'One'), OrderInput(2, 'Two')] ctx.add_session_vars('orders') Enable Custom Form
Displayed Field Name Ordering
Then your code which processes the input can simply do something like this: for order in ctx.local.orders: if order.checked == 'on': # do something For added security (since 1.01) you might even want to do this: ctx.locals._orders This would prevent the browser from directly accessing any of the internal values except via the alias. - Dave -- http://www.object-craft.com.au From neel at mediapulse.com Wed Oct 30 13:51:31 2002 From: neel at mediapulse.com (Michael Neel) Date: Tue, 29 Oct 2002 21:51:31 -0500 Subject: [albatross-users] Form state problem In-Reply-To: Message-ID: <000001c27fbf$40579d40$0400a8c0@clapton> I feel ashamed to not have thought of that. It's been several years since I've worked in an OO language, and the years of that "other p" have taken their toll I see. I'll have to do some playing around to get the OrderInput class callable from the template, but that shouldn't be too much work. The reason I set it from the template is I use a custom tag I wrote, alx-sql, to run SQL statements inside the template. It works something like such... Or also handy with Mike -----Original Message----- From: djc at ferret.object-craft.com.au [mailto:djc at ferret.object-craft.com.au] On Behalf Of Dave Cole Sent: Tuesday, October 29, 2002 7:13 PM To: Michael C. Neel Cc: albatross-users at object-craft.com.au Subject: Re: [albatross-users] Form state problem >>>>> "Michael" == Michael C Neel writes: Michael> Ah, young grasshopper is schooled... Yes, that's exactly what Michael> I did, even though Learning Python p.64 warns of this. Michael> Everything works fine now. Have you considered using a small class to group values instead of using parallel arrays? class OrderInput: def __init__(self, cfid, name): self.cfid = cfid self.name = name self.checked = 'on' self.order = '' def albatross_alias(self): return 'order%s' % self.cfid ctx.locals.orders = [OrderInput(1, 'One'), OrderInput(2, 'Two')] ctx.add_session_vars('orders') Enable Custom Form
Displayed Field Name Ordering
Then your code which processes the input can simply do something like this: for order in ctx.local.orders: if order.checked == 'on': # do something For added security (since 1.01) you might even want to do this: ctx.locals._orders This would prevent the browser from directly accessing any of the internal values except via the alias. - Dave -- http://www.object-craft.com.au From djc at object-craft.com.au Wed Oct 30 14:04:13 2002 From: djc at object-craft.com.au (Dave Cole) Date: 30 Oct 2002 14:04:13 +1100 Subject: [albatross-users] Form state problem In-Reply-To: <000001c27fbf$40579d40$0400a8c0@clapton> References: <000001c27fbf$40579d40$0400a8c0@clapton> Message-ID: > I feel ashamed to not have thought of that. It's been several years > since I've worked in an OO language, and the years of that "other p" > have taken their toll I see. I'll have to do some playing around to > get the OrderInput class callable from the template, but that > shouldn't be too much work. The reason I set it from the template > is I use a custom tag I wrote, alx-sql, to run SQL statements inside > the template. It works something like such... > > args="(1,)"> > > > > Or also handy with optionexpr="db_cursor.fetchall()" /> Very nice. How hard was it building the extension tag? - Dave -- http://www.object-craft.com.au From gnb at itga.com.au Wed Oct 30 14:37:46 2002 From: gnb at itga.com.au (Gregory Bond) Date: Wed, 30 Oct 2002 14:37:46 +1100 Subject: [albatross-users] Form state problem In-Reply-To: Your message of 30 Oct 2002 14:04:13 +1100. Message-ID: <200210300337.OAA14375@lightning.itga.com.au> > args="(1,)"> Very cool. I could use something like this. Hmmmm..... It could use a ctx.dbhandle() method to return a DBI-compliant handle. (This divorces details about db vendor, and vendor-specific stuff like login etc, away from the tag implementation and into the application-defined ctx class). Have a name="" attribute to specify the name of the cursor object, so you can have nested cursors. Or perhaps have 2 tags: al-sql which works like al-expr al-sqlfor which returns an iterator over the sql cursor, like al-for. I might have a play with this sometime..... From neel at mediapulse.com Wed Oct 30 15:24:21 2002 From: neel at mediapulse.com (Michael Neel) Date: Tue, 29 Oct 2002 23:24:21 -0500 Subject: [albatross-users] Form state problem In-Reply-To: Message-ID: <000001c27fcc$38b57ff0$0400a8c0@clapton> > Very nice. How hard was it building the extension tag? Very easy. In fact I did the extension tag in my second day of using albatross. Since Gregory might have use here is the alx_sql.py code (the database connection is made in globals.py): .......................................... import albatross, MySQLdb from globals import db class Sql(albatross.EmptyTag): name = 'alx-sql' def __init__(self, ctx, filename, line_num, dict): self.db_cursor = db.cursor() albatross.EmptyTag.__init__(self, ctx, filename, line_num, dict) def to_html(self, ctx): stmt = self.get_attrib('stmt') args = self.get_attrib('args') ctx.locals.db_cursor = self.db_cursor try: if args is None: ctx.locals.db_cursor.execute(stmt) else: ctx.locals.db_cursor.execute(stmt, eval(args, ctx.locals.__dict__)) except MySQLdb.DatabaseError, errstr: self.raise_error("Database Error: " + str(errstr)) ........................................... Not a lot, but gets the job done. I used MySQLdb, but should work with any DB API 2.0 driver without much change. Mike From neel at mediapulse.com Wed Oct 30 15:29:13 2002 From: neel at mediapulse.com (Michael Neel) Date: Tue, 29 Oct 2002 23:29:13 -0500 Subject: [albatross-users] Form state problem In-Reply-To: <200210300337.OAA14375@lightning.itga.com.au> Message-ID: <000101c27fcc$e6aeb360$0400a8c0@clapton> I Just sent in my lowly .01 version to the list. If you do add some of this (name="" was sometihng I had on my list, esp. since mysql does not yet do sub-selects) let me know! Mike -----Original Message----- From: gnb at itga.com.au [mailto:gnb at itga.com.au] Sent: Tuesday, October 29, 2002 10:38 PM To: Dave Cole Cc: Michael Neel; albatross-users at object-craft.com.au Subject: Re: [albatross-users] Form state problem > args="(1,)"> Very cool. I could use something like this. Hmmmm..... It could use a ctx.dbhandle() method to return a DBI-compliant handle. (This divorces details about db vendor, and vendor-specific stuff like login etc, away from the tag implementation and into the application-defined ctx class). Have a name="" attribute to specify the name of the cursor object, so you can have nested cursors. Or perhaps have 2 tags: al-sql which works like al-expr al-sqlfor which returns an iterator over the sql cursor, like al-for. I might have a play with this sometime..... From gnb at itga.com.au Thu Oct 31 11:18:31 2002 From: gnb at itga.com.au (Gregory Bond) Date: Thu, 31 Oct 2002 11:18:31 +1100 Subject: [albatross-users] Minor nits in HTML doco Message-ID: <200210310018.LAA03742@lightning.itga.com.au> A bunch of places the literal examples get screwed somehow in the HTML conversion. E.g., Sec 5.1.2 , the first example renders like this: This seems to mainly affect the src= attribute. The underlying HTML is similarly busted
   <al-input type="image" nextpage="m" srcicons/right.gif" border="0">
   
but the .tex seems reasonable: \begin{verbatim} \end{verbatim} Wonder if there is some special-casing of the string '=/"' in the tex->html converter?? From djc at object-craft.com.au Thu Oct 31 12:05:19 2002 From: djc at object-craft.com.au (Dave Cole) Date: 31 Oct 2002 12:05:19 +1100 Subject: [albatross-users] Minor nits in HTML doco In-Reply-To: <200210310018.LAA03742@lightning.itga.com.au> References: <200210310018.LAA03742@lightning.itga.com.au> Message-ID: > A bunch of places the literal examples get screwed somehow in the HTML > conversion. E.g., Sec 5.1.2 , the first example renders like this: > > This seems to mainly affect the src= attribute. > > The underlying HTML is similarly busted >
>    <al-input type="image" nextpage="m" srcicons/right.gif" border="0">
>    
> but the .tex seems reasonable: > \begin{verbatim} > > \end{verbatim} > > > Wonder if there is some special-casing of the string '=/"' in the > tex->html converter?? I just upgraded to the latest latex2html and it still does bad things. Time to do some research I suppose. - Dave -- http://www.object-craft.com.au From andrewm at object-craft.com.au Thu Oct 31 12:09:29 2002 From: andrewm at object-craft.com.au (Andrew McNamara) Date: Thu, 31 Oct 2002 12:09:29 +1100 Subject: [albatross-users] Minor nits in HTML doco In-Reply-To: Message from Gregory Bond of "Thu, 31 Oct 2002 11:18:31 +1100." <200210310018.LAA03742@lightning.itga.com.au> References: <200210310018.LAA03742@lightning.itga.com.au> Message-ID: <20021031010929.A561B3CBD0@coffee.object-craft.com.au> >A bunch of places the literal examples get screwed somehow in the HTML >conversion. E.g., Sec 5.1.2 , the first example renders like this: > >This seems to mainly affect the src= attribute. [...] >but the .tex seems reasonable: > \begin{verbatim} > > \end{verbatim} We'd noticed this - something odd is certainly happening inside latex2html. >Wonder if there is some special-casing of the string '=/"' in the tex->html >converter?? But it's a 560KB perl script that bears more resemblance to line noise than most perl scripts, so who'd really know? 8-( -- Andrew McNamara, Senior Developer, Object Craft http://www.object-craft.com.au/ From gnb at itga.com.au Thu Oct 31 16:15:02 2002 From: gnb at itga.com.au (Gregory Bond) Date: Thu, 31 Oct 2002 16:15:02 +1100 Subject: [albatross-users] A pattern for processing a bunch of items at once? Message-ID: <200210310515.QAA21763@lightning.itga.com.au> I'm looking for a good Albatross pattern for the following problem: Consider the popview application in the manual. What if you wanted to have the ability to delete several of the messages in the one operation? My thoughts so far are to include a checkbox on each row with a name like "del_" (built using nameexpr), and a delete button. But the next bit is odd: the best thing I can think of for the page_process() function is something like: if ctx.req_equals('delete'): for v in ctx.locals.__dict__: if v[:4] == 'del_': mbox.delete_msg(int(v[4:])) but this is pretty ugly. Any better/more elegant ways that ppl can suggest? From gregh at object-craft.com.au Thu Oct 31 16:53:14 2002 From: gregh at object-craft.com.au (Greg Hamilton) Date: Thu, 31 Oct 2002 16:53:14 +1100 Subject: [albatross-users] A pattern for processing a bunch of items at once? In-Reply-To: <200210310515.QAA21763@lightning.itga.com.au> Message-ID: <0BCC9354-EC95-11D6-882F-000393B5EFF2@object-craft.com.au> I've had to do something similar a few times. I don't know if this is the best solution but it works for me. On Thursday, October 31, 2002, at 04:15 PM, Gregory Bond wrote: > I'm looking for a good Albatross pattern for the following problem: > > Consider the popview application in the manual. What if you wanted to > have the > ability to delete several of the messages in the one operation? > > My thoughts so far are to include a checkbox on each row with a name > like > "del_" (built using nameexpr), and a delete button. Create a checkbox for each message. Give each checkbox the same name. Set the value to something which uniquely identifies the message. > But the next bit is odd: the best thing I can think of for the > page_process() > function is something like: > if ctx.req_equals('delete'): > for v in ctx.locals.__dict__: > if v[:4] == 'del_': > mbox.delete_msg(int(v[4:])) > but this is pretty ugly. > > Any better/more elegant ways that ppl can suggest? > > Then put something like this in your page module. def page_enter(ctx): ctx.locals.messages = load_messages_from_somewhere() ctx.locals.del_msgs = None ctx.add_session_vars('messages', 'del_msgs', ) def page_process(ctx): if ctx.req_equals('delete'): # if nothing is selected return is None # if one item, return is String # if >1 items, return is list if ctx.local.del_msgs is None: # nothing selected pass elif type(ctx.locals.del_msgs) == types.StringType: # one message to delete pass elif type(ctx.locals.del_msgs) == types.ListType: # a list of messages to delete pass The only trap to watch out for is that 'del_msgs' will be None, a String or a List (or more likely a tuple, I don't recall) depending on the number of items selected. Greg Hamilton -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: text/enriched Size: 2222 bytes Desc: not available URL: From gnb at itga.com.au Thu Oct 31 17:04:17 2002 From: gnb at itga.com.au (Gregory Bond) Date: Thu, 31 Oct 2002 17:04:17 +1100 Subject: [albatross-users] A pattern for processing a bunch of items at once? In-Reply-To: Your message of Thu, 31 Oct 2002 16:53:14 +1100. Message-ID: <200210310604.RAA14336@lightning.itga.com.au> >Create a checkbox for each message. Give each checkbox the same name. >Set the value to something which uniquely identifies the message. >The only trap to watch out for is that 'del_msgs' will be None, a String or a >List (or more likely a tuple, I don't recall) depending on the number of items >selected. Whacko! Fabulous answer, thanks! I'd fergotten the "might be a list" "feature" of cgi..... From andrewm at object-craft.com.au Thu Oct 31 17:05:41 2002 From: andrewm at object-craft.com.au (Andrew McNamara) Date: Thu, 31 Oct 2002 17:05:41 +1100 Subject: [albatross-users] A pattern for processing a bunch of items at once? In-Reply-To: Message from Greg Hamilton of "Thu, 31 Oct 2002 16:53:14 +1100." <0BCC9354-EC95-11D6-882F-000393B5EFF2@object-craft.com.au> References: <0BCC9354-EC95-11D6-882F-000393B5EFF2@object-craft.com.au> Message-ID: <20021031060541.6CC053CBD0@coffee.object-craft.com.au> >The only trap to watch out for is that 'del_msgs' will be None, a >String or a List (or more likely a tuple, I don't recall) depending on >the number of items selected. Albatross 1.00 introduced the list="list" attribute, which forces the return to be a list. So, you want your al-input to look like: -- Andrew McNamara, Senior Developer, Object Craft http://www.object-craft.com.au/ From bgg at object-craft.com.au Thu Oct 31 17:08:16 2002 From: bgg at object-craft.com.au (Ben Golding) Date: Thu, 31 Oct 2002 17:08:16 +1100 Subject: [albatross-users] A pattern for processing a bunch of items at once? In-Reply-To: <0BCC9354-EC95-11D6-882F-000393B5EFF2@object-craft.com.au> Message-ID: <2551EFE2-EC97-11D6-94C8-003065907038@object-craft.com.au> On Thursday, Oct 31, 2002, at 16:53 Australia/Melbourne, Greg Hamilton wrote: > Create a checkbox for each message. Give each checkbox the same name. > Set the value to something which uniquely identifies the message. > > > > valueexpr="element.value().get_message_id()" whitespace> > > > If you add the "list" attribute to the al-input, so that it reads: then it will always return a list which will be empty, contain a single element, or all selected elements. That makes the code below largely redundant which was why it was added. > def page_process(ctx): > if ctx.req_equals('delete'): > # if nothing is selected return is None > # if one item, return is String > # if >1 items, return is list > if ctx.local.del_msgs is None: > # nothing selected > pass > elif type(ctx.locals.del_msgs) == types.StringType: > # one message to delete > pass > elif type(ctx.locals.del_msgs) == types.ListType: > # a list of messages to delete > pass That should simplify things. Ben.