From korg at darkqueen.org Tue Jul 1 01:09:48 2003 From: korg at darkqueen.org (Cameron Blackwood) Date: Tue, 01 Jul 2003 11:09:48 +1000 Subject: [albatross-users] Re: Albatross-users digest, Vol 1 #176 - 14 msgs In-Reply-To: Your message of "Tue, 01 Jul 2003 03:53:01 +1000." <20030630175301.20310.73173.Mailman@numbat.object-craft.com.au> Message-ID: <200307010109.h6119m713416@firewall.darkqueen.org> From: Dave Cole : | | Matt> On Sun, 2003-06-29 at 10:42, Dave Cole wrote: | >> I am at the end of the largest outstanding documentation task - the | >> tag reference. Now would be a good time to hit me with issues | >> before I launch into another task. | | Matt> Is that a hint? ;-) | | Maybe... Now I feel silly for commenting on the docs. :-/ From: "Michael C. Neel" : | From: Dave Cole [mailto:djc@object-craft.com.au]=20 | > Subject: Re: [albatross-users] New tag reference | =20 | http://www.object-craft.com.au/projects/albatross/albatross/tag-input-ge | neric.html if user: ctx.locals._user = user ctx.add_session_vars('_user') ^ remove the '_' ?? | =20 | http://www.object-craft.com.au/projects/albatross/albatross/tag-input-im | age.html Oooooh, nifty!! So, having said I feel stoopid for commenting on the docs... I notice that the page renders as: ^ missing " again. | =20 | http://www.object-craft.com.au/projects/albatross/albatross/tag-input-fi | le.html "a flag indicating whether or not the list (5.2.2.4) attribute was present." is directly followed by: "The request merging allows the user to submit more than one file in a file input field. To simplify application code the Request always returns a list of FileField objects for file inputs" So, 'request merging' allows submitting more than one file in a single al-imput, but the list attribute allows for multiple al-inputs of the same name? ?? It seems unclear. From: "Eric S. Johansson" : | Subject: Re: [albatross-users] Renaming application and execution context | classes | | | To me, simple context is far more descriptive of what the class does than | template context. This is more apparent when you contrast simple applicati | on | versus client session page object application. I didnt find it so as a newbie. I thought simple applied to the complexity of the object, not how the data was stored. That could be because Im dumb tho :) :) :) | | On a personal note, I find StudleyCaps quite disturbing. In 1994 after bei | ng a [...] | again, this is a long-winded way of saying that ordinary_words | separated_by_the_underscore_character is preferable to me and that I subscr | ibe Im with you there, man. :) Long descriptive names and '_'s up the whazoo for me :) I want going to comment because I didnt write albatross, so I didnt feel that I could comment on coding style, but now you mention it... Now, if we cant use generic classes with initiators like: Context(storage=Albatross.file) then Id vote for 2| SimpleContext Context_stored_nowhere(?) Context_no_store(?) 2| AppContext 2| 2| SimpleAppContext Context_stored_client 2| SessionAppContext Context_stored_server_process 2| SessionFileAppContext Context_stored_server_file (note, typing this, was suddenly unsure of SessionAppContext again, before I worked out which one it was by process of elimination. Id argue that the name isnt immediatly obvious, so renaming would be helpful) And the same but longer for the Apps (although again, Id prefer the app not to need to know how the context was stored, but maybe thats just me). -- / `Rev Dr' cam at darkqueen.org Roleplaying, virtual goth \ < http://darkqueen.org Poly, *nix, Python, C/C++, genetics, ATM > \ [+61 3] 9809 1523[h] skeptic, Evil GM(tm). Sysadmin for hire / ---------- Random Quote ---------- "I changed my headlights the other day. I put in strobe lights instead! Now when I drive at night, it looks like everyone else is standing still ..." -- Steven Wright From esj at harvee.org Tue Jul 1 02:50:21 2003 From: esj at harvee.org (Eric S. Johansson) Date: Mon, 30 Jun 2003 22:50:21 -0400 Subject: [albatross-users] Re: Albatross-users digest, Vol 1 #176 - 14 msgs In-Reply-To: <200307010109.h6119m713416@firewall.darkqueen.org> References: <200307010109.h6119m713416@firewall.darkqueen.org> Message-ID: <3F00F6ED.5050009@harvee.org> Cameron Blackwood wrote: > Now I feel silly for commenting on the docs. :-/ shouldn't. (Too much) > > Im with you there, man. :) > > Long descriptive names and '_'s up the whazoo for me :) > > I want going to comment because I didnt write albatross, so I didnt > feel that I could comment on coding style, but now you mention it... > > Now, if we cant use generic classes with initiators like: > Context(storage=Albatross.file) > then Id vote for > > 2| SimpleContext Context_stored_nowhere(?) > Context_no_store(?) > 2| AppContext > 2| > 2| SimpleAppContext Context_stored_client > 2| SessionAppContext Context_stored_server_process > 2| SessionFileAppContext Context_stored_server_file I like this series of proposed names because it's something that makes sense. > And the same but longer for the Apps (although again, Id prefer > the app not to need to know how the context was stored, but maybe > thats just me). there is a couple things about albatross that has plagued me and excessive visibility of what should be internals is one of them. The documentation looks like it is very good if you have already absorbed the gestalt of albatross. Unfortunately, I've been reading the documentation and trying to understand the gestalt without much success. Goodness knows I've written my fair share of train-by-telepathy documentation so there is no blame by me on that point, just observation. one of the gestalt points is communicating information from the python side to the HTML side and back. I've been mucking with it for about a week and I am no closer to having a useful knowledge of information transfer issues than I was before I started. The black magic surrounding context.local really isn't clear nor is the usage of attributes. I've been using Python for the better part of the year and a half now and I've never used attributes (knowingly). Maybe it's some sort of watershed one must cross in order to become an anointed pythoninista, I don't know. In any case, this gestalt has driven me to the point of admitting failure. I've surveyed a fair number of template/CGI tools and I think albatross is one of the better overall and has the best potential for being small and really effective. However, I have been unable to learn enough to do I need to do and I cannot ask any more from the community. You have been more than generous with your time already and for that I am grateful. on the documentation front, take a look at CherryPY and pso. while I'm not happy with either of them for different reasons, they both have good documentation teaching people how to use their system. If you can accept a suggestion, I would suggest creating an very simple user-friendly layer. It would reflect the simple nature of CGI environment. It would consist of a couple of functions/methods. The first would be used for generating output. It would associate a dictionary with an albatross HTML template. The keys of the dictionary would map to variable names in the template. The matching value to a given key would be substituted into the variables. Obviously, nested lists, dictionaries etc. would be permitted so that for loops etc. in the templates could be used. the second function would extract information back from CGI forms. I haven't thought long on the form it would take but I suspect it would also be some form of dictionary based structure based on an albatross HTML template. obviously these ideas aren't fully formed but they are a reflection of my confidence that that the whole process can be simplified even further than it has been to date. I also believe it should be possible to create a layer over the current albatross API to generate this kind of simple interface. Again, I want to thank everyone who has been so very helpful and I appreciate the effort you have expended in helping me. ---eric From korg at darkqueen.org Tue Jul 1 05:42:05 2003 From: korg at darkqueen.org (Cameron Blackwood) Date: Tue, 01 Jul 2003 15:42:05 +1000 Subject: [albatross-users] al-input type="image": internal bug/obscured traceback?? Message-ID: <200307010542.h615g5N15836@firewall.darkqueen.org> Halp... Hi, Im playing with clickable images in 1.10pre1 and I try: ----------- vv ----------- Oh crap ----------- ^^ ----------- which generates some thing like (neatened): ----------- vv ----------- Oh crap
----------- ^^ ----------- but when I click on the image, I get: ----------- vv ----------- Template traceback (most recent call last): Traceback (most recent call last): File "/usr/lib/python2.1/site-packages/albatross/app.py", line 221, in run self.merge_request(ctx) File "/usr/lib/python2.1/site-packages/albatross/app.py", line 301, in merge_request ctx.merge_request() File "/usr/lib/python2.1/site-packages/albatross/context.py", line 279, in merge_request text = self.request.field_value('__albform__') File "/usr/lib/python2.1/site-packages/albatross/cgiapp.py", line 26, in field_value if isinstance(field, list): TypeError: isinstance() arg 2 must be a class or type ----------- ^^ ----------- Which doesnt look like it's in my code at all. :-/ (or if it is, how to I get a real traceback or some more useful feedback?) Infact clicking on the submit button also generates the above error. Hmmm? Its probably a problem in my actual code, but it's kinda hard to find it with the above traceback (which makes it look like an albatross internal problem). ?? cheese :), cam -- / `Rev Dr' cam at darkqueen.org Roleplaying, virtual goth \ < http://darkqueen.org Poly, *nix, Python, C/C++, genetics, ATM > \ [+61 3] 9809 1523[h] skeptic, Evil GM(tm). Sysadmin for hire / ---------- Random Quote ---------- TAILFINS!! ... click ... From korg at darkqueen.org Tue Jul 1 06:30:28 2003 From: korg at darkqueen.org (Cameron Blackwood) Date: Tue, 01 Jul 2003 16:30:28 +1000 Subject: [albatross-users] Simple/Class based register? Message-ID: <200307010630.h616USN16233@firewall.darkqueen.org> Im sick of forgetting to register my classes. :-/ Can anyone see a problem with doing something like this? (Besides speed, which is obviously going to be slower than hardcoding). ----------- 8< also.py >8 ----------- import p class page_also1(p.AlbatrossClass): pass class page_also2(p.AlbatrossClass): pass ----------- 8< also.py >8 ----------- ----------- 8< p.py >8 ----------- class app: def __init__(s): startpage=None for name,value in globals().items(): is_albatross_start= is_albatross= None try: if value not in [AlbatrossClass, AlbatrossStartClass]: is_albatross_start=value.is_albatross_start_class is_albatross= value.is_albatross_class except: pass # if startpage and is_albatross_start: squid=squid-donut() # error! if is_albatross_start: startpage=name if is_albatross: print 'I should register',name,value print 'Start page is:',startpage class AlbatrossClass: is_albatross_class=1 is_albatross_start_class=0 class AlbatrossStartClass(AlbatrossClass): is_albatross_start_class=1 class page1(AlbatrossStartClass): pass class page2(AlbatrossClass): pass class page3(AlbatrossClass): pass def main(): MyApp=app() if __name__=="__main__": main() ----------- 8< p.py >8 ----------- Running python p.py gives me ----------- 8< output >8 ----------- register page_also1 also.page_also1 register page_also2 also.page_also2 register page3 __main__.page3 register page2 __main__.page2 register page1 __main__.page1 start page is: page1 ----------- 8< output >8 ----------- cheers, cam -- / `Rev Dr' cam at darkqueen.org Roleplaying, virtual goth \ < http://darkqueen.org Poly, *nix, Python, C/C++, genetics, ATM > \ [+61 3] 9809 1523[h] skeptic, Evil GM(tm). Sysadmin for hire / ---------- Random Quote ---------- There is no such thing as fortune. Try again. From korg at darkqueen.org Tue Jul 1 07:31:07 2003 From: korg at darkqueen.org (Cameron Blackwood) Date: Tue, 01 Jul 2003 17:31:07 +1000 Subject: [albatross-users] Re: Simple/Class based register? In-Reply-To: Your message of "Tue, 01 Jul 2003 16:30:28 +1000." Message-ID: <200307010731.h617V7T16859@firewall.darkqueen.org> "Cameron Blackwood" writes: | Im sick of forgetting to register my classes. :-/ | | Can anyone see a problem with doing something like this? | (Besides speed, which is obviously going to be slower than hardcoding). I can see a problem with it :) I cant avoid needing to pass globals() to my wrapper library and I think thats ugly, so ignore me. -- / `Rev Dr' cam at darkqueen.org Roleplaying, virtual goth \ < http://darkqueen.org Poly, *nix, Python, C/C++, genetics, ATM > \ [+61 3] 9809 1523[h] skeptic, Evil GM(tm). Sysadmin for hire / ---------- Random Quote ---------- But like the Good Book says... There's BIGGER DEALS to come! From korg at darkqueen.org Tue Jul 1 08:43:07 2003 From: korg at darkqueen.org (Cameron Blackwood) Date: Tue, 01 Jul 2003 18:43:07 +1000 Subject: [albatross-users] @#*(&$@!! Waste of a day... :( In-Reply-To: Your message of "Tue, 01 Jul 2003 17:31:07 +1000." Message-ID: <200307010843.h618h7K17558@firewall.darkqueen.org> http://www.object-craft.com.au/projects/albatross/albatross/inst-pre.html Says: "2.1 Prerequisites * Python 2.1 or later." But... cgiapp.py:26 reads: if isinstance(field, list): Which breaks on list.... Python 2.1.1 (#1, Aug 30 2001, 17:36:05) [GCC 2.96 20000731 (Mandrake Linux 8.1 2.96-0.61mdk)] on linux-i386 Type "copyright", "credits" or "license" for more information. >>> type(list) because a function isnt the same as: Python 2.2.2 (#2, Feb 5 2003, 10:40:08) [GCC 3.2.1 (Mandrake Linux 9.1 3.2.1-5mdk)] on linux-i386 Type "help", "copyright", "credits" or "license" for more information. >>> type(list) So I assume 1.10pre1 needs atleast 2.2? Shouldnt setup.py not install albatross for non working versions of python? (Especially for it works until you acutally submit a form type errors). -- / `Rev Dr' cam at darkqueen.org Roleplaying, virtual goth \ < http://darkqueen.org Poly, *nix, Python, C/C++, genetics, ATM > \ [+61 3] 9809 1523[h] skeptic, Evil GM(tm). Sysadmin for hire / ---------- Random Quote ---------- I just got out of the hospital after a speed reading accident. I hit a bookmark. -- Steven Wright From matt at pollenation.net Tue Jul 1 09:23:57 2003 From: matt at pollenation.net (Matt Goodall) Date: Tue, 01 Jul 2003 10:23:57 +0100 Subject: [albatross-users] Simple/Class based register? In-Reply-To: <200307010630.h616USN16233@firewall.darkqueen.org> References: <200307010630.h616USN16233@firewall.darkqueen.org> Message-ID: <3F01532D.6030401@pollenation.net> Cameron Blackwood wrote: >Im sick of forgetting to register my classes. :-/ > Is this just searching for page classes and registering them automatically? If so, have you thought about using the PageModuleMixin or, more likely, one of the ModularXxx prepackaged application classes instead? With those you do not need to register your classes - Albatross will load the module dynamically on first request. Cheers, Matt -- Matt Goodall, Pollenation Internet Ltd e: matt@pollenationinternet.com t: 0113 2252500 From matt at pollenation.net Tue Jul 1 09:37:26 2003 From: matt at pollenation.net (Matt Goodall) Date: Tue, 01 Jul 2003 10:37:26 +0100 Subject: [albatross-users] Re: Albatross-users digest, Vol 1 #176 - 14 msgs In-Reply-To: <3F00F6ED.5050009@harvee.org> References: <200307010109.h6119m713416@firewall.darkqueen.org> <3F00F6ED.5050009@harvee.org> Message-ID: <3F015656.2040606@pollenation.net> Hi Eric, I realise you have posted quite a bit to the list recently (which is definitely not a problem!) and got some answers but could you quickly and clearly summarize the problems you are still facing with Albatross. Perhaps we could then address each issue again and see if we can help you. Cheers, Matt -- Matt Goodall, Pollenation Internet Ltd e: matt@pollenationinternet.com From djc at object-craft.com.au Tue Jul 1 10:14:17 2003 From: djc at object-craft.com.au (Dave Cole) Date: 01 Jul 2003 20:14:17 +1000 Subject: [albatross-users] Re: Renaming application and execution context classes In-Reply-To: <200306300717.h5U7Hs105061@firewall.darkqueen.org> References: <200306300717.h5U7Hs105061@firewall.darkqueen.org> Message-ID: > http://www.object-craft.com.au/projects/albatross/albatross/app-popview3.html > "Adding Server-Side Session Support to Popview" > > "The new application prologue looks like this: > > #!/usr/bin/python > from albatross import SimpleSessionApp, SessionAppContext > " > > and then: > > " def create_context(self): > return AppContext(self)" > > but that should be: > > " def create_context(self): > return SessionAppContext(self)" Once you look at the code in the samples/popview3 directory it is a bit clearer what is going on. It certainly looks like the AppContext class should be included in the documentation though :-) I have added the AppContext to the documentation. Thanks for pointing out the problem. - Dave -- http://www.object-craft.com.au From djc at object-craft.com.au Tue Jul 1 10:18:07 2003 From: djc at object-craft.com.au (Dave Cole) Date: 01 Jul 2003 20:18:07 +1000 Subject: [albatross-users] Re: Renaming application and execution context classes In-Reply-To: <200306300721.h5U7Lv605110@firewall.darkqueen.org> References: <200306300721.h5U7Lv605110@firewall.darkqueen.org> Message-ID: > http://www.object-craft.com.au/projects/albatross/albatross/app-proto-new.html > > looks kinda weird: > ?

> ?

>   ? "new " appid " " age CRLF
>   ? 
>   ? 
> ? > ?

> ? Successful response will be a line of the form: > ? > ?

> ?

>   ? "OK " sesid CRLF
>   ? 
> ? > > I assume the "'s are ment to be more clear? A Python representation of the above would look like this: 'new %s %s\r\n' % (appid, age) 'OK %s\r\n' % sesid Is that how you read the text? - Dave -- http://www.object-craft.com.au From djc at object-craft.com.au Tue Jul 1 10:30:26 2003 From: djc at object-craft.com.au (Dave Cole) Date: 01 Jul 2003 20:30:26 +1000 Subject: [albatross-users] Renaming application and execution context classes In-Reply-To: <3F007B12.3070107@pollenation.net> References: <3F007B12.3070107@pollenation.net> Message-ID: >>>>> "Matt" == Matt Goodall writes: Matt> Michael C. Neel wrote: >> I won't admit how long I used hungarian notation... >> Matt> Shudder. ;-) When I was learning how to be a Windows programmer in the 3.0 days I gave hungarian notation a try. What I found was that I spent way too much time trying to work out the correct notation for a type that actually naming the variable. It never stuck in my mind. It was much later that I formed an opinion about the notation. Funny story: Around 1990 on one contract I worked on a system of around 200k lines of Pascal. It made heavy use of hungarian notation. People were constantly complaining that the use of notation and abbreviations was not consistent. After a while I became so sick of tripping over the inconsistent naming that I wrote a program to parse the entire code base and build a global symbol table. The program gave you the ability to interactively browse all of the symbols and show you where they were used. You could then globally rename symbols. After getting the program working I went through and renamed hundreds of symbols in a matter of hours. The result was still hungarian notation, but at least most of the abbreviations were consistent. - Dave -- http://www.object-craft.com.au From djc at object-craft.com.au Tue Jul 1 11:07:34 2003 From: djc at object-craft.com.au (Dave Cole) Date: 01 Jul 2003 21:07:34 +1000 Subject: [albatross-users] Renaming application and execution context classes In-Reply-To: References: Message-ID: > Is it possible to combine the classes into one (from the user's > point of view)? In an ideal world > > app = albatross.App(blah, blah, session_store=albatross.FILE) > > it what I'd like best. > > As for StudyCaps I personally find them much more readable for class > names, and they point out "hey I'm a class not a function", and use > lowercase/_'s for var/function names. This also jives with (most) > the standard library, and I think it's more important to go along > with the norm than have your module be different. > > I won't admit how long I used hungarian notation... Andrew and I thought about something like the above but could not come up with anything that was not extremely hacky and ugly. I like the idea of being able to control individual feature sets like that... In a sense Albatross is already like that though. If you look in at the bottom of albatross/app.py you can hopefully see what I mean. Take for instance the ModularSessionApp class: class ModularSessionApp(PickleSignMixin, Application, CachingTemplateLoaderMixin, PageModuleMixin, SessionServerAppMixin): def __init__(self, base_url, module_path, template_path, start_page, secret, session_appid, session_server = 'localhost', server_port = 34343, session_age = 1800): Application.__init__(self, base_url) PickleSignMixin.__init__(self, secret) CachingTemplateLoaderMixin.__init__(self, template_path) PageModuleMixin.__init__(self, module_path, start_page) SessionServerAppMixin.__init__(self, session_appid, session_server, server_port, session_age) def create_context(self): return SessionAppContext(self) If we did away with all of the prepackaged classes and changed the interface to all of the mixins to just accept **kw then the above could look like this: class ModularSessionApp(PickleSignMixin, Application, CachingTemplateLoaderMixin, PageModuleMixin, SessionServerAppMixin): def __init__(self, **kw): Application.__init__(self, **kw) PickleSignMixin.__init__(self, **kw) CachingTemplateLoaderMixin.__init__(self, **kw) PageModuleMixin.__init__(self, **kw) SessionServerAppMixin.__init__(self, **kw) In theory the create_context() method could be removed from the existing classes. App Class Context Class SimpleApp SimpleAppContext ModularApp SimpleAppContext RandomModularApp SimpleAppContext SimpleSessionApp SessionAppContext ModularSessionApp SessionAppContext RandomModularSessionApp SessionAppContext SimpleSessionFileApp SessionFileAppContext ModularSessionFileApp SessionFileAppContext RandomModularSessionFileApp SessionFileAppContext If we consider SimpleAppContext to be the default execution context for an application, then all application classes that inherit from SessionFileAppMixin create a SessionFileAppContext, while all that inherit from SessionServerAppMixin create SessionAppContext. Taking the above a little further we could probably allow you to do something like this: class MyApp(albatross.AppBase, albatross.PickleSignMixin, albatross.Application, albatross.CachingTemplateLoaderMixin, albatross.PageModuleMixin, albatross.SessionServerAppMixin): pass Then in Albatross we would define the AppBase class to be something like this: class AppBase: def __init__(self, **kw): for klass in self.__class__.__bases__: if klass != AppBase: klass.__init__(self, **kw) All of this is of course untested :-) One big advantage to all of this is that it allows you to change application classes very easily. Going back to yet another suggestion by Cameron Blackwood: http://www.object-craft.com.au/pipermail/albatross-users/2002-November/000166.html This would solve his problem in varying argument lists to application class constructors. - Dave -- http://www.object-craft.com.au From matt at pollenation.net Tue Jul 1 11:25:38 2003 From: matt at pollenation.net (Matt Goodall) Date: Tue, 01 Jul 2003 12:25:38 +0100 Subject: hungarian notation (was Re: [albatross-users] Renaming application and execution context classes) In-Reply-To: References: <3F007B12.3070107@pollenation.net> Message-ID: <3F016FB2.3010102@pollenation.net> Many moons ago, I used to work with OS/2 and its APIs use hungarian notation everywhere so we did too. It seemed like a good idea at the time but as we got more "used" to it we realised that it caused more hastle than benefit. The amusing thing was that we *all* sat down to come up with our coding standards that mandated the use of hungarian notation but over time we *individually*, secretly stopped using it in our code. I can't remember who admitted that they had stopped using it first but there were sighes of relief from everyone :-). I've never used it since. - Matt Dave Cole wrote: >>>>>>"Matt" == Matt Goodall writes: >>>>>> >>>>>> > >Matt> Michael C. Neel wrote: > > >>>I won't admit how long I used hungarian notation... >>> >>> >>> >Matt> Shudder. ;-) > >When I was learning how to be a Windows programmer in the 3.0 days I >gave hungarian notation a try. What I found was that I spent way too >much time trying to work out the correct notation for a type that >actually naming the variable. It never stuck in my mind. It was much >later that I formed an opinion about the notation. > >Funny story: > >Around 1990 on one contract I worked on a system of around 200k lines >of Pascal. It made heavy use of hungarian notation. People were >constantly complaining that the use of notation and abbreviations was >not consistent. > >After a while I became so sick of tripping over the inconsistent >naming that I wrote a program to parse the entire code base and build >a global symbol table. The program gave you the ability to >interactively browse all of the symbols and show you where they were >used. You could then globally rename symbols. > >After getting the program working I went through and renamed hundreds >of symbols in a matter of hours. The result was still hungarian >notation, but at least most of the abbreviations were consistent. > >- Dave > > > -- Matt Goodall, Pollenation Internet Ltd e: matt@pollenationinternet.com t: 0113 2252500 From korg at darkqueen.org Tue Jul 1 11:23:02 2003 From: korg at darkqueen.org (Cameron Blackwood) Date: Tue, 01 Jul 2003 21:23:02 +1000 Subject: [albatross-users] Re: Albatross-users digest, Vol 1 #177 - 13 msgs In-Reply-To: Your message of "Tue, 01 Jul 2003 20:19:01 +1000." <20030701101901.28516.20369.Mailman@numbat.object-craft.com.au> Message-ID: <200307011123.h61BN2w19204@firewall.darkqueen.org> From: "Eric S. Johansson" : | | Cameron Blackwood wrote: | > | > Im with you there, man. :) | > | > Long descriptive names and '_'s up the whazoo for me :) | > | > I want going to comment because I didnt write albatross, so I didnt | > feel that I could comment on coding style, but now you mention it... | > | > Now, if we cant use generic classes with initiators like: | > Context(storage=Albatross.file) This would be my preferred solution actually :) or even Application(contest=Albatross.store_on_client) :) | > 2| SimpleAppContext Context_stored_client | > 2| SessionAppContext Context_stored_server_process | > 2| SessionFileAppContext Context_stored_server_file | | I like this series of proposed names because it's something that makes sens | e. *nod* instantly readable! Thats gotta be a Good Thing(tm) | | > And the same but longer for the Apps (although again, Id prefer | > the app not to need to know how the context was stored, but maybe | > thats just me). | | there is a couple things about albatross that has plagued me and excessive | visibility of what should be internals is one of them. *nod* Im agree 100%. Trying to nut out the difference between all the Application types etc is something I hit again and again. | trying to understand the gestalt without much success. Goodness knows I've | | written my fair share of train-by-telepathy documentation so there is no bl *haha* | | one of the gestalt points is communicating information from the python side | to | the HTML side and back. I've been mucking with it for about a week and I a | m no | closer to having a useful knowledge of information transfer issues than I w | as | before I started. The black magic surrounding context.local really isn't c | lear | nor is the usage of attributes. I've been using Python for the better part I just tend to put everyting in context.local.variable_name and then ctx.add_session_vars('variable_name') and magically it's useable from my template. Maybe its just laziness on my part, but it just kinda works. | | In any case, this gestalt has driven me to the point of admitting failure. | I've | surveyed a fair number of template/CGI tools and I think albatross is one o | f the | better overall and has the best potential for being small and really effect | ive. Yeah, I agree. Albatross is so tauntingly almost perfect ;). (Im not saying I could do better, but there just seem to be a couple of things that poke me in the eye everytime I think I fully understand it :) | However, I have been unable to learn enough to do I need to do and I cann | ot | ask any more from the community. You have been more than generous with you | r | time already and for that I am grateful. Actually, one thing that I think Albatross __REALLY__ __REALLY__ needs are some simple example/skeleton code fragments. Maybe this should be a list effort, not something we all wait for object-craft.com.au to do. What kind of demo would help you get your stuff done? I was thinking along the lines of... 1) An demo page that takes input and dumps it to some python code and displays the results in various ways. (Kind of already there, but one that tests the various template tags.) 2) An example app that lets you: Login, user, edit user.details change user.picture edit user.story 3) A more complex example with a custom al-session-daemon that holds a number of 'users' and 'chess games' and (using the newly renamed Context_stored_server_process :) lets you: Login, user, list/create game join game play game make move send message (this one is more complex because you have the whole state saving and parallel input problem) This is top of my head stuff, but if we as a list could come up with a set of 'these examples would be great', then Id sure be up for trying to code some of them. (I mean, it'd be a good learning exercise ;) | | If you can accept a suggestion, I would suggest creating an very simple | user-friendly layer. It would reflect the simple nature of CGI environment | . It | would consist of a couple of functions/methods. The first would be used fo | r | generating output. It would associate a dictionary with an albatross HTML | template. The keys of the dictionary would map to variable names in the | template. The matching value to a given key would be substituted into the | variables. Obviously, nested lists, dictionaries etc. would be permitted s | o | that for loops etc. in the templates could be used. | | the second function would extract information back from CGI forms. I haven | 't | thought long on the form it would take but I suspect it would also be some | form | of dictionary based structure based on an albatross HTML template. | Ive been abusing cgi forms for ages :) Im sure we could would work out a few good examples here. :) Ive been avoiding templates :) so Im not sure I could do it alone. :-/ | obviously these ideas aren't fully formed but they are a reflection of my | confidence that that the whole process can be simplified even further than | it *nod* I have a hope that it could be simplified, but the objectcraft people are smart, so maybe it cant. | has been to date. I also believe it should be possible to create a layer o | ver | the current albatross API to generate this kind of simple interface. *nod* although a set of good useable examples would take away the need, maybe? cam -- / `Rev Dr' cam at darkqueen.org Roleplaying, virtual goth \ < http://darkqueen.org Poly, *nix, Python, C/C++, genetics, ATM > \ [+61 3] 9809 1523[h] skeptic, Evil GM(tm). Sysadmin for hire / ---------- Random Quote ---------- $100 invested at 7% interest for 100 years will become $100,000, at which time it will be worth absolutely nothing. -- Lazarus Long, "Time Enough for Love" From djc at object-craft.com.au Tue Jul 1 11:26:41 2003 From: djc at object-craft.com.au (Dave Cole) Date: 01 Jul 2003 21:26:41 +1000 Subject: [albatross-users] Re: Albatross-users digest, Vol 1 #176 - 14 msgs In-Reply-To: <200307010109.h6119m713416@firewall.darkqueen.org> References: <200307010109.h6119m713416@firewall.darkqueen.org> Message-ID: > | http://www.object-craft.com.au/projects/albatross/albatross/tag-input-generic.html > > if user: > ctx.locals._user = user > ctx.add_session_vars('_user') > ^ > remove the '_' ?? The '_' prefix is there to prevent the browser ever being able to provide _user as an input field in a request. It effectively protects the object from external modification. From: http://www.object-craft.com.au/projects/albatross/albatross/tag-input.html When merging browser requests the application object places the browser supplied value back into the execution context value referenced by the name attribute. The application request merging will not merge variable names prefixed by underscore. Use this to protect application values from browser modification. > | http://www.object-craft.com.au/projects/albatross/albatross/tag-input-image.html > > Oooooh, nifty!! > > So, having said I feel stoopid for commenting on the docs... I notice > that the page renders as: > > > ^ > missing " again. That is really bizarre. Another latex2html bug. It comes up fine in the PDF documentation. The actual file used in the document is doc/doctest/tags-input-image (from the Albatross top level directory). It looks like this: >>> import albatross >>> class Ctx(albatross.SimpleContext): ... def input_add(self, *args): ... print args ... >>> ctx = Ctx('.') >>> albatross.Template(ctx, '', ''' ... ... ''').to_html(ctx) ('image', 'nextpage,m', None, 0) >>> ctx.flush_content() The files in the doc/doctest directory are constructed so that we can run 'make test' in the doc directory and use all of the documentation fragments as unit tests. > | http://www.object-craft.com.au/projects/albatross/albatross/tag-input-file.html > > "a flag indicating whether or not the list (5.2.2.4) attribute was > present." > > is directly followed by: > > "The request merging allows the user to submit more than one file in a > file input field. To simplify application code the Request always > returns a list of FileField objects for file inputs" > > So, 'request merging' allows submitting more than one file in a single > al-imput, but the list attribute allows for multiple al-inputs of the > same name? ?? > > It seems unclear. I blame Andrew :-) (*ducks*) > | On a personal note, I find StudleyCaps quite disturbing. In 1994 after bei > | ng a > [...] > | again, this is a long-winded way of saying that ordinary_words > | separated_by_the_underscore_character is preferable to me and that I subscr > | ibe > > Im with you there, man. :) > > Long descriptive names and '_'s up the whazoo for me :) > > I want going to comment because I didnt write albatross, so I didnt > feel that I could comment on coding style, but now you mention it... I follow the BDFL. http://www.python.org/doc/essays/styleguide.html Class Names Almost without exception, class names use the CapWords convention. Classes for internal use have a leading underscore in addition. Ben (another guy here) says (paraphrased) that when speaking a (spoken) language you strive to speak like a native, or without an accent. The same should apply to programming languages. If you follow the BDFL you are less likely to code Python with an accent. > And the same but longer for the Apps (although again, Id prefer > the app not to need to know how the context was stored, but maybe > thats just me). The application and execution context cooperate to deal with the session. The execution context is where the session data is created manipulated, but the application is usually responsible to loading and saving the session. This allows the application to maintain a long lived connection with a server if necessary. Remember that an execution context lives only long enough to process a single browser request. Hope that does not make things less clear... - Dave -- http://www.object-craft.com.au From djc at object-craft.com.au Tue Jul 1 11:34:39 2003 From: djc at object-craft.com.au (Dave Cole) Date: 01 Jul 2003 21:34:39 +1000 Subject: [albatross-users] Re: Albatross-users digest, Vol 1 #176 - 14 msgs In-Reply-To: <3F00F6ED.5050009@harvee.org> References: <200307010109.h6119m713416@firewall.darkqueen.org> <3F00F6ED.5050009@harvee.org> Message-ID: >>>>> "Eric" == Eric S Johansson writes: Eric> The documentation looks like it is very good if you have already Eric> absorbed the gestalt of albatross. Unfortunately, I've been Eric> reading the documentation and trying to understand the gestalt Eric> without much success. Goodness knows I've written my fair share Eric> of train-by-telepathy documentation so there is no blame by me Eric> on that point, just observation. I am largely responsible for lack of clarity in the documentation. The criticism above is something I am all too aware of. train-by-telepathy is a good description :-) Eric> In any case, this gestalt has driven me to the point of Eric> admitting failure. I've surveyed a fair number of template/CGI Eric> tools and I think albatross is one of the better overall and has Eric> the best potential for being small and really Eric> effective. However, I have been unable to learn enough to do I Eric> need to do and I cannot ask any more from the community. You Eric> have been more than generous with your time already and for that Eric> I am grateful. It is responses like this that tell us where our weaknesses are. We need at more small examples that are carefully explained. I raised this with Andrew a week or so ago and asked if he thought we should remove the popview example. He said that the popview example was good because it actually did something real. Eric> on the documentation front, take a look at CherryPY and pso. Eric> while I'm not happy with either of them for different reasons, Eric> they both have good documentation teaching people how to use Eric> their system. I will have a look. Thanks for the tip. Eric> If you can accept a suggestion, I would suggest creating an very Eric> simple user-friendly layer. It would reflect the simple nature Eric> of CGI environment. It would consist of a couple of Eric> functions/methods. The first would be used for generating Eric> output. It would associate a dictionary with an albatross HTML Eric> template. The keys of the dictionary would map to variable Eric> names in the template. The matching value to a given key would Eric> be substituted into the variables. Obviously, nested lists, Eric> dictionaries etc. would be permitted so that for loops etc. in Eric> the templates could be used. Eric> the second function would extract information back from CGI Eric> forms. I haven't thought long on the form it would take but I Eric> suspect it would also be some form of dictionary based structure Eric> based on an albatross HTML template. Eric> obviously these ideas aren't fully formed but they are a Eric> reflection of my confidence that that the whole process can be Eric> simplified even further than it has been to date. I also Eric> believe it should be possible to create a layer over the current Eric> albatross API to generate this kind of simple interface. Albatross is supposed to eliminate the need for most of what you describe above. Maybe that should be made much clearer in the documentation (along with some examples showing why). - Dave -- http://www.object-craft.com.au From andrewm at object-craft.com.au Tue Jul 1 11:35:41 2003 From: andrewm at object-craft.com.au (Andrew McNamara) Date: Tue, 01 Jul 2003 21:35:41 +1000 Subject: [albatross-users] @#*(&$@!! Waste of a day... :( In-Reply-To: Message from "Cameron Blackwood" of "Tue, 01 Jul 2003 18:43:07 +1000." <200307010843.h618h7K17558@firewall.darkqueen.org> References: <200307010843.h618h7K17558@firewall.darkqueen.org> Message-ID: <20030701113541.1BCE13C332@coffee.object-craft.com.au> >http://www.object-craft.com.au/projects/albatross/albatross/inst-pre.html > >Says: > "2.1 Prerequisites > > * Python 2.1 or later." > >But... > > >cgiapp.py:26 reads: > > if isinstance(field, list): > > >Which breaks on list.... Damn. And that's not the only one. The booleans True and False are also missing, and there's also another test failure that I haven't looked into yet. The fixes are easy enough - I guess that's what a -pre is for (although I thought we'd tested against 2.1 - 1.5.2 was the target up until this version). Sorry for wasting your time. -- Andrew McNamara, Senior Developer, Object Craft http://www.object-craft.com.au/ From djc at object-craft.com.au Tue Jul 1 11:39:27 2003 From: djc at object-craft.com.au (Dave Cole) Date: 01 Jul 2003 21:39:27 +1000 Subject: [albatross-users] al-input type="image": internal bug/obscured traceback?? In-Reply-To: <200307010542.h615g5N15836@firewall.darkqueen.org> References: <200307010542.h615g5N15836@firewall.darkqueen.org> Message-ID: > but when I click on the image, I get: > ----------- vv ----------- > Template traceback (most recent call last): > > Traceback (most recent call last): > File "/usr/lib/python2.1/site-packages/albatross/app.py", line 221, in run > self.merge_request(ctx) > File "/usr/lib/python2.1/site-packages/albatross/app.py", line 301, in merge_request > ctx.merge_request() > File "/usr/lib/python2.1/site-packages/albatross/context.py", line 279, in merge_request > text = self.request.field_value('__albform__') > File "/usr/lib/python2.1/site-packages/albatross/cgiapp.py", line 26, in field_value > if isinstance(field, list): > TypeError: isinstance() arg 2 must be a class or type > ----------- ^^ ----------- > > Which doesnt look like it's in my code at all. :-/ (or if it is, how > to I get a real traceback or some more useful feedback?) > > > Infact clicking on the submit button also generates the above error. > Hmmm? > > Its probably a problem in my actual code, but it's kinda hard to find > it with the above traceback (which makes it look like an albatross > internal problem). ?? As you quite rightly point out in a subsequent message this is a problem in Albatross. Looks like a 2.2ism sneaked in there. Andrew and I discussed which level of Python we should target now that 1.5.2 is a distant memory and we settled on 2.1. We need to fix this for the 1.10pre2 release that I hope to get out before the end of the week. If the 1.10pre2 goes well we will rerelease it as 1.10 and announce it outside of this list. - Dave -- http://www.object-craft.com.au From matt at pollenation.net Tue Jul 1 11:51:24 2003 From: matt at pollenation.net (Matt Goodall) Date: Tue, 01 Jul 2003 12:51:24 +0100 Subject: example code (was Re: [albatross-users] Re: Albatross-users digest, Vol 1 #177 - 13 msgs) In-Reply-To: <200307011123.h61BN2w19204@firewall.darkqueen.org> References: <200307011123.h61BN2w19204@firewall.darkqueen.org> Message-ID: <3F0175BC.7040102@pollenation.net> Cameron Blackwood wrote: >Actually, one thing that I think Albatross __REALLY__ __REALLY__ needs >are some simple example/skeleton code fragments. Maybe this should be >a list effort, not something we all wait for object-craft.com.au to >do. > I would be more than happy to help out with this. I also think that HOWTOs and an FAQ (built from posts to the mailing list) would be really useful. A wiki seems like a good place for this sort of documentation as the list memers could then contribute too ... leaving Dave time to update the official documentation ;-). Dave, Andrew - any chance of getting a public wiki on the object craft web server? - Matt -- Matt Goodall, Pollenation Internet Ltd e: matt@pollenationinternet.com From djc at object-craft.com.au Tue Jul 1 11:46:27 2003 From: djc at object-craft.com.au (Dave Cole) Date: 01 Jul 2003 21:46:27 +1000 Subject: example code (was Re: [albatross-users] Re: Albatross-users digest, Vol 1 #177 - 13 msgs) In-Reply-To: <3F0175BC.7040102@pollenation.net> References: <200307011123.h61BN2w19204@firewall.darkqueen.org> <3F0175BC.7040102@pollenation.net> Message-ID: >>>>> "Matt" == Matt Goodall writes: Matt> Cameron Blackwood wrote: >> Actually, one thing that I think Albatross __REALLY__ __REALLY__ >> needs are some simple example/skeleton code fragments. Maybe this >> should be a list effort, not something we all wait for >> object-craft.com.au to do. >> Matt> I would be more than happy to help out with this. I also think Matt> that HOWTOs and an FAQ (built from posts to the mailing list) Matt> would be really useful. A wiki seems like a good place for this Matt> sort of documentation as the list memers could then contribute Matt> too ... leaving Dave time to update the official documentation Matt> ;-). Matt> Dave, Andrew - any chance of getting a public wiki on the object Matt> craft web server? I think that is an excellent idea. Why didn't we think of that... - Dave -- http://www.object-craft.com.au From esj at harvee.org Tue Jul 1 12:34:58 2003 From: esj at harvee.org (Eric S. Johansson) Date: Tue, 01 Jul 2003 08:34:58 -0400 Subject: example code (was Re: [albatross-users] Re: Albatross-users digest, Vol 1 #177 - 13 msgs) In-Reply-To: References: <200307011123.h61BN2w19204@firewall.darkqueen.org> <3F0175BC.7040102@pollenation.net> Message-ID: <3F017FF2.5020806@harvee.org> Dave Cole wrote: >>>>>>"Matt" == Matt Goodall writes: > > > Matt> Cameron Blackwood wrote: > >>>Actually, one thing that I think Albatross __REALLY__ __REALLY__ >>>needs are some simple example/skeleton code fragments. Maybe this >>>should be a list effort, not something we all wait for >>>object-craft.com.au to do. >>> > > Matt> I would be more than happy to help out with this. I also think > Matt> that HOWTOs and an FAQ (built from posts to the mailing list) > Matt> would be really useful. A wiki seems like a good place for this > Matt> sort of documentation as the list memers could then contribute > Matt> too ... leaving Dave time to update the official documentation > Matt> ;-). > > Matt> Dave, Andrew - any chance of getting a public wiki on the object > Matt> craft web server? > > I think that is an excellent idea. Why didn't we think of that... having acquired a fair degree of scar tissue in this area over the past year, go for simple (install, use) and try to find something with a revision history capability in case you get the occasional fine witted moron who decides to pee in the public pool. I believe the current version of moinmoin satisfies this requirement. I've used twiki and while it is simple to use, its registration requirements for users, configuration, and set up complexity reveal its perlish nature. ---eric From djc at object-craft.com.au Tue Jul 1 13:22:52 2003 From: djc at object-craft.com.au (Dave Cole) Date: 01 Jul 2003 23:22:52 +1000 Subject: example code (was Re: [albatross-users] Re: Albatross-users digest, Vol 1 #177 - 13 msgs) In-Reply-To: <3F017FF2.5020806@harvee.org> References: <200307011123.h61BN2w19204@firewall.darkqueen.org> <3F0175BC.7040102@pollenation.net> <3F017FF2.5020806@harvee.org> Message-ID: >>>>> "Eric" == Eric S Johansson writes: >> I think that is an excellent idea. Why didn't we think of that... Eric> having acquired a fair degree of scar tissue in this area over Eric> the past year, go for simple (install, use) and try to find Eric> something with a revision history capability in case you get the Eric> occasional fine witted moron who decides to pee in the public Eric> pool. Eric> I believe the current version of moinmoin satisfies this Eric> requirement. I've used twiki and while it is simple to use, its Eric> registration requirements for users, configuration, and set up Eric> complexity reveal its perlish nature. OK. I have a pristine wiki up at the following URL: http://www.object-craft.com.au/projects/albatross/wiki Go for it. I suppose the best thing that Andrew and I can do is stand well back. Maybe we should restrict ourselves to adding clarification and corrections when they are necessary. - Dave -- http://www.object-craft.com.au From matt at pollenation.net Tue Jul 1 15:03:41 2003 From: matt at pollenation.net (Matt Goodall) Date: Tue, 01 Jul 2003 16:03:41 +0100 Subject: example code (was Re: [albatross-users] Re: Albatross-users digest, Vol 1 #177 - 13 msgs) In-Reply-To: References: <200307011123.h61BN2w19204@firewall.darkqueen.org> <3F0175BC.7040102@pollenation.net> <3F017FF2.5020806@harvee.org> Message-ID: <3F01A2CD.4040402@pollenation.net> Do we want to come up with a top-level "menu"? Perhaps HowTo, FrequentlyAskedQuestions, CaseStudies, Comments, Gotchas aka CommonMistakes, ExampleCode, HintsAndTips etc. Perhaps someone knows a similar wiki that they find well structured that we could use as a model? ... or shall we just see what happens? Cheers, Matt Dave Cole wrote: >OK. I have a pristine wiki up at the following URL: > > http://www.object-craft.com.au/projects/albatross/wiki > >Go for it. I suppose the best thing that Andrew and I can do is stand >well back. Maybe we should restrict ourselves to adding clarification >and corrections when they are necessary. > >- Dave > > > -- Matt Goodall, Pollenation Internet Ltd e: matt@pollenationinternet.com t: 0113 2252500 From tchur at optushome.com.au Tue Jul 1 15:41:05 2003 From: tchur at optushome.com.au (Tim Churches) Date: 02 Jul 2003 01:41:05 +1000 Subject: [albatross-users] Re: Albatross-users digest, Vol 1 #176 - 14 msgs In-Reply-To: References: <200307010109.h6119m713416@firewall.darkqueen.org> <3F00F6ED.5050009@harvee.org> Message-ID: <1057074065.1169.12.camel@emilio> --=-pqyBVPd5zMmGwy36rsLh Content-Type: text/plain Content-Transfer-Encoding: quoted-printable On Tue, 2003-07-01 at 21:34, Dave Cole wrote: > It is responses like this that tell us where our weaknesses are. We > need at more small examples that are carefully explained. I raised > this with Andrew a week or so ago and asked if he thought we should > remove the popview example. He said that the popview example was good > because it actually did something real. I think that Albatross needs an explicit pattern library, in the documentation if possible (or perhaps patterns can be migrataed from the wiki into the documentation with each new release) - like the Python Cookbook edited by Alex Martelli, which is very, very useful. The manual is a bit too phenomenological at the moment: here is a tag, here is a context, here is a hippopotamus - but not enough examples of how they relate to one another when solving real-life problems. Such examples are essential for developing the gestalt to which Eric refers. These patterns need to go from the basic through to the more complex. I also think that things like popview are useful in order to demonstrate what's possible to people who are assessing Albatross - but that these examples should (also) be hosted directly on an Object Craft Web site so they don't need to install Albatross to try them out. --=20 Tim C PGP/GnuPG Key 1024D/EAF993D0 available from keyservers everywhere or at http://members.optushome.com.au/tchur/pubkey.asc Key fingerprint =3D 8C22 BF76 33BA B3B5 1D5B EB37 7891 46A9 EAF9 93D0 --=-pqyBVPd5zMmGwy36rsLh Content-Type: application/pgp-signature; name=signature.asc Content-Description: This is a digitally signed message part -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.0.7 (GNU/Linux) iD8DBQA/AauReJFGqer5k9ARAnYdAKCNPM0sq7But3UkXBriYcikH7LRdgCeM2+T Rjn+AnSxJuHXJL7XGGdzvus= =GXpm -----END PGP SIGNATURE----- --=-pqyBVPd5zMmGwy36rsLh-- From neel at mediapulse.com Tue Jul 1 15:44:24 2003 From: neel at mediapulse.com (Michael C. Neel) Date: Tue, 1 Jul 2003 11:44:24 -0400 Subject: [albatross-users] @#*(&$@!! Waste of a day... :( Message-ID: As a tip, I've always done: if type([]) =3D=3D type(mylist) to avoid these version change problems. not sure if that would help in this case. Mike ------------------- Python 2.1.1 (#1, Aug 30 2001, 17:36:05) [GCC 2.96 20000731 (Mandrake Linux 8.1 2.96-0.61mdk)] on linux-i386 Type "copyright", "credits" or "license" for more information. >>> type(list) because a function isnt the same as: Python 2.2.2 (#2, Feb 5 2003, 10:40:08) [GCC 3.2.1 (Mandrake Linux 9.1 3.2.1-5mdk)] on linux-i386 Type "help", "copyright", "credits" or "license" for more information. >>> type(list) From tchur at optushome.com.au Tue Jul 1 15:45:28 2003 From: tchur at optushome.com.au (Tim Churches) Date: 02 Jul 2003 01:45:28 +1000 Subject: [albatross-users] Re: Albatross-users digest, Vol 1 #176 - 14 msgs In-Reply-To: References: <200307010109.h6119m713416@firewall.darkqueen.org> Message-ID: <1057074328.1169.16.camel@emilio> --=-ENvrPnEy05Cg7DJtKpMo Content-Type: text/plain Content-Transfer-Encoding: quoted-printable On Tue, 2003-07-01 at 21:26, Dave Cole wrote: > Ben (another guy here) says (paraphrased) that when speaking a > (spoken) language you strive to speak like a native, or without an > accent. The same should apply to programming languages. If you > follow the BDFL you are less likely to code Python with an accent. Or rather, to code Python with the intended Dutch accent... > The application and execution context cooperate to deal with the > session. The execution context is where the session data is created > manipulated, but the application is usually responsible to loading > and saving the session. This allows the application to maintain a > long lived connection with a server if necessary. Remember that an > execution context lives only long enough to process a single browser > request. That para should be near the front of the manual if it isn't already. --=20 Tim C PGP/GnuPG Key 1024D/EAF993D0 available from keyservers everywhere or at http://members.optushome.com.au/tchur/pubkey.asc Key fingerprint =3D 8C22 BF76 33BA B3B5 1D5B EB37 7891 46A9 EAF9 93D0 --=-ENvrPnEy05Cg7DJtKpMo Content-Type: application/pgp-signature; name=signature.asc Content-Description: This is a digitally signed message part -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.0.7 (GNU/Linux) iD8DBQA/AayYeJFGqer5k9ARArNRAJ98VQkv2ziNzRCYgfuchfdwvgWI4gCfSKqw jc37IlGaZdqngU/wkpYaGJI= =ek4z -----END PGP SIGNATURE----- --=-ENvrPnEy05Cg7DJtKpMo-- From neel at mediapulse.com Tue Jul 1 16:13:06 2003 From: neel at mediapulse.com (Michael C. Neel) Date: Tue, 1 Jul 2003 12:13:06 -0400 Subject: [albatross-users] Renaming application and execution context classes Message-ID: I think there is something too this. Add to what you have below a top level albatross function that returns the **kw you need, taking one argument and doing a preset of classes. So you could write: app =3D albatross.App(albatross.AppBase, albatross.PickleSignMixin, albatross.Application, albatross.CachingTemplateLoaderMixin, albatross.PageModuleMixin, albatross.SessionServerAppMixin) - or - app =3D albatross.App(albatross.init_app(albatross.SERVER)) - and even could do - initapp =3D albatross.init_app(albatross.SERVER) initapp.pagemodule =3D RandomPageModuleMixin app =3D =3D albatross.App(initapp) and yes, this comes from my win32 days =3Dp long live h_wnd! Thanks, Mike -----Original Message----- From: Dave Cole [mailto:djc@object-craft.com.au]=20 Sent: Tuesday, July 01, 2003 7:08 AM To: Michael C. Neel Cc: albatross-users; korg@darkqueen.org Subject: Re: [albatross-users] Renaming application and execution context classes > Is it possible to combine the classes into one (from the user's > point of view)? In an ideal world >=20 > app =3D albatross.App(blah, blah, session_store=3Dalbatross.FILE) >=20 > it what I'd like best. >=20 > As for StudyCaps I personally find them much more readable for class > names, and they point out "hey I'm a class not a function", and use > lowercase/_'s for var/function names. This also jives with (most) > the standard library, and I think it's more important to go along > with the norm than have your module be different. >=20 > I won't admit how long I used hungarian notation... Andrew and I thought about something like the above but could not come up with anything that was not extremely hacky and ugly. I like the idea of being able to control individual feature sets like that... In a sense Albatross is already like that though. If you look in at the bottom of albatross/app.py you can hopefully see what I mean. Take for instance the ModularSessionApp class: class ModularSessionApp(PickleSignMixin, Application, CachingTemplateLoaderMixin, PageModuleMixin, SessionServerAppMixin): def __init__(self, base_url, module_path, template_path, start_page, secret, session_appid, session_server =3D 'localhost', server_port =3D 34343, session_age =3D 1800): Application.__init__(self, base_url) PickleSignMixin.__init__(self, secret) CachingTemplateLoaderMixin.__init__(self, template_path) PageModuleMixin.__init__(self, module_path, start_page) SessionServerAppMixin.__init__(self, session_appid, session_server, server_port, session_age) def create_context(self): return SessionAppContext(self) If we did away with all of the prepackaged classes and changed the interface to all of the mixins to just accept **kw then the above could look like this: class ModularSessionApp(PickleSignMixin, Application, CachingTemplateLoaderMixin, PageModuleMixin, SessionServerAppMixin): def __init__(self, **kw): Application.__init__(self, **kw) PickleSignMixin.__init__(self, **kw) CachingTemplateLoaderMixin.__init__(self, **kw) PageModuleMixin.__init__(self, **kw) SessionServerAppMixin.__init__(self, **kw) In theory the create_context() method could be removed from the existing classes. App Class Context Class SimpleApp SimpleAppContext ModularApp SimpleAppContext RandomModularApp SimpleAppContext SimpleSessionApp SessionAppContext ModularSessionApp SessionAppContext RandomModularSessionApp SessionAppContext SimpleSessionFileApp SessionFileAppContext ModularSessionFileApp SessionFileAppContext RandomModularSessionFileApp SessionFileAppContext If we consider SimpleAppContext to be the default execution context for an application, then all application classes that inherit from SessionFileAppMixin create a SessionFileAppContext, while all that inherit from SessionServerAppMixin create SessionAppContext. Taking the above a little further we could probably allow you to do something like this: class MyApp(albatross.AppBase, albatross.PickleSignMixin, albatross.Application, albatross.CachingTemplateLoaderMixin, albatross.PageModuleMixin, albatross.SessionServerAppMixin): pass Then in Albatross we would define the AppBase class to be something like this: class AppBase: def __init__(self, **kw): for klass in self.__class__.__bases__: if klass !=3D AppBase: klass.__init__(self, **kw) All of this is of course untested :-) One big advantage to all of this is that it allows you to change application classes very easily. Going back to yet another suggestion by Cameron Blackwood: =20 http://www.object-craft.com.au/pipermail/albatross-users/2002-November/0 00166.html This would solve his problem in varying argument lists to application class constructors. - Dave --=20 http://www.object-craft.com.au From neel at mediapulse.com Tue Jul 1 17:29:38 2003 From: neel at mediapulse.com (Michael C. Neel) Date: Tue, 1 Jul 2003 13:29:38 -0400 Subject: [albatross-users] Re: Albatross-users digest, Vol 1 #177 - 13 msgs Message-ID: --------- Actually, one thing that I think Albatross __REALLY__ __REALLY__ needs are some simple example/skeleton code fragments. Maybe this should be a list effort, not something we all wait for object-craft.com.au to do. --------- I agree here, we can probably do this and keep off some burden. I have used albtross in 3 major live deployed appliactions now, and a few others that are more light weight. I even have our Sys Adm setup with some default files so when I say to setup a new site with Albatross, these are generic enough to get the site running and the templates being parsed so that the designers can begin to place in the design and pages. I'll try to get some time to make a mod_python/Albatross example, and post here when I have more. Mike From esj at harvee.org Tue Jul 1 19:40:58 2003 From: esj at harvee.org (Eric S. Johansson) Date: Tue, 01 Jul 2003 15:40:58 -0400 Subject: [albatross-users] cognitive speed bumps Message-ID: <3F01E3CA.5030404@harvee.org> Since a few folks have urged me to try and document where I missed with albatross, I figured I would start with my mental model of this process and go from there. Hopefully it will not be much of a mental goat trail. I also apologize for any speech recognition airs I've missed. It's sometimes quite difficult to catch what's wrong with something you've said by reading. Internally, I've partitioned the problem of Web programming into a few events: * initial setup * page creation based on "current known values" * retrieval of form data and translation into a set of "current known values" In the traditional CGI environment, the order seems to be retrieval of form data, detection of initial conditions leading to initial set up, then creation of "current known values" followed by page creation and display. It's not very intuitive but it is logical once you understand the underlying mechanisms of the CGI environment. However when you introduce a tool to separate presentation information from generation of data, that model changes. My expectation has been somewhat to very different from what the various tools smiths have generated. This is no surprise but merely reflects the wide range of mental models folks have for this process. In my expectation, I was picturing templates as named entities which could be operated upon by some engine. The engine would be supplied a template and a set of named data elements. The engine would then apply the value for each named data element to each occurrence of the name within the template. The end result of the engines work would be copied/transferred to either an aggregation object or storage until all of the components were operated on and ready for display. Originally I envisioned that the presentation control flow would be part of an object encapsulating their representation of a web page. Unfortunately, that becomes rather messy and I can see the wisdom of how albatross put the presentation control flow into the HTML template itself. Data representation on both sides of the fence (CGI, template) should be normal python data types such as strings, integers, floats and, objects. Objects are especially important because it may be convenient for an application to encapsulate all the data either as methods or instance variables. In any case, it should be possible to run the object and retrieve the appropriate data. on retrieving data from forms, I think of the data as being logically associated by name or by type. But what should be most important is that *all* of the data should be available and that user filters can be applied to reduce or refine the data. the only improvement one could make over the dictionary method of presenting data ala cgi.fieldstorage would be if one could logically group the data in the form and have a standard tool/method to retrieve just that named set of data and place it in a dictionary like structure. Yes, I like dictionaries and I like even better the ability to use __get/setitem__ and related methods to create data transformations. Now, having explained (hopefully) where my mental model was at, I banged my shins rather badly on the attribute based model of albatross. One failing of the documentation is a complete description of the data model used for bridging between CGI and template. When it comes right down to it it doesn't matter a piss hole in the snow what model you use as long as it is flexible and documented in a way a novice can understand. Once you know what you have to connect to, you can create impedance matching code to translate between your object models and the template system object models. One test for how good the system is comes from the ability to wiggle every little widget or knob through a variety of techniques ranging from static data assignment through more dynamic data sources such as dictionaries or method generated data sets without requiring the user to learn more than a few interfaces. One could argue that the bridge interface between data and templates should be the same for all levels of data complexity. another place I tripped on regarding albatross was the discovery that I could not get all of the checkbox data (on and off) back from albatross environment without going through a significant amount of convolution which I was willing to do but was unsuccessful at getting it to work. minor points were some of the techniques for determining if a button had been pressed or the value of a field by dynamic name. I'm still not sure the best way to handle hidden variables or should I use state preservation techniques? I'm sure there is a whole list of techniques we could document for various frequently needed circumstances but the question one should always consider is that if you are building a large list of tricks, are you solving the problem the wrong way? Good design doesn't need tricks to do the right job. It should follow naturally from the architecture. It may be necessary to train everyone on the new architecture especially if it is based on a very different set of techniques from the normal world of experience. But it should be simple to convey and easy to learn enough to get started quickly and still support the developer ability to master more complex techniques as the complexity of the task rises. ---eric From matt at pollenation.net Tue Jul 1 20:01:53 2003 From: matt at pollenation.net (Matt Goodall) Date: 01 Jul 2003 21:01:53 +0100 Subject: [albatross-users] A great use for the simple http server Message-ID: <1057089713.26359.13.camel@localhost> Hi, I'm not trying to blow my own trumpet, but the simple http server I wrote and posted in this list would make running the sample apps *much* easier to run. For instance, running the popview5 example would be a matter of changing to the directory and running "al-httd popview.App 8000". No installation necessary and no need to change base_url, template_path etc. Cheers, Matt -- Matt Goodall, Pollenation Internet Ltd w: http://www.pollenation.net e: matt@pollenation.net From matt at pollenation.net Tue Jul 1 20:55:55 2003 From: matt at pollenation.net (Matt Goodall) Date: 01 Jul 2003 21:55:55 +0100 Subject: [albatross-users] First post! Message-ID: <1057092954.32426.54.camel@localhost> Oh, this isn't /. then? ;-) I suggested the Wiki so it's only fair that I get the ball rolling. There is now a hello world example on the wiki. Yeah I know, it's a completely useless application but it's a start and it's something to cut and paste to get going with. One thing that I think could be useful is to add to the RequestsForContent page. I tend to lose things in the noise of the mailing list so that page could be a todo list for people to pick items from later when they have more time or more knowledge. Dave/Andrew - could you enable the "Mail me my account data" option in MoinMoin please so that I can get my id wherever I am. Thanks. Cheers, Matt -- Matt Goodall, Pollenation Internet Ltd w: http://www.pollenation.net e: matt@pollenation.net t: 0113 2252500 From esj at harvee.org Tue Jul 1 21:34:20 2003 From: esj at harvee.org (Eric S. Johansson) Date: Tue, 01 Jul 2003 17:34:20 -0400 Subject: [albatross-users] Re: Albatross-users digest, Vol 1 #176 - 14 msgs In-Reply-To: <3F015656.2040606@pollenation.net> References: <200307010109.h6119m713416@firewall.darkqueen.org> <3F00F6ED.5050009@harvee.org> <3F015656.2040606@pollenation.net> Message-ID: <3F01FE5C.4040400@harvee.org> Matt Goodall wrote: > Hi Eric, > > I realise you have posted quite a bit to the list recently (which is > definitely not a problem!) and got some answers but could you quickly > and clearly summarize the problems you are still facing with Albatross. > Perhaps we could then address each issue again and see if we can help you. > > Cheers, Matt > thank you Matt, if the rest of you folks can take another long-winded description, here's a big chunk of the problem I'm trying to code up. If you go to: harvee.org/cgi-bin/correct.cgi Login with username: albatross password: albatross you'll see what I'm trying reimplement. The reason for the reimplementation is that I will be doing something similar with the spam dumpster and I also need to create something totally unrelated which is the user configuration editing tool. by the way, don't worry about pushing on the buttons because I've filtered out any real action from albatross. The vast majority of the web page is quite simple. The "refresh display" link just refers to the CGI so that you can refresh the list of currently trapped spam below. The number of messages contained in the spamtrap is obviously dynamically created at p. construction time. The button "spam on top/bottom" is simultaneously state information and user information. I set the value of the button to display the sort order for the list. One of my first attempts at converting to albatross forced me to change the message and just set the text to spam on top/bottom and have the button become "click to reverse sorting". I then used a hidden variable to store the state sort of direction. I would like to figure out how to store the sort state direction information so that it would persist even though someone refreshes the display. On the top and bottom of the spamtrap display are to train buttons. We've gone around the barn a few times on the vocabulary for the buttons and I'm probably going to make it "process spamtrap" although there is a vocal minority that prefers "lather, rinse, repeat". Now we come to the messy part, the spamtrap display. This is what prompted my question about displaying two-dimensional data. Internally, I need to look at all messages in the spamtrap, read the messages, extract all fields and correct for errors created by spammers, sort the list, truncate to the display size, and build the display list. The easy forms of the display list are either tuples of all the display elements or dictionaries of the same. I've implemented an object model version but it's not significantly better than the straight iterative form. as you can see, each line consists of: * a checkbox which is checked or unchecked automatically * a background color set according to score * destination mailbox * from address * subject the subject field is also a link which takes you to another CGI which displays the contents of the message. This is useful when trying to evaluate whether or not a message truly is spam. You will also notice that as you check and uncheck each line, the color changes from yellow to red and back again. the last piece is the periodic refresh. it's a JavaScript clock that counts down and reloads the page. It's not perfect because tries to repost data from the last time a button was pressed. Obviously, I need to figure out what's the right way to do the refresh. Also, I would like to make the countdown time dynamic based on the users configuration at some point. as I said in my other piece, what has consistently tripped me up is the difference between the Python data model and the albatross data model. Bridging the gap is essential in enabling new users to be successful with albatross. ---eric From tchur at optushome.com.au Tue Jul 1 21:55:15 2003 From: tchur at optushome.com.au (Tim Churches) Date: 02 Jul 2003 07:55:15 +1000 Subject: [albatross-users] A great use for the simple http server In-Reply-To: <1057089713.26359.13.camel@localhost> References: <1057089713.26359.13.camel@localhost> Message-ID: <1057096515.1169.73.camel@emilio> --=-EJn+ORrGrvzYlipqR4Xq Content-Type: text/plain Content-Transfer-Encoding: quoted-printable On Wed, 2003-07-02 at 06:01, Matt Goodall wrote: > Hi, >=20 > I'm not trying to blow my own trumpet, but the simple http server I > wrote and posted in this list would make running the sample apps *much* > easier to run. >=20 > For instance, running the popview5 example would be a matter of changing > to the directory and running "al-httd popview.App 8000". No installation > necessary and no need to change base_url, template_path etc. I agree - and ease of trying out examples is paramount to hook new users. --=20 Tim C PGP/GnuPG Key 1024D/EAF993D0 available from keyservers everywhere or at http://members.optushome.com.au/tchur/pubkey.asc Key fingerprint =3D 8C22 BF76 33BA B3B5 1D5B EB37 7891 46A9 EAF9 93D0 --=-EJn+ORrGrvzYlipqR4Xq Content-Type: application/pgp-signature; name=signature.asc Content-Description: This is a digitally signed message part -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.0.7 (GNU/Linux) iD8DBQA/AgNDeJFGqer5k9ARAhwyAJ96JEn3nevEATpu8OF6ZQ+KXN37nwCfa6xs jOxv6x+u3PNkmc342w5sxVM= =4ZL1 -----END PGP SIGNATURE----- --=-EJn+ORrGrvzYlipqR4Xq-- From esj at harvee.org Tue Jul 1 22:45:30 2003 From: esj at harvee.org (Eric S. Johansson) Date: Tue, 01 Jul 2003 18:45:30 -0400 Subject: [albatross-users] impedance mismatch 1 Message-ID: <3F020F0A.9010907@harvee.org> I'm reading the documentation and here is my commentary based on where I feel I get that slack-jawed look on my face. http://www.object-craft.com.au/projects/albatross/albatross/tug-simple3.html section 3.3 "introducing albatross tags" after the body of code shown, there is a paragraph starting with "the following lines construct a sorted list..." The description of locals leaves me puzzled. Its behavior is counter to everything I have learned in Python to date. It's this magic data lint trap that doesn't behave like a class, a dictionary, a list or anything else I'm familiar with. But I guess I can sort of deal with the dissonance by just assuming that context.locals can magically absorb data and associate it with a statically supplied name. quite frankly, most of the discussion about local and global name spaces just goes in one ear and out the other because it just doesn't seem important to the problem on hand of figuring out how to transfer data from the local context to the template context. Now comes the templates and I get really confused. expr=name.value() brings an exclamation of wth?? to my lips. Why isn't it just name? what happened to the ctx.locals? Eventually I just shrug and figure it's for some hopefully documented reason. But the next line really brings wrinkles to my brow expr="environ[name.value()]" after all if name needs a .value() function why isn't it expr="environ[name.value()].value()" seriously grump inspiring. I think the rest of the explanation with separating out presentation logic and the use of the al-exec tag is pretty good. the only rough spot is comes with the description of the "locals" data lint trap. ---eric From matt at pollenation.net Wed Jul 2 00:18:57 2003 From: matt at pollenation.net (Matt Goodall) Date: 02 Jul 2003 01:18:57 +0100 Subject: [albatross-users] impedance mismatch 1 In-Reply-To: <3F020F0A.9010907@harvee.org> References: <3F020F0A.9010907@harvee.org> Message-ID: <1057105136.30064.125.camel@localhost> Oh boy, I hope I get this right. I **really** hope it helps and doesn't just confuse you more. See the comments below. Cheers, Matt On Tue, 2003-07-01 at 23:45, Eric S. Johansson wrote: > The description of locals leaves me puzzled. Its behavior is counter to > everything I have learned in Python to date. It's this magic data lint trap > that doesn't behave like a class, a dictionary, a list or anything else I'm > familiar with. OK, I think I understand what you mean about locals now and where your confusion comes from. locals is simply an empty class definition: class Vars: pass ... ctx.locals = Vars() Python allows you to set any attribute on any object at any time: v = Vars() v.my_name = 'Matt' This is perfectly valid and fairly normal in Python. After all, you don't have to define instance attributes, you just say "self.my_name = 'Matt'". This reminds me that I have a note in a text file somewhere that says something like, "could/should ctx.locals behave like a dictionary?". I think ctx.locals could be made to behave like a dictionary. An initial (untested) implementation of Vars to support this might be: class Vars: def __setitem__(self, name, value): setattr(self, name, value) def __getitem__(self, name): return getattr(self, name) etc That means you can treat a Vars instance as an object or a dictionary, depending on your preference: >>> v = Vars() >>> v.a = 'a' >>> v['b'] = 'b' >>> vars(v) {'a': 'a', 'b': 'b'} >>> v.a 'a' >>> v['a'] 'a' >>> v.b 'b' >>> v['b'] 'b' There are other methods that would need implementing for Vars to be truly dictionary-like but I'm sure you get the idea. Eric, would making ctx.locals behave like a dictionary help your understanding? Dave/Andrew, are there any technical reasons why this would not work? > > But I guess I can sort of deal with the dissonance by just assuming that > context.locals can magically absorb data and associate it with a statically > supplied name. Hopefully, it's not so magic now ;-). > > quite frankly, most of the discussion about local and global name spaces just > goes in one ear and out the other because it just doesn't seem important to the > problem on hand of figuring out how to transfer data from the local context to > the template context. I must admit, I need to find out about the global name space! > > Now comes the templates and I get really confused. > > expr=name.value() > > brings an exclamation of wth?? to my lips. Why isn't it just name? what > happened to the ctx.locals? Eventually I just shrug and figure it's for some > hopefully documented reason. But the next line really brings wrinkles to my brow > > expr="environ[name.value()]" > > after all if name needs a .value() function why isn't it > > expr="environ[name.value()].value()" > > seriously grump inspiring. OK, here goes ... What happened to the ctx.locals ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ In a template the scope *is* ctx.locals, i.e. any reference to a variable called 'my_name' actually means ctx.locals.my_name. You publish object for the template by storing them in ctx.locals. Earlier, you talked about the need to "associate a dictionary with an albatross HTML template"; that's what ctx.locals does. expr="name.value()" ... Why isn't it just name? ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Here's the important bit in the documentation from section 5.3.7, http://www.object-craft.com.au/projects/albatross/albatross/tag-for.html. "The tag uses an instance of the ListIterator identified in the local namespace by the iter attribute to iterate over the sequence defined by the expression in the expr attribute." If you look at ListIterator's methods it will probably make more sense now. It is ListIterator that makes the paging possible and the index() can be used for things like colouring alternate rows, i.e. "name.index()%2 and 'red' or 'green'". By the way, Dave has only just updated this bit of documentation based on feedback on the list so don't feel bad about missing the importance of ListIterator. It was documented but it was not as clear as it could have been. why isn't it environ[name.value()].value() ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ So, why isn't the .value() needed on the end? Hopefully you now understand that: * "name" is a ListIterator created by the tag to iterate over the items in "keys" * "name.value()" is the current item from "keys" * "environ" when inside the template refers to the same dictionary as "ctx.locals.environ" in the python code. So all "environ[name.value()]" is actually doing is getting the value of the item in environ that has a key name.value(). The tag has no need to create anything like the ListIterator as all it does is print some text to the page. -- Matt Goodall, Pollenation Internet Ltd w: http://www.pollenation.net e: matt@pollenation.net From gnb at itga.com.au Wed Jul 2 00:44:13 2003 From: gnb at itga.com.au (Gregory Bond) Date: Wed, 02 Jul 2003 10:44:13 +1000 Subject: [albatross-users] impedance mismatch 1 In-Reply-To: Your message of 02 Jul 2003 01:18:57 +0100. Message-ID: <200307020044.KAA27327@lightning.itga.com.au> One wrinkle on all this: > * "environ" when inside the template refers to the same dictionary > as "ctx.locals.environ" in the python code. ... and if ctx.locals.environ doesn't exist, then it looks for environ in the global context of the _page display function_. So you can do something like: ---- my_heading = 'Super Application' class StartPage: # ... def page_display(self, ctx): ctx.run_template('start.ht') ---- then, inside start.ht, something like

and it will work. But the trick is it uses the global namespace of the function that calls run_template(). If you use page modules, it has to be in the page module. If you do what I do and have a library with a base class for Albatross pages that has a run_template function, then you will get the global namespace of the library module, not the application, unless you override the page_display in your concrete page class. (Which is probably as clear as mud....) From matt at pollenation.net Wed Jul 2 00:54:35 2003 From: matt at pollenation.net (Matt Goodall) Date: 02 Jul 2003 01:54:35 +0100 Subject: [albatross-users] impedance mismatch 1 In-Reply-To: <200307020044.KAA27327@lightning.itga.com.au> References: <200307020044.KAA27327@lightning.itga.com.au> Message-ID: <1057107274.11964.2.camel@localhost> Thanks for that correction! Now I understand globals as well :) On Wed, 2003-07-02 at 01:44, Gregory Bond wrote: > One wrinkle on all this: > > > * "environ" when inside the template refers to the same dictionary > > as "ctx.locals.environ" in the python code. > > ... and if ctx.locals.environ doesn't exist, then it looks for environ in the > global context of the _page display function_. So you can do something like: > > ---- > my_heading = 'Super Application' > > class StartPage: > # ... > def page_display(self, ctx): > ctx.run_template('start.ht') > ---- > then, inside start.ht, something like >

> and it will work. > > But the trick is it uses the global namespace of the function that calls > run_template(). If you use page modules, it has to be in the page module. If > you do what I do and have a library with a base class for Albatross pages that > has a run_template function, then you will get the global namespace of the > library module, not the application, unless you override the page_display in > your concrete page class. > > (Which is probably as clear as mud....) > > > > _______________________________________________ > Albatross-users mailing list > Albatross-users@object-craft.com.au > https://www.object-craft.com.au/cgi-bin/mailman/listinfo/albatross-users -- Matt Goodall, Pollenation Internet Ltd w: http://www.pollenation.net e: matt@pollenation.net From sheila at thinkspot.net Wed Jul 2 03:57:46 2003 From: sheila at thinkspot.net (Sheila King) Date: Tue, 01 Jul 2003 20:57:46 -0700 Subject: [albatross-users] multiple session support Message-ID: <50112117.1057093066@SHEILA-LAPTOP> Hello, I got a question today from a team member, and I think the answer is "yes" but I just wanted to verify that with the list. The question was: "Multiple sessions/browser windows open is something to keep in mind. Does the Albatross framework allow multiple sessions for 1 account / from 1 computer?" At this point, I'm wondering exactly what he means by this? I can't find anything about multiple sessions in the albatross documentation and the closest I found in the mailing list archives is this: which isn't really exactly what he is asking about, but I think it touches on it. Does anyone have an idea what the purpose or desireability of multiple sessions for one account from one computer would be? And would it be possible to implement in Albatross? (The guy who asked is mostly a PHP and Perl programmer, so I'm not sure if that has anything to do with where he's coming from or not?) -- Sheila King http://www.thinkspot.net/sheila/ http://www.k12groups.org From esj at harvee.org Wed Jul 2 12:50:56 2003 From: esj at harvee.org (Eric S. Johansson) Date: Wed, 02 Jul 2003 08:50:56 -0400 Subject: [albatross-users] impedance mismatch 1 In-Reply-To: <1057107274.11964.2.camel@localhost> References: <200307020044.KAA27327@lightning.itga.com.au> <1057107274.11964.2.camel@localhost> Message-ID: <3F02D530.6060503@harvee.org> Matt Goodall wrote: ... > On Wed, 2003-07-02 at 01:44, Gregory Bond wrote: >.. fantastic explanations! This brings to mind a few things: 1) we now have the start of a wiki section called "puzzled about?" I'll try to take these explanations and put them into wiki pages so you can see what I mean. 2) I think the documentation should have a section called "fundamental concepts" in which it illustrates some of these fundamental bits of knowledge necessary to understand the environment. One picture, forming in my head, which may or may not be useful to anyone would show the relationship between python code space, context.locals, a template, and the final result. python code template end result . . . context.locals.xyzzy = "plugh" | +==> | +===> plugh and it might be useful to spell out these kind of transformations for all cases (or at least, many of them) It would not be necessary to document all "fundamental concepts" in one place. That would just overload the reader and not do anyone any good. It would probably be preferable to have a "fundamental constants" section before every example that introduces a new concept or concepts. ---eric From matt at pollenation.net Wed Jul 2 13:36:57 2003 From: matt at pollenation.net (Matt Goodall) Date: Wed, 02 Jul 2003 14:36:57 +0100 Subject: [albatross-users] impedance mismatch 1 In-Reply-To: <3F02D530.6060503@harvee.org> References: <200307020044.KAA27327@lightning.itga.com.au> <1057107274.11964.2.camel@localhost> <3F02D530.6060503@harvee.org> Message-ID: <3F02DFF9.9080809@pollenation.net> Glad it helped, does that largely clear things up for you know, at least in terms of how to use Albatross? I agree with your idea for the Wiki, anything to make Albatross more accessible would benefit the project and its users. Cheers, Matt -- Matt Goodall, Pollenation Internet Ltd e: matt@pollenationinternet.com From matt at pollenation.net Wed Jul 2 13:55:03 2003 From: matt at pollenation.net (Matt Goodall) Date: Wed, 02 Jul 2003 14:55:03 +0100 Subject: [albatross-users] multiple session support In-Reply-To: <50112117.1057093066@SHEILA-LAPTOP> References: <50112117.1057093066@SHEILA-LAPTOP> Message-ID: <3F02E437.4030100@pollenation.net> Does he mean multiple sessions or multiple browser windows sharing a single session? I'm not speaking from experience here but I cannot think of a reason why multiple windows with one session would be a problem for the server-side session management mixins ... that is, provided that any file system access is using locks. Multiple browser windows with a session per window would be possible using the client-side session management since all session data stays with a page. - Matt Sheila King wrote: >Hello, > >I got a question today from a team member, and I think the answer is "yes" >but I just wanted to verify that with the list. > >The question was: > >"Multiple sessions/browser windows open is something to keep in mind. Does >the Albatross framework allow multiple sessions for 1 account / from 1 >computer?" > >At this point, I'm wondering exactly what he means by this? > >I can't find anything about multiple sessions in the albatross >documentation and the closest I found in the mailing list archives is this: >l> > >which isn't really exactly what he is asking about, but I think it touches >on it. > >Does anyone have an idea what the purpose or desireability of multiple >sessions for one account from one computer would be? And would it be >possible to implement in Albatross? > >(The guy who asked is mostly a PHP and Perl programmer, so I'm not sure if >that has anything to do with where he's coming from or not?) > > > -- Matt Goodall, Pollenation Internet Ltd e: matt@pollenationinternet.com t: 0113 2252500 From neel at mediapulse.com Wed Jul 2 14:43:22 2003 From: neel at mediapulse.com (Michael C. Neel) Date: Wed, 2 Jul 2003 10:43:22 -0400 Subject: Whoa! What is this is I see? was RE: [albatross-users] impedance mismatch 1 Message-ID: Okay, one thing I miss that python doesn't have is the ?: operator. But then Matt writes: "name.index()%2 and 'red' or 'green'". Which from my quick tests in idle seem to be working like ?:; with the execption of: 1 and 0 or 2 returns 2 ( 1 ? 0 : 2 would return 0) Which I can see why and I could work around that with int(1 and '0' or 2) If I need a0 for a true value (rare case). So my question is, is this a hack of python, or can I always expect this to stay the same across past and new versions of python? It seems to work because python will return the last value in a true and statement; but with 2.2.1 adding bool() , True, and False I'm worried that at some point expressions will begin to return True or False as is seems like there is a movement to a true bool type (2.2.1+ still just maps True to 1; False to 0 is looks like). Mike From matt at pollenation.net Wed Jul 2 17:26:10 2003 From: matt at pollenation.net (Matt Goodall) Date: Wed, 02 Jul 2003 18:26:10 +0100 Subject: [albatross-users] impedance mismatch 1 In-Reply-To: References: Message-ID: <3F0315B2.9020100@pollenation.net> That's not really what I meant, I was thinking more about how ctx.locals is accessed in the Python code. It probably wasn't as clear as it could have been ... it was a long post and it was very late ;-). What I was actually suggesting was *adding* a dictionary-like interface to ctx.locals (a Vars instance) to allow something like this: def page_display(ctx): ctx.locals.first_name = 'Matt' ... or ... ctx.locals['first_name'] = 'Matt' ctx.run_template('template.html') It wouldn't change anything in the template, it would still be "". From what I've seen on the list people sometimes expect ctx.locals to be a dictionary and get confused when it turns out that it's just an object that stores attributes. I think that was the concept that was holding Eric back from true enlightenment. To be honest, I'm not sure it's a good idea anyway. For a start, it's more typing to use ctx.locals like a dictionary (all those quotes and square brackets ... yeuch!) but more importantly, if people start mixing styles it could make examples harder to understand. To support the dictionary interface completely would also clutter ctx.locals with unnecessary attributes such as "keys" which would break at least one of the examples in the documentation. It seems best just to document what ctx.locals is and why "ctx.local.first_name = 'Matt'" is allowed. Cheers, Matt Michael C. Neel wrote: >>This reminds me that I have a note in a text file somewhere that says >>something like, "could/should ctx.locals behave like a dictionary?". >> >> > >There is no need for this, you can just use the locals() method of >python (don't confuse ctx.locals with locals()) > >so, if you need a ctx.locals dict, do: > > > >locals() only will grab what is in the ctx.locals namespace. If you >want to see globals as a dict, use the python globals() method. > >so: > >import os > >class myform: > def page_display(self, ctx): > ctx.locals.myvar = "two" > ctx.run_template('index.html') > >---------------- > > > >With the .has_key() method of dicts, it's easy to have templates that >can deal with not having a value passed to them they may want to use. >This is really useful in making the same template handle both add and >edit a record. > >Mike > > -- Matt Goodall, Pollenation Internet Ltd e: matt@pollenationinternet.com From esj at harvee.org Wed Jul 2 17:16:50 2003 From: esj at harvee.org (Eric S. Johansson) Date: Wed, 02 Jul 2003 13:16:50 -0400 Subject: [albatross-users] impedance mismatch 1 In-Reply-To: <1057105136.30064.125.camel@localhost> References: <3F020F0A.9010907@harvee.org> <1057105136.30064.125.camel@localhost> Message-ID: <3F031382.7000408@harvee.org> Matt Goodall wrote: > Oh boy, I hope I get this right. I **really** hope it helps and doesn't > just confuse you more. See the comments below. http://www.object-craft.com.au/projects/albatross/wiki/PuzzledAboutBitsAndPieces you have clarified things and I've put some of it in the wiki. Let me know what you think and don't be afraid to change it. I'd do more except I really need to get some work done on some of my other projects (that will hopefully lead to revenue). > Python allows you to set any attribute on any object at any time: > > v = Vars() > v.my_name = 'Matt' > > This is perfectly valid and fairly normal in Python. After all, you > don't have to define instance attributes, you just say "self.my_name = > 'Matt'". Dawn breaks over Marblehead. In other words, folks use attributes on objects every single day thinking that they are class variables and treating them as such. this single concept I think was the biggest block in my mind. It deserves a prominent position in the documentation. > This reminds me that I have a note in a text file somewhere that says > something like, "could/should ctx.locals behave like a dictionary?". > ... > Eric, would making ctx.locals behave like a dictionary help your > understanding? Dave/Andrew, are there any technical reasons why this > would not work? this was my original conception of the context of the template environment but now I'm not so sure it's necessary. It might be nice to have a "convert dictionary to attributes feature but I need to think about that. >>But I guess I can sort of deal with the dissonance by just assuming that >>context.locals can magically absorb data and associate it with a statically >>supplied name. > > > Hopefully, it's not so magic now ;-). that's true it is not. However, I still think of it as a data lint trap... ;-) > > What happened to the ctx.locals > ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > In a template the scope *is* ctx.locals, i.e. any reference to a > variable called 'my_name' actually means ctx.locals.my_name. You publish > object for the template by storing them in ctx.locals. Earlier, you > talked about the need to "associate a dictionary with an albatross HTML > template"; that's what ctx.locals does. that's clear enough now. Again, this should be a fundamental concept near the beginning of the documentation. I believe I captured the essence in the wiki seriously, please check what I put into the wiki and make sure it isn't terribly wrong. I have unfortunately run out of time for this fun today. ---eric From esj at harvee.org Thu Jul 3 00:29:55 2003 From: esj at harvee.org (Eric S. Johansson) Date: Wed, 02 Jul 2003 20:29:55 -0400 Subject: [albatross-users] more data tricks for the wiki Message-ID: <3F037903.2040306@harvee.org> well, I fumbled along somemore and generated this little tidbit (telepathy bit turned on): Assume you have a collection of data that you want displayed on a web page. it really doesn't matter what the collection is for as long as it is a logical set of data extracted from a list of these sets by the statement. Usual usage patterns are will yield a statement like: where list is the list of sets and item is a single element from the list. If the individual item was a simple string, integer, or float them the value would be made accessible by the .value() method. The reason for this indirect method of data retrieval is that item is not what you put on the list in the first place. It is instead an object which contains one of the objects you put on to "list". However, in this circumstance the data contained in each element of "list" is more complicated. It can be a tuple, object, or even a list of lists. In this case, accessing the real data comes after .value() such as: item.value().status which would return the data on the field/attribute called status. While this form is okay for a couple of references, it quickly gets tedious. Instead, it's possible to reassign the value of item to another variable and then use that other variable as the base for referencing the various fields of the real object. In the example above, we extract the real object from item and then make accessible for ordinary use. From gnb at itga.com.au Thu Jul 3 01:37:15 2003 From: gnb at itga.com.au (Gregory Bond) Date: Thu, 03 Jul 2003 11:37:15 +1000 Subject: [albatross-users] impedance mismatch 1 In-Reply-To: Your message of Wed, 02 Jul 2003 13:16:50 -0400. Message-ID: <200307030137.LAA13842@lightning.itga.com.au> > Dawn breaks over Marblehead. In other words, folks use attributes on objects > every single day thinking that they are class variables and treating them as > such. this single concept I think was the biggest block in my mind. It > deserves a prominent position in the documentation. This isn't an Albatross thing, it's a Python thing(*). Getting you head around this one is a big step forward as a python hacker. For the sort of work I do, it's one of the best things about Python (compared to a strongly-typed language such as C++) - the ability to take existing objects and "decorate" them with new attributes without having to do silly things like keep parallel arrays or hash lookups or "(caddr_t)user_data" or whatever. Yes, you can be burned when the underlying object adds a "real" attribute with the same name, but the alternatives also break in ugly ways, too. I'm forever doing things like list = get_lots_of_orders() for o in list: o.is_local = o.deliver_country == 'aus' o.gst_payable = o.is_local and o.client_type != 'exempt' # Display the list, including an indicator of which are local, etc (*) or a smalltalk thing, or a perl thing -- basically, any dynamically-typed language. From matt at pollenation.net Thu Jul 3 01:40:38 2003 From: matt at pollenation.net (Matt Goodall) Date: 03 Jul 2003 02:40:38 +0100 Subject: [albatross-users] more data tricks for the wiki In-Reply-To: <3F037903.2040306@harvee.org> References: <3F037903.2040306@harvee.org> Message-ID: <1057195894.6022.32.camel@localhost> I have added a "Examples of using " item to RequestsForContent for now. If I had more time I would have added the whole thing ... work always gets in the way! I'm probably being a bit pedantic but ... Strictly speaking, ListIterator.value() *always* returns a reference to a list item, it never returns the value. The reason it appears that the value is being returned for a string, integer, float etc is that those objects know how to display themselves as text. Note that one of the 2.x Python releases changed even the basic types into objects so there is literally no difference between a string and a type you define using "class" these days. And while I'm being pedantic ;-) ... ListIterator contains a list, not a list item. It steps through the list when next() is called and returns a reference to the current item when value() is called. Cheers, Matt On Thu, 2003-07-03 at 01:29, Eric S. Johansson wrote: > well, I fumbled along somemore and generated this little tidbit (telepathy bit > turned on): > > Assume you have a collection of data that you want displayed on a web page. it > really doesn't matter what the collection is for as long as it is a logical set > of data extracted from a list of these sets by the statement. > > Usual usage patterns are will yield a statement like: > > > > where list is the list of sets and item is a single element from the list. If > the individual item was a simple string, integer, or float them the value would > be made accessible by the .value() method. The reason for this indirect method > of data retrieval is that item is not what you put on the list in the first > place. It is instead an object which contains one of the objects you put on to > "list". > > However, in this circumstance the data contained in each element of "list" is > more complicated. It can be a tuple, object, or even a list of lists. In this > case, accessing the real data comes after .value() such as: > > item.value().status > > which would return the data on the field/attribute called status. While this > form is okay for a couple of references, it quickly gets tedious. Instead, it's > possible to reassign the value of item to another variable and then use that > other variable as the base for referencing the various fields of the real object. > > > > > > > > In the example above, we extract the real object from item and then make > accessible for ordinary use. > > _______________________________________________ > Albatross-users mailing list > Albatross-users@object-craft.com.au > https://www.object-craft.com.au/cgi-bin/mailman/listinfo/albatross-users -- Matt Goodall, Pollenation Internet Ltd w: http://www.pollenation.net e: matt@pollenation.net t: 0113 2252500 From matt at pollenation.net Thu Jul 3 01:40:45 2003 From: matt at pollenation.net (Matt Goodall) Date: 03 Jul 2003 02:40:45 +0100 Subject: [albatross-users] New version of the standalone http server Message-ID: <1057196415.18669.41.camel@localhost> --=-Oi7PrhiCO8naASUJznCV Content-Type: text/plain Content-Transfer-Encoding: 7bit Hi all, Attached is an updated version of the standalone server with the following changes: * Fixed to support forms containing input fields with a "list" attribute. It only ever returned the first value in the get or post data before. * Added the current working directory to the path so that the httpd.py script can live anywhere. * changed the filename to al-httpd. An even better name might be al-simple-server. Cheers, Matt -- Matt Goodall, Pollenation Internet Ltd w: http://www.pollenation.net e: matt@pollenation.net --=-Oi7PrhiCO8naASUJznCV Content-Disposition: attachment; filename=al-httpd Content-Type: text/plain; name=al-httpd; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable #!/usr/bin/env python import BaseHTTPServer import cgi import os import sys from cStringIO import StringIO from urlparse import urlsplit class Request: """BaseHTTPServer request adaptor""" def __init__(self, req): self._req =3D req self._status =3D 200; self._fields =3D [] self.headers_out =3D {} self.data =3D StringIO() if self._req.command =3D=3D 'GET': self._fields =3D self.parse_get_fields() elif self._req.command =3D=3D 'POST': self._fields =3D self.parse_post_fields() else: pass def parse_get_fields(self): """Extract fields from query string""" qs =3D urlsplit(self._req.requestline.split()[1])[3] if not qs: return {} return cgi.parse_qs(qs) def parse_post_fields(self): """Extract fields from posted data""" fields =3D {} content_type =3D self._req.headers.get('content-type') if content_type: key, pdict =3D cgi.parse_header(content_type) if key =3D=3D 'application/x-www-form-urlencoded': cl =3D int(self._req.headers['content-length']) fields =3D cgi.parse_qs(self._req.rfile.read(cl), 1) elif key =3D=3D 'multipart/form-data': fields =3D cgi.parse_multipart(self.content, pdict) else: pass return fields def get_header(self, name): return self._req.headers.get(name) =20 def write_header(self, name, value): self.headers_out[name] =3D value def end_headers(self): pass def has_field(self, name): return self._fields.has_key(name) def field_value(self, name): =20 # Get the field field =3D self._fields[name] =20 # Field is always a list. If there is only one item in it then retu= rn # the item and let Albatross take care of input fields with the lis= t # attribute if len(field) =3D=3D 1: return field[0] else: return field def field_names(self): return self._fields.keys() def get_uri(self): serverName =3D self._req.server.server_name serverPort =3D self._req.server.server_port path =3D self._req.path uri =3D 'http://%s:%d%s' % (serverName, serverPort, path) return uri def get_servername(self): servername =3D self._req.server.server_name port =3D self._req.server.server_port return '%s:%d' % (servername, port) def write_content(self, data): self.data.write(data) def redirect(self, loc): self.write_header('Location', loc) self.write_header('Status', '301 Moved Permanently') self._status =3D 301 self.end_headers() def set_status(self, status): self._status =3D status def status(self): return self._status class RequestHandler(BaseHTTPServer.BaseHTTPRequestHandler): """ Handle HTTP request, routing them through to the Albatross application """ def do_GET(self): self.process_request() def do_POST(self): self.process_request() def process_request(self): self.log_request() req =3D Request(self) self.server.app.run(req) self.send_response(req.status()) for name, value in req.headers_out.items(): self.send_header(name, value) self.end_headers() if req.status() =3D=3D 200: self.wfile.write(req.data.getvalue()) class HTTPServer(BaseHTTPServer.HTTPServer): """Simple, standalone HTTP server for Albatross applications.""" def __init__(self, app, port): BaseHTTPServer.HTTPServer.__init__(self, ('', port), RequestHandler= ) self.app =3D app if __name__ =3D=3D '__main__': # Append the current working directory to the path sys.path.append(os.getcwd()) # Parse the command line appClass =3D sys.argv[1] port =3D int(sys.argv[2]) # Load the application's module and create an application instance module =3D __import__(appClass[:appClass.rindex('.')]) app =3D getattr(module,appClass[appClass.rindex('.')+1:])() # Create the HTTP server httpd =3D HTTPServer(app, port) # Handle requests httpd.serve_forever() --=-Oi7PrhiCO8naASUJznCV-- From gnb at itga.com.au Thu Jul 3 01:44:23 2003 From: gnb at itga.com.au (Gregory Bond) Date: Thu, 03 Jul 2003 11:44:23 +1000 Subject: [albatross-users] more data tricks for the wiki In-Reply-To: Your message of Wed, 02 Jul 2003 20:29:55 -0400. Message-ID: <200307030144.LAA14395@lightning.itga.com.au> > > > where list is the list of sets and item is a single element from the list. No, better to think of it as: item is a ListIterator object, item.value() is a (reference to a) single element from the list. Which implies "item" is not a great name for the iterator in an al-for loop! (And it is a real reference to the actual object, too, so you can do things like "item.value().use_count += 1" and it will do the Right Thing.) Personally, I don't find "i.value().field" to be much of a problem, but that may be because I grew up doing pointer arithmetic in C. From esj at harvee.org Thu Jul 3 02:06:12 2003 From: esj at harvee.org (Eric S. Johansson) Date: Wed, 02 Jul 2003 22:06:12 -0400 Subject: [albatross-users] more data tricks for the wiki In-Reply-To: <200307030144.LAA14395@lightning.itga.com.au> References: <200307030144.LAA14395@lightning.itga.com.au> Message-ID: <3F038F94.5040902@harvee.org> Gregory Bond wrote: > > >> >> >>where list is the list of sets and item is a single element from the list. > > > No, better to think of it as: item is a ListIterator object, item.value() is > a (reference to a) single element from the list. my question for you is: at what point does the distinction between ListIterator and a simple element created from the list contents confuse the user and enlighten the user. There is a point that the early learning phase where this is not important and in fact detracts from the user's ability to masterthe basics. There is some point later when it becomes important to have the concept of ListIterator firmly in one's mind. Can you define that boundary? > > Which implies "item" is not a great name for the iterator in an al-for loop! true. But what else works? It's a singleton containing your precious data and it is your challenge to rip your data out of its evil clutches and cast the empty ListIterator husk into the depths below. (I guess that shows my frame of mind) seriously, from the user's perspective "item" is just that. A single item. The user shouldn't have to care that it's an iterator when the surrounding structure looks like a simple for loop. if appearances are deceiving, the user will resent being deceived. > > (And it is a real reference to the actual object, too, so you can do things > like "item.value().use_count += 1" and it will do the Right Thing.) that's information for the advanced category of the documentation > > Personally, I don't find "i.value().field" to be much of a problem, but that > may be because I grew up doing pointer arithmetic in C. when I was programming in C, I would regularly create structures of pointers that would make the other programmers on the team whimper in fear. When c-front 1.2 was released and I got a chance to play with C++, I was able to understand the output of c-front well enough that I could tell the vendor what was wrong with the code generator and give them concrete examples to reproduce the bug. It's fun scary when you get to be on a first name basis with the development team... in my dotage, I have come to appreciate simplicity. anything.value().something is not simple. :-) so tomorrow, I will take your advice as well as others and try to rework my example. By the way, commentary on what is already in the wiki is also important. ---eric From djc at object-craft.com.au Thu Jul 3 02:44:13 2003 From: djc at object-craft.com.au (Dave Cole) Date: 03 Jul 2003 12:44:13 +1000 Subject: [albatross-users] First post! In-Reply-To: <1057092954.32426.54.camel@localhost> References: <1057092954.32426.54.camel@localhost> Message-ID: >>>>> "Matt" == Matt Goodall writes: Matt> Oh, this isn't /. then? ;-) I suggested the Wiki so it's only Matt> fair that I get the ball rolling. There is now a hello world Matt> example on the wiki. Yeah I know, it's a completely useless Matt> application but it's a start and it's something to cut and paste Matt> to get going with. Matt> One thing that I think could be useful is to add to the Matt> RequestsForContent page. I tend to lose things in the noise of Matt> the mailing list so that page could be a todo list for people to Matt> pick items from later when they have more time or more Matt> knowledge. Matt> Dave/Andrew - could you enable the "Mail me my account data" Matt> option in MoinMoin please so that I can get my id wherever I Matt> am. Thanks. Sorry, was out of office yesterday and our ISP had some routing problems last night... I have set up the mail options now. - Dave -- http://www.object-craft.com.au From korg at darkqueen.org Thu Jul 3 03:50:32 2003 From: korg at darkqueen.org (Cameron Blackwood) Date: Thu, 03 Jul 2003 13:50:32 +1000 Subject: [albatross-users] Comments on using examples... Message-ID: <200307030350.h633oWc06073@firewall.darkqueen.org> I dont know about other people, but when I see an example in docs, I often like to actually: 1) try it myself 2) modify it 3) use it as a base for what I really want to do Eg: www.object-craft.com.au/projects/albatross/albatross/tag-comment.html trying it: Hands up anyone who has used albatross in interactive mode? Interactive python dumps are not much use because: 1) noone would ever do that 2) you cant cut & paste to test (well you can, but you have to cut and paste specific bits (not the output) and you cant cut and paste the multi-line examples, thanks to the pythonic '... '/'>>> ', without having to be _VERY_ careful about indenting.) 3) if I find what I need, then I need to translate it into a SimpleApp (or whatever) to actually use it (Thus, shouldnt it be a SimpleApp example to start with?) clarity: Actually I just noticed that there is no output for that example. In that case, shouldnt the example be ... this will is here ... ... this isnt... ... ... and so is this. The comment should be one of the easiest examples. I think Id much rather (for the simple examples) see something like: 'I would never do anything ' renders to 'I would never do anything bad ' Two lines.. excellent, I understanded al-owned now. Using a non silly example, which is more helpful than the listed comment example: 'pre middle post' renders to: 'pre post' This example illustrates what happens with pre and post and also spacing. So, what about: 'pre \nmid\ndle\n post\nend\n' 'pre mid\ndle\n post\nend\n' Would you rather an 8 line intereactive dump or just the two lines: 'pre\npost' 'pre post' I mean you could even use html underline on the characters that arnt stripped out, just to make it even clearer. And the complex examples? I'd probably rather actual files that I can download, install and run. That way I can modify them and play! Eg: www.object-craft.com.au/projects/albatross/albatross/tug-form2.html Who does import 'cgi' with albatross code? I dont. (Should I?) I guess Im trying to ask who actually codes like that? Neat. 'setattr(ctx.locals, name, value)'. Especially now we all understand ctx.locals :). Eg: www.object-craft.com.au/projects/albatross/albatross/tug-form1.html "Using Forms to Receive User Input" is where I would first look to see how to read input into my program. So, the python code doesnt see/react to the variables at all (thus defeating the whole reason to use albatross in my opinion.) [I guess this example is saying, "you dont need python to use form input". Yeah, ok. and I'd do that why? (I guess for some simple UI details, but that is a clever hack, not the main reason Im using Albatross)] cheers, cam PS: I feel bad everytime I post commenting on stuff like this, but really, I do think Albatross rocks :) -- / `Rev Dr' cam at darkqueen.org Roleplaying, virtual goth \ < http://darkqueen.org Poly, *nix, Python, C/C++, genetics, ATM > \ [+61 3] 9809 1523[h] skeptic, Evil GM(tm). Sysadmin for hire / ---------- Random Quote ---------- Now is the time for drinking; now the time to beat the earth with unfettered foot. -- Quintus Horatius Flaccus (Horace) From korg at darkqueen.org Thu Jul 3 04:12:10 2003 From: korg at darkqueen.org (Cameron Blackwood) Date: Thu, 03 Jul 2003 14:12:10 +1000 Subject: [albatross-users] Re: Albatross-users digest, Vol 1 #181 - 12 msgs In-Reply-To: Your message of "Wed, 02 Jul 2003 23:46:01 +1000." <20030702134601.9151.43636.Mailman@numbat.object-craft.com.au> Message-ID: <200307030412.h634CA506257@firewall.darkqueen.org> From: Matt Goodall : | Date: Wed, 02 Jul 2003 14:55:03 +0100 | From: Matt Goodall | To: "Albatross User's List" | Subject: Re: [albatross-users] multiple session support | [...] | | Sheila King wrote: | >The question was: | > | >"Multiple sessions/browser windows open is something to keep in mind. Does | >the Albatross framework allow multiple sessions for 1 account / from 1 | >computer?" | Does he mean multiple sessions or multiple browser windows sharing a | single session? Err, I dont think so. Say we have an chess game server which has a number of users, and each user can be playing multiple chess games against other people. I read that question as does albatross allow me to start my browser, create two tabs/windows, login (as a different and/or the same user) in each and play two different games. The are two issues here: 1) can albatross manage seperate sessions in a single browser instance? Answer: YES. See the code below seems to illustrate it. 2) can albatross deal with the issues of multiple streams of input without getting foobar'ed (ie, locks etc) EG, (assume in the chess example that chess was a realtime game and not turnbased) what happens if two people are trying to move the same piece? Answer: That isnt albatrosses job, that's the code you write :). (If anyone has any examples of (2) or knows how to make albatross do that, then please tell me :) :) :) Oh, and if he did mean.... | Does he mean multiple sessions or multiple browser windows sharing a | single session? then I guess the answer to that is that your application would have to be smart enough to deal with that. (and that isnt simple). -- / `Rev Dr' cam at darkqueen.org Roleplaying, virtual goth \ < http://darkqueen.org Poly, *nix, Python, C/C++, genetics, ATM > \ [+61 3] 9809 1523[h] skeptic, Evil GM(tm). Sysadmin for hire / ---------- Random Quote ---------- Now is the time for drinking; now the time to beat the earth with unfettered foot. -- Quintus Horatius Flaccus (Horace) -------------- 8< cut ------------ #!/usr/bin/python from albatross import SimpleApp as AlbatrossApp from albatross import SimpleAppContext as AlbatrossContext from albatross.cgiapp import Request def DEBUG(msg,*rest): fd=open("/tmp/debug",'a') fd.write('DEBUG: '+msg) if rest: fd.write('%s'%(rest)) fd.write('\n') fd.close() class StartPage: def page_enter(self, ctx): ctx.locals.number=0 ctx.locals.op=0 ctx.add_session_vars('number') def page_process(self, ctx): DEBUG('num==%s op==%s'%(ctx.locals.number,ctx.locals.op)) if ctx.locals.op: DEBUG(' INSIDE op==%s'%(ctx.locals.op)) if ctx.locals.op=='+': ctx.locals.number=ctx.locals.number+1 if ctx.locals.op=='-': ctx.locals.number=ctx.locals.number-1 if ctx.locals.op=='0': ctx.locals.number=0 def page_display(self, ctx): ctx.run_template('foo.html') class App(AlbatrossApp): def __init__(self): AlbatrossApp.__init__(self, base_url = 'whocares.py', template_path = 'template', start_page = 'StartPage', secret = '-=-secret-=-', # session_appid = 'popview3' ) for page in (StartPage(),): self.register_page(page.__class__.__name__, page) def create_context(self): return AlbatrossContext(self) if __name__ == '__main__': app = App() app.run(Request()) -------------- 8< cut ------------ albatross-foo

hello

Number is:

Writen in: Python and Albatross From andrewm at object-craft.com.au Thu Jul 3 07:02:40 2003 From: andrewm at object-craft.com.au (Andrew McNamara) Date: Thu, 03 Jul 2003 17:02:40 +1000 Subject: Whoa! What is this is I see? was RE: [albatross-users] impedance mismatch 1 In-Reply-To: Message from "Michael C. Neel" of "Wed, 02 Jul 2003 10:43:22 -0400." References: Message-ID: <20030703070240.5CD193C332@coffee.object-craft.com.au> >Okay, one thing I miss that python doesn't have is the ?: operator. But >then Matt writes: > >"name.index()%2 and 'red' or 'green'". > >Which from my quick tests in idle seem to be working like ?:; with the >execption of: > >1 and 0 or 2 returns 2 ( 1 ? 0 : 2 would return 0) Which I can see why >and I could work around that with int(1 and '0' or 2) If I need a0 for a >true value (rare case). > >So my question is, is this a hack of python, or can I always expect this >to stay the same across past and new versions of python? [...] The language reference has this to say: The expression x and y first evaluates x; if x is false, its value is returned; otherwise, y is evaluated and the resulting value is returned. The expression x or y first evaluates x; if x is true, its value is returned; otherwise, y is evaluated and the resulting value is returned. So, yes, the behaviour is defined, and it will not change. There are, however, some gotchyas: - as you note, unlike ?:, the second expression is evaluated - if the second expression evaluates to False, then the last expression is returned irrespective of the first expression. Your example is equivilent to: (1 and 0) or 2 => 0 or 2 => 2 So.. if the 2nd expression is a non-zero constant, you're okay. - if you forget and type " or and ", the results will not be what you expect, and it's visually hard to see what's wrong. A number of the python ghods are in favour of the and/or idiom, but I prefer not to use it. -- Andrew McNamara, Senior Developer, Object Craft http://www.object-craft.com.au/ From matt at pollenation.net Thu Jul 3 09:02:35 2003 From: matt at pollenation.net (Matt Goodall) Date: Thu, 03 Jul 2003 10:02:35 +0100 Subject: [albatross-users] more data tricks for the wiki In-Reply-To: <3F038F94.5040902@harvee.org> References: <200307030144.LAA14395@lightning.itga.com.au> <3F038F94.5040902@harvee.org> Message-ID: <3F03F12B.2080102@pollenation.net> Eric S. Johansson wrote: > Gregory Bond wrote: > >>> >>> >>> where list is the list of sets and item is a single element from the >>> list. >> >> No, better to think of it as: item is a ListIterator object, >> item.value() is >> a (reference to a) single element from the list. > > my question for you is: at what point does the distinction between > ListIterator and a simple element created from the list contents > confuse the user and enlighten the user. > > There is a point that the early learning phase where this is not > important and in fact detracts from the user's ability to masterthe > basics. There is some point later when it becomes important to have > the concept of ListIterator firmly in one's mind. Can you define that > boundary? The fact that it is an iterator is *always* important. If it was not an iterator it would not support paging, you could not easily decide whether it was an odd or even row etc without keeping track of the count yourself. The features ListIterator provide are so common that Albatross simply makes it readily available. >> Which implies "item" is not a great name for the iterator in an >> al-for loop! > > true. But what else works? what about "iter"? Or "people_iter" when iterating over a list of people and you need to make the name of the iterator more specific because you have a nested ? > It's a singleton containing your precious data and it is your > challenge to rip your data out of its evil clutches and cast the empty > ListIterator husk into the depths below. (I guess that shows my frame > of mind) I can see you are enjoying yourself. This is how I feel whenever I have to do any PHP, it drives me insane ;-). > seriously, from the user's perspective "item" is just that. A single > item. Ah, but as Greg pointed out that's what *you* called the iterator, not what Albatross called it. > The user shouldn't have to care that it's an iterator when the > surrounding structure looks like a simple for loop. if appearances > are deceiving, the user will resent being deceived. Hmm, that's an interesting point. Perhaps the *real* problem is that the tag is called but doesn't behave like a Python for loop. Perhaps something like would be better? Cheers, Matt -- Matt Goodall, Pollenation Internet Ltd e: matt@pollenationinternet.com From matt at pollenation.net Thu Jul 3 09:13:01 2003 From: matt at pollenation.net (Matt Goodall) Date: Thu, 03 Jul 2003 10:13:01 +0100 Subject: Whoa! What is this is I see? was RE: [albatross-users] impedance mismatch 1 In-Reply-To: <20030703070240.5CD193C332@coffee.object-craft.com.au> References: <20030703070240.5CD193C332@coffee.object-craft.com.au> Message-ID: <3F03F39D.4040203@pollenation.net> There is a good description of the and or trick at diveintopython.org, sepcifically http://diveintopython.org/apihelper_andor.html. Be sure to read the "when end-or trick fails" section! I admit to using this more than I should and Albatross has the tag which is a much better way of doing what I wanted in the example I posted. Cheers, Matt Andrew McNamara wrote: >>Okay, one thing I miss that python doesn't have is the ?: operator. But >>then Matt writes: >> >>"name.index()%2 and 'red' or 'green'". >> >>Which from my quick tests in idle seem to be working like ?:; with the >>execption of: >> >>1 and 0 or 2 returns 2 ( 1 ? 0 : 2 would return 0) Which I can see why >>and I could work around that with int(1 and '0' or 2) If I need a0 for a >>true value (rare case). >> >>So my question is, is this a hack of python, or can I always expect this >>to stay the same across past and new versions of python? [...] >> >> > >The language reference has this to say: > > The expression x and y first evaluates x; if x is false, its value > is returned; otherwise, y is evaluated and the resulting value > is returned. > > The expression x or y first evaluates x; if x is true, its value > is returned; otherwise, y is evaluated and the resulting value > is returned. > >So, yes, the behaviour is defined, and it will not change. There are, >however, some gotchyas: > > - as you note, unlike ?:, the second expression is evaluated - if > the second expression evaluates to False, then the last expression > is returned irrespective of the first expression. Your example is > equivilent to: > > (1 and 0) or 2 => 0 or 2 => 2 > > So.. if the 2nd expression is a non-zero constant, you're okay. > > - if you forget and type " or and ", the results will > not be what you expect, and it's visually hard to see what's wrong. > >A number of the python ghods are in favour of the and/or idiom, but I >prefer not to use it. > > > -- Matt Goodall, Pollenation Internet Ltd e: matt@pollenationinternet.com t: 0113 2252500 From dwagon at connect.com.au Thu Jul 3 08:43:26 2003 From: dwagon at connect.com.au (Dougal Scott) Date: Thu, 03 Jul 2003 18:43:26 +1000 Subject: [albatross-users] Consistencies in attributes and tags Message-ID: <20030703084326.3F6C54EE8B@koro.off.connect.com.au> There are some attributes that don't work in as many tags as I would like. The one that I have been irritated with was the 'noescape' attribute. It only applies to the tag and not to , and others. It shouldn't be difficult to make the attributes consistent across all tags, where they are applicable. This would make the tag more useful (to me at least). Currently I have to ctx.locals.imgtag='' and expand it with '' rather than ''. -- Dougal Scott Connect Internet Solutions dwagon@connect.com.au 180-188 Burnley Street Senior Systems Administrator Richmond, Australia, 3121 From djc at object-craft.com.au Thu Jul 3 10:48:48 2003 From: djc at object-craft.com.au (Dave Cole) Date: 03 Jul 2003 20:48:48 +1000 Subject: [albatross-users] Re: Albatross-users digest, Vol 1 #176 - 14 msgs In-Reply-To: <1057074328.1169.16.camel@emilio> References: <200307010109.h6119m713416@firewall.darkqueen.org> <1057074328.1169.16.camel@emilio> Message-ID: >>>>> "Tim" == Tim Churches writes: >> The application and execution context cooperate to deal with the >> session. The execution context is where the session data is >> created manipulated, but the application is usually responsible to >> loading and saving the session. This allows the application to >> maintain a long lived connection with a server if necessary. >> Remember that an execution context lives only long enough to >> process a single browser request. Tim> That para should be near the front of the manual if it isn't Tim> already. This is what I added at the end of the Guide to Building Applications introduction (just before section 4.1): http://www.object-craft.com.au/projects/albatross/albatross/app-guide.html In all Albatross applications there are two important objects that determine how browser requests are processed; the application object, and the execution context object. The application is a potentially long lived object that provides generic services for multiple browser requests. A new execution context is created to process each browser request. One of the things that the application and execution context do is cooperate to provide session functionality. The execution context is the object where session data is created and manipulated, but the application is usually responsible to loading and saving the session. This allows the application to maintain a long lived connection with a server if necessary. - Dave -- http://www.object-craft.com.au From djc at object-craft.com.au Thu Jul 3 11:02:32 2003 From: djc at object-craft.com.au (Dave Cole) Date: 03 Jul 2003 21:02:32 +1000 Subject: [albatross-users] Renaming application and execution context classes In-Reply-To: References: Message-ID: > I think there is something too this. Add to what you have below a > top level albatross function that returns the **kw you need, taking > one argument and doing a preset of classes. So you could write: > > app = albatross.App(albatross.AppBase, > albatross.PickleSignMixin, > albatross.Application, > albatross.CachingTemplateLoaderMixin, > albatross.PageModuleMixin, > albatross.SessionServerAppMixin) If you were doing something like this: class MyApp(albatross.AppBase, albatross.PickleSignMixin, albatross.Application, albatross.CachingTemplateLoaderMixin, albatross.PageModuleMixin, albatross.SessionServerAppMixin): pass then it would probably make sense to put the code that determined the required constructor **kw arguments inside a method in AppBase. Am I confused? > app = albatross.App(albatross.init_app(albatross.SERVER)) > > - and even could do - > > initapp = albatross.init_app(albatross.SERVER) > initapp.pagemodule = RandomPageModuleMixin > > app = = albatross.App(initapp) > > and yes, this comes from my win32 days =p long live h_wnd! Are you suggesting that there be a single application class that delegates processing to instances of other classes? If you are I think it might make things more than a little complicated. At the moment we are using inheritance hierarchies to define most of the variant functionality. If you did not use inheritance you would have to build some other scheme to explicitly delegate and distribute functionality. I cannot think of anything that would be as effective or clean. - Dave -- http://www.object-craft.com.au From djc at object-craft.com.au Thu Jul 3 11:15:07 2003 From: djc at object-craft.com.au (Dave Cole) Date: 03 Jul 2003 21:15:07 +1000 Subject: [albatross-users] A great use for the simple http server In-Reply-To: <1057096515.1169.73.camel@emilio> References: <1057089713.26359.13.camel@localhost> <1057096515.1169.73.camel@emilio> Message-ID: >>>>> "Tim" == Tim Churches writes: Tim> On Wed, 2003-07-02 at 06:01, Matt Goodall wrote: >> Hi, >> >> I'm not trying to blow my own trumpet, but the simple http server I >> wrote and posted in this list would make running the sample apps >> *much* easier to run. >> >> For instance, running the popview5 example would be a matter of >> changing to the directory and running "al-httd popview.App >> 8000". No installation necessary and no need to change base_url, >> template_path etc. Tim> I agree - and ease of trying out examples is paramount to hook Tim> new users. I agree with both of you. A cookbook is something that a wiki can almost certainly do better than we can in the documentation. - Dave -- http://www.object-craft.com.au From djc at object-craft.com.au Thu Jul 3 11:24:01 2003 From: djc at object-craft.com.au (Dave Cole) Date: 03 Jul 2003 21:24:01 +1000 Subject: [albatross-users] impedance mismatch 1 In-Reply-To: <1057105136.30064.125.camel@localhost> References: <3F020F0A.9010907@harvee.org> <1057105136.30064.125.camel@localhost> Message-ID: > OK, I think I understand what you mean about locals now and where > your confusion comes from. locals is simply an empty class > definition: > > class Vars: > pass > ... > ctx.locals = Vars() > > Python allows you to set any attribute on any object at any time: > > v = Vars() > v.my_name = 'Matt' > > This is perfectly valid and fairly normal in Python. After all, you > don't have to define instance attributes, you just say "self.my_name > = 'Matt'". Excellent explanation. > This reminds me that I have a note in a text file somewhere that > says something like, "could/should ctx.locals behave like a > dictionary?". I suppose there is no reason why it shouldn't. > I think ctx.locals could be made to behave like a dictionary. An > initial (untested) implementation of Vars to support this might be: > > class Vars: > def __setitem__(self, name, value): > setattr(self, name, value) > def __getitem__(self, name): > return getattr(self, name) That is all you really need to do. > There are other methods that would need implementing for Vars to be > truly dictionary-like but I'm sure you get the idea. If you really wanted to use things like .items() and .keys() you could just do it on the .__dict__ member. > Eric, would making ctx.locals behave like a dictionary help your > understanding? Dave/Andrew, are there any technical reasons why this > would not work? None that I know of. Is there any reason why you would want to though. I am not sure that you want to encourage people to mix code like ctx.locals['a'] = 3 and ctx.locals.b = 5. - Dave -- http://www.object-craft.com.au From djc at object-craft.com.au Thu Jul 3 11:48:26 2003 From: djc at object-craft.com.au (Dave Cole) Date: 03 Jul 2003 21:48:26 +1000 Subject: [albatross-users] impedance mismatch 1 In-Reply-To: <200307020044.KAA27327@lightning.itga.com.au> References: <200307020044.KAA27327@lightning.itga.com.au> Message-ID: > One wrinkle on all this: > > * "environ" when inside the template refers to the same dictionary > > as "ctx.locals.environ" in the python code. > > ... and if ctx.locals.environ doesn't exist, then it looks for > environ in the global context of the _page display function_. So > you can do something like: > > ---- > my_heading = 'Super Application' > > class StartPage: > # ... > def page_display(self, ctx): > ctx.run_template('start.ht') > ---- > then, inside start.ht, something like >

> and it will work. > > But the trick is it uses the global namespace of the function that > calls run_template(). If you use page modules, it has to be in the > page module. If you do what I do and have a library with a base > class for Albatross pages that has a run_template function, then you > will get the global namespace of the library module, not the > application, unless you override the page_display in your concrete > page class. > > (Which is probably as clear as mud....) That is a pretty clear explanation. I should see if I can add some rationale... One of the cool things about Python expression evaluation is that it uses two namespaces. This allows you to do things like this in Python. >>> a = 5 >>> def f(): ... b = 4 ... print a * b ... >>> f() 20 In the function above I was able to use a global variable - quite useful if you consider that modules appear in the global namespace. Local variables are useful because... well just because. :-) The way Python exposes the local and global namespace to eval() is by letting you pass two dictionaries to the eval() function. >>> print eval.__doc__ eval(source[, globals[, locals]]) -> value Evaluate the source in the context of globals and locals. The source may be a string representing a Python expression or a code object as returned by compile(). The globals and locals are dictionaries, defaulting to the current globals and locals. If only globals is given, locals defaults to it. That is a very powerful feature. Now back to Albatross. If you want to build an application from multiple modules, you might need to access functions or values from a module inside a template expression. If there was only one namespace exposed to template expressions you would need to do something like this all of the time: import utils def page_display(ctx): ctx.locals.utils = utils ctx.run_template('template.html') That is not so bad but can get quite ugly. With the current functionality the execution context searches up the stack frame for the function that called run_template(). It then uses the globals of that stack frame as the globals in the execution context for evaluating template expressions. This means that the execution context will find the global namespace that contains the imported utils module. You do not need to explicity place a reference to the utils module in the local namespace (ctx.locals). import utils # used in template.html def page_display(ctx): ctx.run_template('template.html') - Dave -- http://www.object-craft.com.au From djc at object-craft.com.au Thu Jul 3 12:23:39 2003 From: djc at object-craft.com.au (Dave Cole) Date: 03 Jul 2003 22:23:39 +1000 Subject: [albatross-users] multiple session support In-Reply-To: <50112117.1057093066@SHEILA-LAPTOP> References: <50112117.1057093066@SHEILA-LAPTOP> Message-ID: >>>>> "Sheila" == Sheila King writes: Sheila> Hello, I got a question today from a team member, and I think Sheila> the answer is "yes" but I just wanted to verify that with the Sheila> list. Sheila> The question was: Sheila> "Multiple sessions/browser windows open is something to keep Sheila> in mind. Does the Albatross framework allow multiple sessions Sheila> for 1 account / from 1 computer?" The answer is probably "it depends". For client side sessions all of the state is stored in hidden fields in forms at the browser. This means that there is no restriction over how many windows you point at a single application. For server side sessions Albatross uses a unique session id in a cookie to identify the session. If you have installed a server side session Albatross application, and you are running mozilla, you can see the cookie by using the Cookie Manager (on the Tools menu). When you look at the cookie in the browser you will notice that it has the following attributes (amongst others); host, name, path, and information. When the browser sends a request to a URL at a server it looks up its cookie database for any cookies that match the same host and URL path. All cookies that match it are sent as headers in the HTTP request to the server. In server side session Albatross applications you specify a session_appid argument to the application constructor. This value is sent to the browser in the form of a cookie containing the session id. For example, the popview3 application constructor looks like: SimpleSessionApp(base_url = 'popview.py', template_path = '.', start_page = 'login', secret = '-=-secret-=-', session_appid = 'popview3') This causes the server to send a set-cookie request like this to the browser something like this: Set-Cookie: popview3=1234567812345678 The browser then stores the cookie value in the cookie database so that the next time you send a request to the same URL path on the same server it can send back the cookie. Sheila> At this point, I'm wondering exactly what he means by this? What he probably means is that by using cookie you restrict each browser to a single session for each Albatross application at each web server. Sheila> I can't find anything about multiple sessions in the albatross Sheila> documentation and the closest I found in the mailing list Sheila> archives is this: Sheila> Andrew is talking about something else. He is pointing out another problem with server side sessions; when the user goes back in their page history at the browser and submits a form. The problem here is that old pages in the browser history probably contain content dependent on state that no longer exists at the server. If the user submits a form from an old page then you are probably going to have some sort of application failure. There are some way to partially reduce the exposure to this problem. Andrew mentioned one scheme in the above message. Sheila> Does anyone have an idea what the purpose or desireability of Sheila> multiple sessions for one account from one computer would be? I have on occasion thought that it might be nice to support multiple sessions to the same application in Albatross. It would make for a very complex application though. You might find it easier to solve the problem with multiple applications. Sheila> And would it be possible to implement in Albatross? Yes it would be possible to implement something in Albatross. It would require the development of some extra Albatross mixins though. Sheila> (The guy who asked is mostly a PHP and Perl programmer, so I'm Sheila> not sure if that has anything to do with where he's coming Sheila> from or not?) Couldn't say. - Dave -- http://www.object-craft.com.au From djc at object-craft.com.au Thu Jul 3 12:27:16 2003 From: djc at object-craft.com.au (Dave Cole) Date: 03 Jul 2003 22:27:16 +1000 Subject: [albatross-users] multiple session support In-Reply-To: <3F02E437.4030100@pollenation.net> References: <50112117.1057093066@SHEILA-LAPTOP> <3F02E437.4030100@pollenation.net> Message-ID: >>>>> "Matt" == Matt Goodall writes: Matt> Does he mean multiple sessions or multiple browser windows Matt> sharing a single session? Matt> I'm not speaking from experience here but I cannot think of a Matt> reason why multiple windows with one session would be a problem Matt> for the server-side session management mixins ... that is, Matt> provided that any file system access is using locks. Multiple application windows can be handled by dividing application functionality between those windows. What can't be handled is multiple server side sessions associated with the application pages from the same browser. One day Andrew might publish his enhanced popview application which makes extensive use of multiple frames (which is effectively the same as multiple windows). - Dave -- http://www.object-craft.com.au From djc at object-craft.com.au Thu Jul 3 12:33:32 2003 From: djc at object-craft.com.au (Dave Cole) Date: 03 Jul 2003 22:33:32 +1000 Subject: [albatross-users] more data tricks for the wiki In-Reply-To: <3F03F12B.2080102@pollenation.net> References: <200307030144.LAA14395@lightning.itga.com.au> <3F038F94.5040902@harvee.org> <3F03F12B.2080102@pollenation.net> Message-ID: >>>>> "Matt" == Matt Goodall writes: >> The user shouldn't have to care that it's an iterator when the >> surrounding structure looks like a simple for loop. if appearances >> are deceiving, the user will resent being deceived. Matt> Hmm, that's an interesting point. Perhaps the *real* problem is Matt> that the tag is called but doesn't behave like a Python Matt> for loop. Perhaps something like would be better? Good point. The new documentation for should hopefully make the iterator a little less confusing. http://www.object-craft.com.au/projects/albatross/albatross/tag-for.html - Dave -- http://www.object-craft.com.au From djc at object-craft.com.au Thu Jul 3 13:16:57 2003 From: djc at object-craft.com.au (Dave Cole) Date: 03 Jul 2003 23:16:57 +1000 Subject: [albatross-users] New version of the standalone http server In-Reply-To: <1057196415.18669.41.camel@localhost> References: <1057196415.18669.41.camel@localhost> Message-ID: > Attached is an updated version of the standalone server with the > following changes: > > * Fixed to support forms containing input fields with a "list" > attribute. It only ever returned the first value in the get or > post data before. > * Added the current working directory to the path so that the > httpd.py script can live anywhere. > * changed the filename to al-httpd. An even better name might be > al-simple-server. It works beautifully. I would love to add this to Albatross to sit next to your FastCGI code. I made one small change to your code to make it a bit more flexible (I hope). I let the application mainline construct the application object. --- al-httpd-orig 2003-07-03 23:09:30.000000000 +1000 +++ al-httpd 2003-07-03 23:07:18.000000000 +1000 @@ -149,7 +149,7 @@ # Load the application's module and create an application instance module = __import__(appClass[:appClass.rindex('.')]) - app = getattr(module,appClass[appClass.rindex('.')+1:])() + app = getattr(module,appClass[appClass.rindex('.')+1:]) # Create the HTTP server httpd = HTTPServer(app, port) Now with the most trivial change to the form4 Albatross sample it works fantastically. --- samples/form4/form.py 2002-08-17 23:14:36.000000000 +1000 +++ form.py 2003-07-03 23:13:40.000000000 +1000 @@ -19,4 +19,5 @@ secret = '-=-secret-=-') app.register_page('form', Form()) -app.run(Request()) +if __name__ == '__main__': + app.run(Request()) Now due to you code I can do this: $ al-httpd form.app 8080 That is cool! - Dave -- http://www.object-craft.com.au From esj at harvee.org Thu Jul 3 13:32:19 2003 From: esj at harvee.org (Eric S. Johansson) Date: Thu, 03 Jul 2003 09:32:19 -0400 Subject: [albatross-users] more data tricks for the wiki In-Reply-To: <3F03F12B.2080102@pollenation.net> References: <200307030144.LAA14395@lightning.itga.com.au> <3F038F94.5040902@harvee.org> <3F03F12B.2080102@pollenation.net> Message-ID: <3F043063.3060808@harvee.org> Matt Goodall wrote: [... redundant parts removed...] >> The user shouldn't have to care that it's an iterator when the >> surrounding structure looks like a simple for loop. if appearances >> are deceiving, the user will resent being deceived. > > > Hmm, that's an interesting point. Perhaps the *real* problem is that the > tag is called but doesn't behave like a Python for loop. > Perhaps something like would be better? that's the complete point. The appearances must match the metaphor in order for it to assist in the user's learning process and the expert's use process. now, researching the concept of iterators in Python, I found this nice little article: http://gnosis.cx/publish/programming/charming_python_b1.html In which, the author says " Most frequently, however, one is likely to use a generator as an iterator, which is even more concise (and again looks just like an old-fashioned sequence):" this article and seeing how albatross uses the iterator concept reinforces that iterator is primarily used as a way of encapsulating sequencing behavior across a set of data. what's interesting is the difference in terms of what is returned. An albatross, it's an iterator object; in Python iterators (as demonstrated by examples in the article referenced above) it's an ordinary piece of data (integer, float, string etc.). I'm beginning to understand one of my cognitive speed bumps. The data source for the loop is usually some form of sequence. It appears that the albatross for loop structure tries to cram the sequence into an iterator and then impose its iterator view. as for making a new tag, I don't think it's necessary. I would consider expanding the definition of a loop however. Personally, I would do something like: for ordinary sequences but for the cases where you want an iterator, you can use the current albatross form. ---eric From neel at mediapulse.com Thu Jul 3 14:13:57 2003 From: neel at mediapulse.com (Michael C. Neel) Date: Thu, 3 Jul 2003 10:13:57 -0400 Subject: [albatross-users] Installing multiple copies of Albatross Message-ID: Draging this up again to see if anyone has any ideas here, this is keeping me from playing with new versions of Albatross atm :/ Mike -----Original Message----- From: Michael C. Neel=20 Sent: Sunday, June 29, 2003 7:12 PM To: albatross-users@object-craft.com.au Subject: [albatross-users] Installing multiple copies of Albatross All, I'm trying to figure out how to install several versions of albatross on the same system. I have quite a few sites running on albatross, so I don't want a massive task to upgrade with each new version, esp if there is a rename of classes soon. I tried to place albatross into my modules directoy (I use mod_python) but no matter what I tried I couldn't get the local version of Albatross to be used over the /usr/lib one. I could rename albatross to albatross110pre, but that looks like a lot of code to touch in the module to stop the albatross imports from getting the wrong version. I think I'm missing something simple here, because no one else has mentioned this, so any tips would be helpful. Thanks, Mike _______________________________________________ Albatross-users mailing list Albatross-users@object-craft.com.au https://www.object-craft.com.au/cgi-bin/mailman/listinfo/albatross-users From neel at mediapulse.com Thu Jul 3 14:27:58 2003 From: neel at mediapulse.com (Michael C. Neel) Date: Thu, 3 Jul 2003 10:27:58 -0400 Subject: Whoa! What is this is I see? was RE: [albatross-users] impedancemismatch 1 Message-ID: Thanks for the replies. I most use this type of thing for setting a var that may or may not be set (we don't want to overwrite it if set): myvar =3D myvar and myvar or "No value set" Which I could have: =09 if not myvar: myvar =3D "No value set" but not in a lambda. I know some see python as bineg a "syntax clean" language - aka, not perl - but that's only true to a point. Once you've written '; '.join(map(lambda a, m=3Dareamap: m[int(a)], areas)) doing and-or seems highly readable =3D) Mike From matt at pollenation.net Thu Jul 3 14:57:48 2003 From: matt at pollenation.net (Matt Goodall) Date: Thu, 03 Jul 2003 15:57:48 +0100 Subject: [albatross-users] Installing multiple copies of Albatross In-Reply-To: References: Message-ID: <3F04446C.9050704@pollenation.net> Have you tried the mod_python list to see if anyone there knows how to do it? I've no idea if it would actually work but you could make use of the FastCGI stuff. At the start of the module you could prepend the path to include 1.10pre. Actually, straight CGI would allow this too but you get the obvious performance hit. - Matt Michael C. Neel wrote: >Draging this up again to see if anyone has any ideas here, this is >keeping me from playing with new versions of Albatross atm :/ > >Mike > >-----Original Message----- >From: Michael C. Neel >Sent: Sunday, June 29, 2003 7:12 PM >To: albatross-users@object-craft.com.au >Subject: [albatross-users] Installing multiple copies of Albatross > > >All, > > I'm trying to figure out how to install several versions of >albatross on the same system. I have quite a few sites running on >albatross, so I don't want a massive task to upgrade with each new >version, esp if there is a rename of classes soon. > > I tried to place albatross into my modules directoy (I use >mod_python) but no matter what I tried I couldn't get the local version >of Albatross to be used over the /usr/lib one. I could rename albatross >to albatross110pre, but that looks like a lot of code to touch in the >module to stop the albatross imports from getting the wrong version. > > I think I'm missing something simple here, because no one else >has mentioned this, so any tips would be helpful. > >Thanks, >Mike >_______________________________________________ >Albatross-users mailing list >Albatross-users@object-craft.com.au >https://www.object-craft.com.au/cgi-bin/mailman/listinfo/albatross-users >_______________________________________________ >Albatross-users mailing list >Albatross-users@object-craft.com.au >https://www.object-craft.com.au/cgi-bin/mailman/listinfo/albatross-users > > -- Matt Goodall, Pollenation Internet Ltd e: matt@pollenationinternet.com t: 0113 2252500 From esj at harvee.org Thu Jul 3 16:30:42 2003 From: esj at harvee.org (Eric S. Johansson) Date: Thu, 03 Jul 2003 12:30:42 -0400 Subject: [albatross-users] check boxes again. Message-ID: <3F045A32.90804@harvee.org> http://harvee.org/greeneggs/retrain.cgi it is working better. however, I still have a major problem with checkbox state presetting. I can either set them all on or set them all off. then there's the question of getting the data back on the state of all the checkboxes. This is a fragment of the entire form cut down for intelligibility ... >
target="spamtrap_display">

...
as you can see, I feed it with an object containing all the attributes that define a line including whether or not a check box should be on or off. So, this is my next cognitive hurdle. How do I directly turn the checked attribute on or off? or is it only possible using indirect means? Code and templates available on request ---eric From esj at harvee.org Thu Jul 3 17:53:47 2003 From: esj at harvee.org (Eric S. Johansson) Date: Thu, 03 Jul 2003 13:53:47 -0400 Subject: [albatross-users] check boxes again. In-Reply-To: <3F045A32.90804@harvee.org> References: <3F045A32.90804@harvee.org> Message-ID: <3F046DAB.1010103@harvee.org> Eric S. Johansson wrote: > http://harvee.org/greeneggs/retrain.cgi > > it is working better. and betterer. The question was > So, this is my next cognitive hurdle. How do I directly turn the > checked attribute on or off? or is it only possible using indirect means? solved the setting checkbox problem by: simple but nonobvious. I set the attribute albatross_token to always have a value of "on". Then in the checkbox definition, I set valueexpr to have the value of "checked" which is an on/off value I calculate when defining the line parameters. Next trick is extracting *all* checkbox values... > Code and templates available on request hasn't changed (the offer that is) ---eric From sheila at thinkspot.net Thu Jul 3 19:26:01 2003 From: sheila at thinkspot.net (Sheila King) Date: Thu, 03 Jul 2003 12:26:01 -0700 Subject: [albatross-users] multiple session support In-Reply-To: <50112117.1057093066@SHEILA-LAPTOP> References: <50112117.1057093066@SHEILA-LAPTOP> Message-ID: <19329474.1057235161@SHEILA-LAPTOP> I want to thank everyone on their comments about multiple sessions with one browser/computer. The comments and examples have helped me to get a better frame of reference for continuing discussions with my teammate. I guess, the summary is, that (1) yes this is possible, if we code it (support for such does not currently exist in the Albatross distribution), and (2) I need to get more input from my teammate as to what exactly he hopes to accomplish with such functionality, as I don't even know why I would want to expend the effort at this time to implement my own solution to this problem. Thanks again, -- Sheila King http://www.thinkspot.net/sheila/ http://www.k12groups.org --On Tuesday, July 01, 2003 8:57 PM -0700 Sheila King wrote: > Hello, > > I got a question today from a team member, and I think the answer is "yes" > but I just wanted to verify that with the list. > > The question was: > > "Multiple sessions/browser windows open is something to keep in mind. Does > the Albatross framework allow multiple sessions for 1 account / from 1 > computer?" > > At this point, I'm wondering exactly what he means by this? > > I can't find anything about multiple sessions in the albatross > documentation and the closest I found in the mailing list archives is > this: > tm l> > > which isn't really exactly what he is asking about, but I think it touches > on it. > > Does anyone have an idea what the purpose or desireability of multiple > sessions for one account from one computer would be? And would it be > possible to implement in Albatross? > > (The guy who asked is mostly a PHP and Perl programmer, so I'm not sure if > that has anything to do with where he's coming from or not?) > > -- > Sheila King > http://www.thinkspot.net/sheila/ > http://www.k12groups.org From sheila at thinkspot.net Thu Jul 3 19:49:19 2003 From: sheila at thinkspot.net (Sheila King) Date: Thu, 03 Jul 2003 12:49:19 -0700 Subject: [albatross-users] Comments on using examples... In-Reply-To: <200307030350.h633oWc06073@firewall.darkqueen.org> References: <200307030350.h633oWc06073@firewall.darkqueen.org> Message-ID: <20727424.1057236559@SHEILA-LAPTOP> --On Thursday, July 03, 2003 1:50 PM +1000 Cameron Blackwood wrote: > I dont know about other people, but when I see an example in docs, I > often like to actually: > 1) try it myself > 2) modify it > 3) use it as a base for what I really want to do Agree. > Eg: > www.object-craft.com.au/projects/albatross/albatross/tag-comment.html > > trying it: > Hands up anyone who has used albatross in interactive mode? Yes, I have. For testing/learning only, of course. I primarily used it that way because of two reasons: (1) the thing I was trying to learn/master was shown with examples in interactive-mode in the documentation. (2) it was quicker to do that then modify the app I'm working on for test purposes. > Interactive python dumps are not much use because: > 1) noone would ever do that I assume that you mean here, that no one would use Albatross in production in such a manner? However, interactive is mostly used (by developers) for testing purposes, even when not working with Albatross. At least, that is my take on the matter (as a clearly peon developer type). > 2) you cant cut & paste to test (well you can, but you have > to cut and paste specific bits (not the output) and you > cant cut and paste the multi-line examples, thanks to the > pythonic '... '/'>>> ', without having to be _VERY_ careful > about indenting.) Agree that c&p is much more difficult/annoying from the interactive examples. > 3) if I find what I need, then I need to translate it into a > SimpleApp (or whatever) to actually use it (Thus, shouldn't > it be a SimpleApp example to start with?) For what it is worth... I also found the amount of interactive examples in the documentation to be ... uh ... not what I would have preferred to see. Some of it is good, or I might not have even realized how to run Albatross interactively (or even thought of it as being possible). I do think some examples of running it interactively are good, in order to make this point. Perhaps put it into a small section of the documentation, as it's own topic: "Running Albatross in Python Interactive Mode" and then a few examples showing how to do that. And then convert the rest of the interactive examples in the documentation to downloadable/runable files. BTW, something I never mentioned but that bugged me in the docs: The use of the '' context in the interactive examples. Bugged the crud out of me as to what it was, why it was named that way, why it worked. Eventually just accepted it as black magic and moved on, but wasn't really happy with having to do that. The examples being currently uploaded to the Wiki may make up for the "short coming" of having so many of the documentation's examples shown as interactive mode. I also want to re-iterate that I find the Albatross product (and its docs) to be first rate, and only make negative comments at all in the hope of offering feedback for improvement of an already fine project. -- Sheila King http://www.thinkspot.net/sheila/ http://www.k12groups.org From gnb at itga.com.au Thu Jul 3 23:09:46 2003 From: gnb at itga.com.au (Gregory Bond) Date: Fri, 04 Jul 2003 09:09:46 +1000 Subject: [albatross-users] Installing multiple copies of Albatross In-Reply-To: Your message of Thu, 03 Jul 2003 10:13:57 -0400. Message-ID: <200307032309.JAA02757@lightning.itga.com.au> > Draging this up again to see if anyone has any ideas here, this is > keeping me from playing with new versions of Albatross atm :/ 2 ideas of the top of my not-yet-caffeine-enhanced head: - install 1.10 in the usual site-python dir but with another name. This would mean changing the apps to say "from albatross110 import ..." but the rest orta work OK provided Dave has been careful in his internal imports. No, the Albatross code is full of references to "from albatross.module import" so you'll need to change them, too. You should be able to change this to just "from module import " and the Python module path hacking will DTRT. Dave: you might consider making Albatross not use the "albatross" name internally so tricks like this work. - Install 1.10 into another site-python directory and add that dir to the front of the search path for applications which are converted. Details depend on your deployment platform, but you could hack sys.path in the script, or set environment variables for your web server, or whatever. From djc at object-craft.com.au Thu Jul 3 23:49:03 2003 From: djc at object-craft.com.au (Dave Cole) Date: 04 Jul 2003 09:49:03 +1000 Subject: [albatross-users] Installing multiple copies of Albatross In-Reply-To: <200307032309.JAA02757@lightning.itga.com.au> References: <200307032309.JAA02757@lightning.itga.com.au> Message-ID: >>>>> "Gregory" == Gregory Bond writes: Gregory> No, the Albatross code is full of references to "from Gregory> albatross.module import" so you'll need to change them, too. Gregory> You should be able to change this to just "from module import Gregory> " and the Python module path hacking will DTRT. Gregory> Dave: you might consider making Albatross not use the Gregory> "albatross" name internally so tricks like this work. Albatross used to use relative imports until we discovered that relative imports are frowned upon. From http://www.python.org/peps/pep-0008.html - Relative imports for intra-package imports are highly discouraged. Always use the absolute package path for all imports. One thing that Andrew has done with good results is install the desired release of Albatross in the application directory. Most of the time Python has the current directory as the first entry in sys.path. If you are running a mod_python application then you will probably have to manually change sys.path. import sys sys.path.insert(0, '/path/to/my/special/albatross') import albatross Since the module is only imported once by Apache the above should be OK. You might also consider telling mod_python to run a separate interpreter instance for each directory. http://www.modpython.org/live/mod_python-2.7.8/doc-html/pyapi-interps.html - Dave -- http://www.object-craft.com.au From gnb at itga.com.au Fri Jul 4 00:04:31 2003 From: gnb at itga.com.au (Gregory Bond) Date: Fri, 04 Jul 2003 10:04:31 +1000 Subject: [albatross-users] check boxes again. In-Reply-To: Your message of Thu, 03 Jul 2003 12:30:42 -0400. Message-ID: <200307040004.KAA08163@lightning.itga.com.au> I battled with this sort of problem a few months ago and I spent some time yesterday putting up my solution onto the Albatross wiki. http://www.object-craft.com.au/projects/albatross/wiki/ExampleCode From esj at harvee.org Fri Jul 4 00:26:42 2003 From: esj at harvee.org (Eric S. Johansson) Date: Thu, 03 Jul 2003 20:26:42 -0400 Subject: [albatross-users] check boxes again. In-Reply-To: <200307040004.KAA08163@lightning.itga.com.au> References: <200307040004.KAA08163@lightning.itga.com.au> Message-ID: <3F04C9C2.1020308@harvee.org> Gregory Bond wrote: > I battled with this sort of problem a few months ago and I spent some time > yesterday putting up my solution onto the Albatross wiki. > http://www.object-craft.com.au/projects/albatross/wiki/ExampleCode I noticed and thank you. I would add another section however. Q: how do I get a complete list of all checkboxes checked and unchecked just like you can with ordinary CGI Personally, I think this is a shortcoming of albatross. It is one of the few I've encountered in my brief exposure which is very impressive. I am resigned to shoving a list of all spamtrap tokens up to the page and using that information plus the list of checkboxes checked to extract a list of what wasn't checked. ugly but not horrible. what is the best way to store a chunk of data (i.e. a list) client side? Anyway, thanks for your taking time to write up your solution. ---eric From djc at object-craft.com.au Fri Jul 4 00:42:40 2003 From: djc at object-craft.com.au (Dave Cole) Date: 04 Jul 2003 10:42:40 +1000 Subject: [albatross-users] more data tricks for the wiki In-Reply-To: <3F043063.3060808@harvee.org> References: <200307030144.LAA14395@lightning.itga.com.au> <3F038F94.5040902@harvee.org> <3F03F12B.2080102@pollenation.net> <3F043063.3060808@harvee.org> Message-ID: >>>>> "Eric" == Eric S Johansson writes: Eric> what's interesting is the difference in terms of what is Eric> returned. An albatross, it's an iterator object; in Python Eric> iterators (as demonstrated by examples in the article referenced Eric> above) it's an ordinary piece of data (integer, float, string Eric> etc.). One of the limitations that Albatross has to live with is that real iterators and generators cannot be pickled. This means that they cannot be saved in a session. If you use pagination in your tag the ListIterator is placed in the session so it can "remember" where you were in the sequence. Thinking out loud: Currently pagination is handled by saving a ListIterator in the session. The browser request then issues a nextpage or prevpage request and names the iterator. next results in next Maybe a better way to do this would be to place all of the information required for pagination into the browser request. This would result in output that looked something like this next The nice outcome of this would be that we do not need to save anything in the session anymore. It would also allow you to bookmark specific pages in an application. - Dave -- http://www.object-craft.com.au From djc at object-craft.com.au Fri Jul 4 00:47:49 2003 From: djc at object-craft.com.au (Dave Cole) Date: 04 Jul 2003 10:47:49 +1000 Subject: [albatross-users] check boxes again. In-Reply-To: <3F04C9C2.1020308@harvee.org> References: <200307040004.KAA08163@lightning.itga.com.au> <3F04C9C2.1020308@harvee.org> Message-ID: >>>>> "Eric" == Eric S Johansson writes: Eric> Gregory Bond wrote: >> I battled with this sort of problem a few months ago and I spent >> some time yesterday putting up my solution onto the Albatross wiki. >> http://www.object-craft.com.au/projects/albatross/wiki/ExampleCode Eric> I noticed and thank you. I would add another section however. Eric> Q: how do I get a complete list of all checkboxes checked and Eric> unchecked just like you can with ordinary CGI Eric> Personally, I think this is a shortcoming of albatross. It is Eric> one of the few I've encountered in my brief exposure which is Eric> very impressive. I am resigned to shoving a list of all Eric> spamtrap tokens up to the page and using that information plus Eric> the list of checkboxes checked to extract a list of what wasn't Eric> checked. ugly but not horrible. Eric> what is the best way to store a chunk of data (i.e. a list) Eric> client side? Eric> Anyway, thanks for your taking time to write up your solution. You might be able to get closer what you want by using the alias attribute. http://www.object-craft.com.au/projects/albatross/albatross/tag-input-alias.html - Dave -- http://www.object-craft.com.au From djc at object-craft.com.au Fri Jul 4 01:01:48 2003 From: djc at object-craft.com.au (Dave Cole) Date: 04 Jul 2003 11:01:48 +1000 Subject: [albatross-users] Consistencies in attributes and tags In-Reply-To: <20030703084326.3F6C54EE8B@koro.off.connect.com.au> References: <20030703084326.3F6C54EE8B@koro.off.connect.com.au> Message-ID: > There are some attributes that don't work in as many tags as I would > like. The one that I have been irritated with was the 'noescape' > attribute. It only applies to the tag and not to > , and others. It shouldn't be difficult to make the > attributes consistent across all tags, where they are applicable. > > This would make the tag more useful (to me at least). > Currently I have to ctx.locals.imgtag='' and expand it > with '' rather than ' expr="..." noescape>'. I cannot see any problem in adding the noescape attribute to al-img. We should probably add the ability to disable content escaping everywhere. What do you think Andrew? - Dave -- http://www.object-craft.com.au From gnb at itga.com.au Fri Jul 4 01:10:24 2003 From: gnb at itga.com.au (Gregory Bond) Date: Fri, 04 Jul 2003 11:10:24 +1000 Subject: [albatross-users] check boxes again. In-Reply-To: Your message of Thu, 03 Jul 2003 20:26:42 -0400. Message-ID: <200307040110.LAA28357@lightning.itga.com.au> > Q: how do I get a complete list of all checkboxes checked and unchecked just > like you can with ordinary CGI Presumably, you get this list from the same place you get the list of all the items you are adding to the form. (i.e. you need exactly this information to display the page in the first place, so it can't be that hard!!) > what is the best way to store a chunk of data (i.e. a list) client side? If you add a variable to the session (with ctx.add_session_vars()), then it will be there for you next time the page_process() function is called. You can add (almost) any Python datatype to the session, so a vector of strings is easy. This can be expensive in bandwith if you use client-side sessions, depending on how much data you add. We use file-based server sessions with up to 100k of session data to do this sort of thing with no problems at all. Perhaps the model you want is something like this (warning: untested): -------- def page_enter(self, ctx): ctx.locals.all_ids = [] ctx.add_session_vars('all_ids') def page_display(self, ctx): ctx.locals.spam_ids = [] ctx.locals.not_spam_ids = [] for i in self.list_of_emails(): id = i.message_id() ctx.locals.all_ids.append(id) if i.is_spam(): ctx.locals.spam_ids.append(id) elif i.is_not_spam(): ctx.locals.not_spam_ids.append(id) ctx.run_template('list.htm') def page_process(self, ctx): # Here, ctx.locals.all_ids is a vector of all the IDs # ctx.locals.spam_ids is a vector of all the IDs for which the "is spam" checkbox was selected # likewise, ctx.locals.not_spam_ids for id in ctx.locals.all_ids: if id in ctx.locals.spam_ids: mark_id_spam(id) elif id in ctx.locals.not_spam_ids: mark_id_not_spam(id) else: mark_id_unknown_status(id) ---------- Now depending on how long each vector might be, the "i in smap_ids" might be too slow (it's O(n) in the number of items) so you could start by converting the vector into a dict. But this is unlikely to be an issue for any sensible web page - your browser will explode trying to render the form well before this becomes a bottleneck. And you can avoid storing the all_ids vector in the session by changing your process function to something like this: def page_process(self, ctx): for i in self.list_of_emails(): id = i.message_id() if id in ctx.locals.spam_ids: mark_id_spam(id) elif id in ctx.locals.not_spam_ids: mark_id_not_spam(id) else: mark_id_unknown_status(id) i.e. use the same for loop in the process function as you used in the al-for template that generated the form. From andrewm at object-craft.com.au Fri Jul 4 01:18:46 2003 From: andrewm at object-craft.com.au (Andrew McNamara) Date: Fri, 04 Jul 2003 11:18:46 +1000 Subject: [albatross-users] Consistencies in attributes and tags In-Reply-To: Message from Dave Cole of "04 Jul 2003 11:01:48 +1000." References: <20030703084326.3F6C54EE8B@koro.off.connect.com.au> Message-ID: <20030704011847.F0F923C332@coffee.object-craft.com.au> > >> There are some attributes that don't work in as many tags as I would >> like. The one that I have been irritated with was the 'noescape' >> attribute. It only applies to the tag and not to >> , and others. It shouldn't be difficult to make the >> attributes consistent across all tags, where they are applicable. >> >> This would make the tag more useful (to me at least). >> Currently I have to ctx.locals.imgtag='' and expand it >> with '' rather than '> expr="..." noescape>'. > >I cannot see any problem in adding the noescape attribute to al-img. > >We should probably add the ability to disable content escaping >everywhere. What do you think Andrew? Sounds reasonable. -- Andrew McNamara, Senior Developer, Object Craft http://www.object-craft.com.au/ From djc at object-craft.com.au Fri Jul 4 01:48:34 2003 From: djc at object-craft.com.au (Dave Cole) Date: 04 Jul 2003 11:48:34 +1000 Subject: [albatross-users] Consistencies in attributes and tags In-Reply-To: <20030704011847.F0F923C332@coffee.object-craft.com.au> References: <20030703084326.3F6C54EE8B@koro.off.connect.com.au> <20030704011847.F0F923C332@coffee.object-craft.com.au> Message-ID: --=-=-= >>>>> "Andrew" == Andrew McNamara writes: >>> There are some attributes that don't work in as many tags as I >>> would like. The one that I have been irritated with was the >>> 'noescape' attribute. It only applies to the tag and >>> not to , and others. It shouldn't be difficult to make >>> the attributes consistent across all tags, where they are >>> applicable. >>> >>> This would make the tag more useful (to me at least). >>> Currently I have to ctx.locals.imgtag='' and expand >>> it with '' rather than '>> expr="..." noescape>'. >> I cannot see any problem in adding the noescape attribute to >> al-img. >> >> We should probably add the ability to disable content escaping >> everywhere. What do you think Andrew? Andrew> Sounds reasonable. OK, here is a patch to enable noescape in , , (values returned by expression), and . It is completely untested - but will be in the next release. - Dave --=-=-= Content-Type: text/x-patch Content-Disposition: attachment; filename=noescape.patch Index: albatross/tags.py =================================================================== RCS file: /usr/local/cvsroot/object-craft/albatross/albatross/tags.py,v retrieving revision 1.121 diff -u -r1.121 tags.py --- albatross/tags.py 23 Jun 2003 05:10:57 -0000 1.121 +++ albatross/tags.py 4 Jul 2003 01:47:12 -0000 @@ -142,7 +142,10 @@ if name: ctx.write_content(' name="%s"' % name) if value is not None: - ctx.write_content(' value="%s"' % escape(value)) + if self.has_attrib('noescape'): + ctx.write_content(' value="%s"' % value) + else: + ctx.write_content(' value="%s"' % escape(value)) if not self.has_attrib('disabled'): ctx.input_add(self.__itype, name, value, self.has_attrib('list')) @@ -248,7 +251,11 @@ def to_html(self, ctx): ctx.write_content('') # Using the albatross
tag allows Albatross to record the @@ -369,7 +376,10 @@ if type(item) is type(()): ctx.write_content(' value="%s"' % escape(value)) ctx.write_content('>') - ctx.write_content(escape(text)) + if self.has_attrib('noescape'): + ctx.write_content(text) + else: + ctx.write_content(escape(text)) ctx.write_content('') ctx.write_content('\n') @@ -395,6 +405,8 @@ value = ctx.get_value(name) if not value: ctx.write_content('') + elif self.has_attrib('noescape'): + ctx.write_content(value) else: ctx.write_content(escape(value)) else: --=-=-= -- http://www.object-craft.com.au --=-=-=-- From djc at object-craft.com.au Fri Jul 4 02:45:04 2003 From: djc at object-craft.com.au (Dave Cole) Date: 04 Jul 2003 12:45:04 +1000 Subject: [albatross-users] Standalone HTTP Albatross server In-Reply-To: <1057006507.14170.12.camel@localhost> References: <1056331020.29342.79.camel@localhost> <1057006507.14170.12.camel@localhost> Message-ID: >>>>> "Matt" == Matt Goodall writes: Matt> On Sun, 2003-06-29 at 12:02, Dave Cole wrote: >> Andrew, do you think we should put this into Albatross now? Matt> I just remembered that there is a possible bug in Albatross Matt> 1.10pre1 that breaks this. I can send a patch against 1.10pre1 Matt> if it would help? Matt> See here for more: Matt> http://object-craft.com.au/pipermail/albatross-users/2003-June/000460.html Yup. I am supposed to fix that this weekend so I can release 1.10pre2... You are more than welcome to beat me to it... - Dave -- http://www.object-craft.com.au From dougal.scott at member.sage-au.org.au Fri Jul 4 06:50:11 2003 From: dougal.scott at member.sage-au.org.au (dougal.scott@member.sage-au.org.au) Date: Fri, 04 Jul 2003 16:50:11 +1000 Subject: [albatross-users] Newbie question Message-ID: <20030704065011.7E8784EE3E@koro.off.connect.com.au> In order to better learn Albatross I'm converting an existing cgi. This is a fairly simple cgi which gets some info from the user and then calls itself a few times with different options to generate some embedded images. I'm having problems converting this to Albatross. How do I repeatedly pass a different context to another module. I can do it the bad way by generating an expression that is an img tag such as "". This involves going through the locals and generating the arguments from that - and adding some other ones, in this case imgtype. However this is a hack and I would prefer to do it neatly. Also it means that the context is accepted from the URL, where I would prefer it not to be, so people can't play with the options. This is where either Albatross or my limited understanding of Albatross breaks down. Albatross seems to be based around the concept of a page - and one invocation of a module per page. What I need is multiple modules being invoked to generate a single page. Can anyone point me in the right direction? -- Dougal Scott Connect Internet Solutions dwagon@connect.com.au 180-188 Burnley Street Senior Systems Administrator Richmond, Australia, 3121 From gnb at itga.com.au Fri Jul 4 08:09:00 2003 From: gnb at itga.com.au (Gregory Bond) Date: Fri, 04 Jul 2003 18:09:00 +1000 Subject: [albatross-users] Newbie question In-Reply-To: Your message of Fri, 04 Jul 2003 16:50:11 +1000. Message-ID: <200307040809.SAA18580@lightning.itga.com.au> > In order to better learn Albatross I'm converting an existing cgi. This > is a fairly simple cgi which gets some info from the user and then > calls itself a few times with different options to generate some > embedded images. Hmmm... AFAICT this is not the sort of application where Albatross shines, so I'm not real surprised you are running into some conceptual issues. About the best thing that springs to mind is to have the main app generate the images into a temp directory before spitting out the HTML, then reference them with a call to a simple (non-Albatross) cgi that simply returns the cached image. Another approach might be to use a Random app which is much more tolerant of unusual page orders. Have a "page" called "images" in the trandom app that doesn't update the session state, but creates and returns the requested image based on session info, then refer to them from the "main" page with something like "..../application?image=1" (Random apps are not as well documented as the non-Random versions, and they have quite a different design.) From matt at pollenation.net Fri Jul 4 09:20:02 2003 From: matt at pollenation.net (Matt Goodall) Date: Fri, 04 Jul 2003 10:20:02 +0100 Subject: [albatross-users] Standalone HTTP Albatross server In-Reply-To: References: <1056331020.29342.79.camel@localhost> <1057006507.14170.12.camel@localhost> Message-ID: <3F0546C2.2010606@pollenation.net> This is a multi-part message in MIME format. --------------060906010806030007050909 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit Dave Cole wrote: >Yup. I am supposed to fix that this weekend so I can release >1.10pre2... You are more than welcome to beat me to it... > Patch attached, it should apply to the 1.10pre release using "cat base_url.patch | patch --strip 0". Cheers, Matt p.s. how do you avoid the need for --strip? -- Matt Goodall, Pollenation Internet Ltd e: matt@pollenationinternet.com --------------060906010806030007050909 Content-Type: text/plain; name="base_url.patch" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="base_url.patch" diff -ru ./albatross/app.py ../albatross-1.10pre1-patched/albatross/app.py --- ./albatross/app.py 2003-06-07 06:16:51.000000000 +0100 +++ ../albatross-1.10pre1-patched/albatross/app.py 2003-07-04 10:10:34.000000000 +0100 @@ -206,7 +206,11 @@ def __init__(self, base_url): ResourceMixin.__init__(self) apply(self.register_tagclasses, tags.tags) - self.__base_url = base_url + # Use a base_url of '/' if not provided + if base_url: + self.__base_url = base_url + else: + self.__base_url = '/' def run(self, req): '''Process a single browser request diff -ru ./albatross/randompage.py ../albatross-1.10pre1-patched/albatross/randompage.py --- ./albatross/randompage.py 2003-01-27 10:23:27.000000000 +0000 +++ ../albatross-1.10pre1-patched/albatross/randompage.py 2003-07-04 09:56:27.000000000 +0100 @@ -21,7 +21,7 @@ try: base_path = urlparse.urlparse(self.base_url())[2] uri_path = urlparse.urlparse(uri)[2] - page = string.split(uri_path, base_path + '/', 1)[1] + page = string.split(uri_path, base_path, 1)[1] except IndexError: pass if not page: --------------060906010806030007050909-- From matt at pollenation.net Fri Jul 4 09:52:20 2003 From: matt at pollenation.net (Matt Goodall) Date: Fri, 04 Jul 2003 10:52:20 +0100 Subject: [albatross-users] New version of the standalone http server In-Reply-To: References: <1057196415.18669.41.camel@localhost> Message-ID: <3F054E54.5000308@pollenation.net> Please feel free to include it in Albatross, that would obviously benefit me. I think the only thing that is missing is the file upload support but I still hope to fix that. I don't really have a strong feeling on your change but it seems that making the application's module create an app object may make it less flexible although your solution is definitely the simplest and, as you point out, involves only a trivial change to the code. An even better solution might be to split al-httpd into a module, say albatross.server.httpd, leaving only the __main__ code in al-httpd itself. Applications could then create an instance of the http server manually *if necessary* or use al-httpd in the same way as now. I see the mod_python vs cgi vs fcgi vs httpd as a deployment decision and nothing much to do with the application code itself or in other words ... who hows how someone might want to deploy an application based on Albatross on their server. I'm not sure if I have explained that too well but what I can imagine doing is having a series of startup scripts for the application depending on how I'm using it (i.e. dev vs prod). Sometime like this (completely untested): -- standalone.py -- from albatross.server import httpd import myapp app = myapp.App(base_url = '/', base_dir = '/home/matt/src/myapp') httpd = httpd.HTTPServer(app, 8000) httpd.serve_forever() -- -- app.py -- from albatross import cgiapp import myapp app = myapp.App(base_url = '/dev/myapp/app.py', base_dir = '/home/matt/src/myapp') app.run(cgiapp.Request()) -- etc What are your thoughts on this? I will split the al-httpd script up today, as detailed above, if you think it's a good approach, or if you want to keep it simple, I'm happy with that too. Cheers, Matt Dave Cole wrote: >>Attached is an updated version of the standalone server with the >>following changes: >> >> * Fixed to support forms containing input fields with a "list" >> attribute. It only ever returned the first value in the get or >> post data before. >> * Added the current working directory to the path so that the >> httpd.py script can live anywhere. >> * changed the filename to al-httpd. An even better name might be >> al-simple-server. >> >> > >It works beautifully. I would love to add this to Albatross to sit >next to your FastCGI code. > >I made one small change to your code to make it a bit more flexible (I >hope). I let the application mainline construct the application >object. > >--- al-httpd-orig 2003-07-03 23:09:30.000000000 +1000 >+++ al-httpd 2003-07-03 23:07:18.000000000 +1000 >@@ -149,7 +149,7 @@ > > # Load the application's module and create an application instance > module = __import__(appClass[:appClass.rindex('.')]) >- app = getattr(module,appClass[appClass.rindex('.')+1:])() >+ app = getattr(module,appClass[appClass.rindex('.')+1:]) > > # Create the HTTP server > httpd = HTTPServer(app, port) > >Now with the most trivial change to the form4 Albatross sample it >works fantastically. > >--- samples/form4/form.py 2002-08-17 23:14:36.000000000 +1000 >+++ form.py 2003-07-03 23:13:40.000000000 +1000 >@@ -19,4 +19,5 @@ > secret = '-=-secret-=-') > app.register_page('form', Form()) > >-app.run(Request()) >+if __name__ == '__main__': >+ app.run(Request()) > >Now due to you code I can do this: > >$ al-httpd form.app 8080 > >That is cool! > >- Dave > > > -- Matt Goodall, Pollenation Internet Ltd e: matt@pollenationinternet.com t: 0113 2252500 From andrewm at object-craft.com.au Fri Jul 4 10:52:09 2003 From: andrewm at object-craft.com.au (Andrew McNamara) Date: Fri, 04 Jul 2003 20:52:09 +1000 Subject: [albatross-users] Newbie question In-Reply-To: Message from dougal.scott@member.sage-au.org.au of "Fri, 04 Jul 2003 16:50:11 +1000." <20030704065011.7E8784EE3E@koro.off.connect.com.au> References: <20030704065011.7E8784EE3E@koro.off.connect.com.au> Message-ID: <20030704105209.793393C332@coffee.object-craft.com.au> >I can do it the bad way by generating an expression that is an img tag >such as "". This >involves going through the locals and generating the arguments from >that - and adding some other ones, in this case imgtype. That suggests to me that you're using the hidden field session mixin - if you use a server side session mixin, the session will be available when the image is loaded (just be aware that the browser will probably try to load multiple images at the same time, resulting in multiple processes accessing the one session, which can cause a mess). A similar problem occurs in applications using frames - it can be done, although more care than usual is needed (all frames dispatch through one albatross page, with a hidden field in each frame signalling to the app which is being loaded). The alternative you suggest is okay - I've used it in apps. If security is a problem, you can use md5 hashes to create a hard to guess expression. Greg Bond's suggestion is also a good one which I've used in Albatross apps before: the main application generates all the images and places them where they can be fetched as htdocs (rather than cgi). Again, md5 hashes can be used to obscure filenames. Some mechanism will be needed to clean the files up after use (older than 5 minutes, etc). This option will result in less load on the web server. -- Andrew McNamara, Senior Developer, Object Craft http://www.object-craft.com.au/ From esj at harvee.org Fri Jul 4 12:17:56 2003 From: esj at harvee.org (Eric S. Johansson) Date: Fri, 04 Jul 2003 08:17:56 -0400 Subject: [albatross-users] check boxes again. In-Reply-To: References: <200307040004.KAA08163@lightning.itga.com.au> <3F04C9C2.1020308@harvee.org> Message-ID: <3F057074.7070205@harvee.org> Dave Cole wrote: > You might be able to get closer what you want by using the alias > attribute. > > http://www.object-craft.com.au/projects/albatross/albatross/tag-input-alias.html I'm probably being entirely too dim again but it looks like alias is useful for unique names for the checkbox. I'm not sure how it answers my questions about getting checkbox is in the right state. If you look at: http://harvee.org/greeneggs/retrain.cgi you will see that I've managed to accomplish this goal using the following technique. ... ... and on submit, I get a list of tokens that have been checked. If I follow suggestions given another messages, I should be able to store a list of all tokens as a hidden or session variable and then by simple process of illumination, figure out what wasn't checked. Like I said, ugly, tedious, but not horrible. I can live with it. After all, the goal is to get the job done so I can get out the next release of this antispam system. I still need to solve how to dynamically shift the auto approval and auto trash limits as one trains the Bayesian portion of the system. I keep trying to reduce the administrator's workload and I've put far more work into the Bayesian side than the sender pays side because Bayesian filters are that much more flaky/touchy-feely/squishy etc. but seriously Dave, please consider adding some form of option to allow for direct setting of checked or not checked (extension of checked attribute perhaps) and for listing all checkboxes. ---eric onward and upward From djc at object-craft.com.au Fri Jul 4 13:11:04 2003 From: djc at object-craft.com.au (Dave Cole) Date: 04 Jul 2003 23:11:04 +1000 Subject: [albatross-users] New version of the standalone http server In-Reply-To: <3F054E54.5000308@pollenation.net> References: <1057196415.18669.41.camel@localhost> <3F054E54.5000308@pollenation.net> Message-ID: > Please feel free to include it in Albatross, that would obviously > benefit me. I think the only thing that is missing is the file > upload support but I still hope to fix that. > > I don't really have a strong feeling on your change but it seems > that making the application's module create an app object may make > it less flexible although your solution is definitely the simplest > and, as you point out, involves only a trivial change to the code. Your original the harness expected the mainline to define an application class constructor that takes zero arguments. I figured that since a CGI or mod_python app has to create an application object in the mainline anyway, why not just reference that. In other words, all mainlines do something like this: app = AppClass(args_if_any) > An even better solution might be to split al-httpd into a module, > say albatross.server.httpd, leaving only the __main__ code in > al-httpd itself. LOL. That is what I did with your first version before I had understood your al-httpd intention :-). > Applications could then create an instance of the http server > manually *if necessary* or use al-httpd in the same way as now. I > see the mod_python vs cgi vs fcgi vs httpd as a deployment decision > and nothing much to do with the application code itself or in other > words ... who hows how someone might want to deploy an application > based on Albatross on their server. Exactly! The al-httpd program and httpdapp module will be an excellent addition to Albatross. > I'm not sure if I have explained that too well but what I can > imagine doing is having a series of startup scripts for the > application depending on how I'm using it (i.e. dev vs > prod). Sometime like this (completely untested): > > -- standalone.py -- > from albatross.server import httpd > import myapp > > app = myapp.App(base_url = '/', base_dir = '/home/matt/src/myapp') > > httpd = httpd.HTTPServer(app, 8000) > httpd.serve_forever() > -- > > -- app.py -- > from albatross import cgiapp > import myapp > > app = myapp.App(base_url = '/dev/myapp/app.py', base_dir = > '/home/matt/src/myapp') > app.run(cgiapp.Request()) > -- > What are your thoughts on this? I will split the al-httpd script up > today, as detailed above, if you think it's a good approach, or if > you want to keep it simple, I'm happy with that too. I agree 100% that it should be split into an importable module and a program to launch applications. Andrew, do you have any excellent ideas about naming of the program and module? Off the top of my head I would like to rename the current session-server directory to tools and place the new al-httpd program in there. I also think that the importable module should probably be called httpdapp and should live side by side with fcgiapp, apacheapp, and cgiapp. Matt, this is different to what you have said above, but I think more consistent with the current layout. - Dave -- http://www.object-craft.com.au From matt at pollenation.net Fri Jul 4 13:32:45 2003 From: matt at pollenation.net (Matt Goodall) Date: Fri, 04 Jul 2003 14:32:45 +0100 Subject: [albatross-users] New version of the standalone http server In-Reply-To: References: <1057196415.18669.41.camel@localhost> <3F054E54.5000308@pollenation.net> Message-ID: <3F0581FD.3060205@pollenation.net> Dave Cole wrote: >>What are your thoughts on this? I will split the al-httpd script up >>today, as detailed above, if you think it's a good approach, or if >>you want to keep it simple, I'm happy with that too. >> >> > >I agree 100% that it should be split into an importable module and a >program to launch applications. > >Andrew, do you have any excellent ideas about naming of the program >and module? > >Off the top of my head I would like to rename the current >session-server directory to tools and place the new al-httpd program >in there. I also think that the importable module should probably be >called httpdapp and should live side by side with fcgiapp, apacheapp, >and cgiapp. > >Matt, this is different to what you have said above, but I think more >consistent with the current layout. > >- Dave > > > Cool, I think this is the best solution overall - the simplicity of al-httpd with the flexibility of the module. If you're happy to make these changes then go ahead but just say if you want me to do anything to help. - Matt -- Matt Goodall, Pollenation Internet Ltd e: matt@pollenationinternet.com From djc at object-craft.com.au Fri Jul 4 13:28:08 2003 From: djc at object-craft.com.au (Dave Cole) Date: 04 Jul 2003 23:28:08 +1000 Subject: [albatross-users] New version of the standalone http server In-Reply-To: <3F0581FD.3060205@pollenation.net> References: <1057196415.18669.41.camel@localhost> <3F054E54.5000308@pollenation.net> <3F0581FD.3060205@pollenation.net> Message-ID: >>>>> "Matt" == Matt Goodall writes: Matt> Cool, I think this is the best solution overall - the simplicity Matt> of al-httpd with the flexibility of the module. If you're happy Matt> to make these changes then go ahead but just say if you want me Matt> to do anything to help. I will wait to see what Andrew says. He always pokes holes in my stoopid ideas. - Dave -- http://www.object-craft.com.au From esj at harvee.org Sat Jul 5 01:07:49 2003 From: esj at harvee.org (Eric S. Johansson) Date: Fri, 04 Jul 2003 21:07:49 -0400 Subject: [albatross-users] check boxes again. In-Reply-To: <200307040110.LAA28357@lightning.itga.com.au> References: <200307040110.LAA28357@lightning.itga.com.au> Message-ID: <3F0624E5.7080104@harvee.org> Gregory Bond wrote: >>Q: how do I get a complete list of all checkboxes checked and unchecked just >>like you can with ordinary CGI > > > Presumably, you get this list from the same place you get the list of all the > items you are adding to the form. (i.e. you need exactly this information to > display the page in the first place, so it can't be that hard!!) I do. When I build the display list, I start out first by scanning the entire set of files in the spamtrap. Then, I pass each file (containing a single e-mail message) to an object which extracts necessary information from the headers and if any errors occur, fill in with appropriate defaults. This object defines" a line" in the display. Each of these line objects are placed on a dictionary. In the process of putting line objects in a dictionary, I build a another list (AKA sort list) containing token and some value to sort on. After sorting, the top N entries are are extracted from the sort list and the token values are used to extract line objects from the dictionary. These line objects are then placed on a list which is given to locals for use in the display template. Simple as 3.14159. > > >>what is the best way to store a chunk of data (i.e. a list) client side? > > > If you add a variable to the session (with ctx.add_session_vars()), then it > will be there for you next time the page_process() function is called. You can > add (almost) any Python datatype to the session, so a vector of strings is > easy. This can be expensive in bandwith if you use client-side sessions, > depending on how much data you add. We use file-based server sessions with up > to 100k of session data to do this sort of thing with no problems at all. this is good to know. It shouldn't be bad. I only expect to see 20 or 30 20 byte entries. > > Perhaps the model you want is something like this (warning: untested): thanks for the clue. not only did it teach me more about when to use page_display and page_process, but it also gave me a clue on how to handle the data. here's my working test fragment. All_tokens is a complete list of all tokens entered into the display list. Albatross_tokens is a list return by the checkbox list of checkboxes checked: for token in context.locals.all_tokens: #syslog.syslog("working on %s"% token) if token in context.locals.albatross_token: syslog.syslog("token is spam %s"% token) else: syslog.syslog("token is NOT spam %s"% token) cool thing is I get a usable data set and since the data set is expected to be in the sub 100 entry range, it shouldn't suck too bad. The worst bit is processing every single piece of e-mail in the spamtrap for headers etc. I shudder to think how bad as it going to be when processing the dumpster (where spamtrap entries go to die) according to age. tomorrow, I'm going to complete moving over the Bayesian discriminator correction code from ad hoc CGI to albatross and declare victory. Many thanks to all you who have helped. I could not have done without you and I hope my commentary helped improve documentation. If there's interest, I will continue the cognitive disconnect series on subsequent chapters. ---eric From korg at darkqueen.org Sat Jul 5 01:57:23 2003 From: korg at darkqueen.org (Cameron Blackwood) Date: Sat, 05 Jul 2003 11:57:23 +1000 Subject: [albatross-users] Re: Albatross-users digest, Vol 1 #186 - 12 msgs In-Reply-To: Your message of "Fri, 04 Jul 2003 16:51:01 +1000." <20030704065101.28833.86489.Mailman@numbat.object-craft.com.au> Message-ID: <200307050157.h651vOo28275@firewall.darkqueen.org> From: dougal.scott@member.sage-au.org.au: | Date: Fri, 04 Jul 2003 16:50:11 +1000 | Subject: [albatross-users] Newbie question | | | In order to better learn Albatross I'm converting an existing cgi. This | is a fairly simple cgi which gets some info from the user and then | calls itself a few times with different options to generate some | embedded images. | | I'm having problems converting this to Albatross. How do I repeatedly | pass a different context to another module. | | I can do it the bad way by generating an expression that is an img tag | such as "". This | involves going through the locals and generating the arguments from | that - and adding some other ones, in this case imgtype. | | However this is a hack and I would prefer to do it neatly. Also it | means that the context is accepted from the URL, where I would prefer | it not to be, so people can't play with the options. | | This is where either Albatross or my limited understanding of Albatross | breaks down. Albatross seems to be based around the concept of a page - | and one invocation of a module per page. What I need is multiple | modules being invoked to generate a single page. | | Can anyone point me in the right direction? I uses something like this [below].... (it may need hacking to get going, but you should be able modify the dict in application to get it starting.. (Oh and modify the urls that are coded into the template). It uses the store_server_side_file (SimpleSessionFileApp) to store context, and uses a URL hack to flag image requests. The function: data=image_generator.map_plot() returns a png. You could pass ctx.locals.whatever to it if you need to or do the processing in the page_display() etc. Often I subclass all my albatross pages from another class so that image checking is less work. This works for me :). PLEASE tell me if Im doing something wrong or abusive of albatross ;) I think it is fine because the template page loads first (and processes any ctx/form changes and then it requests the image, so the image page has the latest context as generated from the last template page). To be really save, I guess you should skip any processing in page_process() if it is an image. Actually, Ive been meaning to ask, is there a way to flush data out of a request and NOT store/process the request? Ie, if it is an image, then just write the data and dont do anything with the context (like save or modify it?). | Dougal Scott Connect Internet Solutions cam -- / `Rev Dr' cam at darkqueen.org Roleplaying, virtual goth \ < http://darkqueen.org Poly, *nix, Python, C/C++, genetics, ATM > \ [+61 3] 9809 1523[h] skeptic, Evil GM(tm). Sysadmin for hire / ---------- Random Quote ---------- Don't go to bed with no price on your head. -- Baretta ------------------- 8< cut ----------------------- #!/usr/bin/python import os,string,re import image_gen from albatross import SimpleSessionFileApp as Albatross_Application from albatross import SessionFileAppContext as Albatross_Context from albatross.cgiapp import Request as Albatross_Request # I used to use this on the url before the click data context # COORDS=re.compile("(?P[0-9][0-9]*),(?P[0-9][0-9]*)") image_generator=image_gen.load('test') PageList={} def addpage(p): PageList[ p.__class__.__name__ ]=p def DEBUG(msg): open("/tmp/debug",'a').write('%s\n'%(msg)) class Start: def page_enter(self, ctx): DEBUG("page entered!!") ctx.locals.username=None ctx.locals.passwd=None ctx.locals.square='morons' ctx.locals.pos=[0,0] ctx.locals.click=None ctx.locals.zoom=None ctx.add_session_vars('username','passwd','square','pos','click') def page_process(s,ctx): DEBUG('b:%s'%(ctx.get_uri())) DEBUG('b:%s'%(ctx.base_url())) DEBUG('c:%s'%(ctx.current_url())) if ctx.locals.zoom: DEBUG("setting zoom = %s"%(ctx.locals.zoom)) image_generator.set_zoom(ctx.locals.zoom) if ctx.locals.click: ctx.locals.pos=[ ctx.locals.pos[0]+ctx.locals.click.x, ctx.locals.pos[1]+ctx.locals.click.y ] ctx.locals.click=None if ctx.locals.square=='tree': DEBUG('tree!!!') DEBUG('%s'%(ctx.locals)) def page_display(self, ctx): page=os.environ['REQUEST_URI'][len(os.environ['SCRIPT_NAME'])+1:] DEBUG("page is %s"%(page)) if page=='map_image': data=image_generator.map_plot() ctx.request.write_header('Content-Type','image/png') ctx.request.write_header('Content-Length',str(len(data))) ctx.request.write_header('Pragma', 'no-cache') DEBUG("image squre %s"%(ctx.locals.square)) ctx.write_content(data) else: DEBUG("page squre %s"%(ctx.locals.square)) ctx.run_template('template_map.html') #class Image: addpage(Start()) #addpage(Image()) ############################################################# # Albatross objects ############################################################# class request(Albatross_Request): def __init__(s): Albatross_Request.__init__(s) class context(Albatross_Context): def __init__(s,app): Albatross_Context.__init__(s,app) class application(Albatross_Application): def __init__(s): dict= { 'base_url':'20circle', 'template_path':'/home/korg/projects/20circle/data/web_template/', 'start_page':'Start', 'secret':'-=-secret-=-', 'session_appid':'dumb', # server file stored 'session_dir':'/tmp/session/', # server file stored } Albatross_Application.__init__(s,**dict) if PageList: for n,v in PageList.items(): s.register_page( n, v ) def create_context(s): ctx=context(s) ctx.load_template('macros.html').to_html(ctx) return ctx def main(): a = application() a.run(request()) if __name__=="__main__": main() ------------------- 8< cut ----------------------- Map screen

Welcome


Games Details:

pos:
pos:
pos:
pos:


From djc at object-craft.com.au Sat Jul 5 02:53:01 2003 From: djc at object-craft.com.au (Dave Cole) Date: 05 Jul 2003 12:53:01 +1000 Subject: [albatross-users] New version of the standalone http server In-Reply-To: References: <1057196415.18669.41.camel@localhost> <3F054E54.5000308@pollenation.net> <3F0581FD.3060205@pollenation.net> Message-ID: >>>>> "Dave" == Dave Cole writes: >>>>> "Matt" == Matt Goodall writes: Matt> Cool, I think this is the best solution overall - the simplicity Matt> of al-httpd with the flexibility of the module. If you're happy Matt> to make these changes then go ahead but just say if you want me Matt> to do anything to help. Dave> I will wait to see what Andrew says. He always pokes holes in Dave> my stoopid ideas. Andrew didn't want me to rename the session-server directory so I have added a new standalone-server directory. In preparing the source I noticed some formatting differences between Albatross and your code. I went to PEP8 and had a read. Albatross is still not PEP8 clean :-(. I might do some minor reformatting. While placing the code into Albatross I realised that there is no copyright on the code. What do you want to do? * Include a Matt Goodall BSD style copyright notice. * Assign the copyright to us so we can just apply the same BSD style notice as is on the rest of the code. Since the code is not ours you need to decide what to do here. Anyway, I have split the mainline out so it now looks like this: - - al-httpd - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - #!/usr/bin/env python import os import sys from albatross import httpdapp if __name__ == '__main__': # Append the current working directory to the path. sys.path.append(os.getcwd()) # Parse the command line. try: app_module, app_object = sys.argv[1].split('.') port = int(sys.argv[2]) except: sys.exit('usage: %s main-module.app-object port' % os.path.basename(sys.argv[0])) # Load the application's module and get application instance. module = __import__(app_module) app = getattr(module, app_object) # Create the HTTP server and serve requests. httpd = httpdapp.HTTPServer(app, port) httpd.serve_forever() - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -- http://www.object-craft.com.au From djc at object-craft.com.au Sat Jul 5 06:18:30 2003 From: djc at object-craft.com.au (Dave Cole) Date: 05 Jul 2003 16:18:30 +1000 Subject: [albatross-users] check boxes again. In-Reply-To: <3F0624E5.7080104@harvee.org> References: <200307040110.LAA28357@lightning.itga.com.au> <3F0624E5.7080104@harvee.org> Message-ID: >>>>> "Eric" == Eric S Johansson writes: Eric> Many thanks to all you who have helped. I could not have done Eric> without you and I hope my commentary helped improve Eric> documentation. If there's interest, I will continue the Eric> cognitive disconnect series on subsequent chapters. Any comment on how the documentation is lacking or could be improved is always welcome. - Dave -- http://www.object-craft.com.au From djc at object-craft.com.au Sat Jul 5 06:34:08 2003 From: djc at object-craft.com.au (Dave Cole) Date: 05 Jul 2003 16:34:08 +1000 Subject: [albatross-users] al-for and Template frustration and confusion In-Reply-To: <1056929696.5434.427.camel@localhost> References: <49126450.1056069096@SHEILA-LAPTOP> <20030620075929.E5F743C332@coffee.object-craft.com.au> <9948525.1056116333@SHEILA-LAPTOP> <981458372.1056843004@goddess> <1056877957.5434.265.camel@localhost> <1056929696.5434.427.camel@localhost> Message-ID: > Introduction > ~~~~~~~~~~~~ > I think the following are either missing or not specifically listed: > - simple and flexible to use (as opposed to the framework itself) Not sure I should add a comment like that :-) > - lightweight enough for cgi Added. > - form population and parsing Added. > Front Matter > ~~~~~~~~~~~~ > Add a "See Also" link to www.fastcgi.com and maybe python.org Added. > 3.5.3 Multiple Argument Macros > ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > This could probably do with a small example anyway. Good point. Will see what I can do. - Dave -- http://www.object-craft.com.au From djc at object-craft.com.au Sat Jul 5 07:50:06 2003 From: djc at object-craft.com.au (Dave Cole) Date: 05 Jul 2003 17:50:06 +1000 Subject: [albatross-users] Standalone HTTP Albatross server In-Reply-To: <3F0546C2.2010606@pollenation.net> References: <1056331020.29342.79.camel@localhost> <1057006507.14170.12.camel@localhost> <3F0546C2.2010606@pollenation.net> Message-ID: > Dave Cole wrote: > >Yup. I am supposed to fix that this weekend so I can release > >1.10pre2... You are more than welcome to beat me to it... > > > Patch attached, it should apply to the 1.10pre release using "cat > base_url.patch | patch --strip 0". > > Cheers, Matt > > p.s. how do you avoid the need for --strip? Applied the patch. Thanks. What I usually do is make sure that my version of the source and the original version share the same parent directory. I can then create a patch from the parent directory like this: $ diff -ru albatross-orig albatross > albatross.patch Then the patch can be applied by doing this from inside the unpacked albatross directory, regardless of whether it is called albatross-orig, albatross-1.10pre1, or albatross. $ patch -sp1 < albatross.patch Someone else might be able to come up with better instructions. - Dave -- http://www.object-craft.com.au From djc at object-craft.com.au Sat Jul 5 08:14:48 2003 From: djc at object-craft.com.au (Dave Cole) Date: 05 Jul 2003 18:14:48 +1000 Subject: [albatross-users] Comments on using examples... In-Reply-To: <20727424.1057236559@SHEILA-LAPTOP> References: <200307030350.h633oWc06073@firewall.darkqueen.org> <20727424.1057236559@SHEILA-LAPTOP> Message-ID: >>>>> "Sheila" == Sheila King writes: Sheila> --On Thursday, July 03, 2003 1:50 PM +1000 Cameron Blackwood Sheila> wrote: >> I dont know about other people, but when I see an example in docs, >> I often like to actually: 1) try it myself 2) modify it 3) use it >> as a base for what I really want to do Sheila> Agree. >> Eg: >> www.object-craft.com.au/projects/albatross/albatross/tag-comment.html >> >> trying it: Hands up anyone who has used albatross in interactive >> mode? Point taken. The interactive examples are a bit of a pain in the freckle to copy and paste, Would it be better if there was a module or class provided that made interactive playing easier? The albatross.Application class traps exceptions and tries to build a tag traceback. It might be nice if something like that was available for playing around outside of applications. Sheila> I primarily used it that way because of two reasons: (1) the Sheila> thing I was trying to learn/master was shown with examples in Sheila> interactive-mode in the documentation. (2) it was quicker to Sheila> do that then modify the app I'm working on for test purposes. >> Interactive python dumps are not much use because: 1) noone would >> ever do that Interactive mode is a useful tool for testing ideas. I think that with the new al-httpd program from Matt Goodall will make some types of testing much easier. Sheila> I assume that you mean here, that no one would use Albatross Sheila> in production in such a manner? However, interactive is mostly Sheila> used (by developers) for testing purposes, even when not Sheila> working with Albatross. At least, that is my take on the Sheila> matter (as a clearly peon developer type). I am always firing up an interactive interpreter to check my understanding of various things in Python. >> 2) you cant cut & paste to test (well you can, but you have to cut >> and paste specific bits (not the output) and you cant cut and paste >> the multi-line examples, thanks to the pythonic '... '/'>>> ', >> without having to be _VERY_ careful about indenting.) Sheila> Agree that c&p is much more difficult/annoying from the Sheila> interactive examples. The examples are formatted like that so that a testing program can run the samples and ensure that the correct output is produced. This has the benefit of ensuring that the documentation is always correct. It also provides more unit tests for the toolkit. We could probably change the testing program so that it used two files; a .py file and a .out file. This would allow us to change something like doctest/tags-if1 from - - doctest/tags-if1 - - - - - - - - - - - - - - - - - - - - - - - - >>> import albatross >>> ctx = albatross.SimpleContext('.') >>> ctx.locals.a = 10 >>> albatross.Template(ctx, '', ''' ... ... a () is less than 15. ... ... a () is greater than or equal to 15. ... ... ''').to_html(ctx) >>> ctx.flush_content() a (10) is less than 15. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - to this: - - doctest/tags-if1.py - - - - - - - - - - - - - - - - - - - - - - import albatross # Create an execution context for evaluating templates and place a # value into the local namespace. ctx = albatross.SimpleContext('.') ctx.locals.a = 10 # Evaluate an inline template. albatross.Template(ctx, '', ''' a () is less than 15. a () is greater than or equal to 15. ''').to_html(ctx) # Display the template output. ctx.flush_content() - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - doctest/tags-if1.out - - - - - - - - - - - - - - - - - - - - - - a (10) is less than 15. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Oh, I think that the doctext samples should be documented too. Sheila> I also found the amount of interactive examples in the Sheila> documentation to be ... uh ... not what I would have preferred Sheila> to see. Some of it is good, or I might not have even realized Sheila> how to run Albatross interactively (or even thought of it as Sheila> being possible). I do think some examples of running it Sheila> interactively are good, in order to make this point. Perhaps Sheila> put it into a small section of the documentation, as it's own Sheila> topic: "Running Albatross in Python Interactive Mode" and then Sheila> a few examples showing how to do that. And then convert the Sheila> rest of the interactive examples in the documentation to Sheila> downloadable/runable files. Good idea. Sheila> BTW, something I never mentioned but that bugged me in the Sheila> docs: Sheila> The use of the '' context in the interactive Sheila> examples. Bugged the crud out of me as to what it was, why it Sheila> was named that way, why it worked. Eventually just accepted it Sheila> as black magic and moved on, but wasn't really happy with Sheila> having to do that. It was a stupid joke. There is nothing magic about it - it is just a fake filename. When you run Python interactively and case an exception Python calls interactive input ''. >>> 1/0 Traceback (most recent call last): File "", line 1, in ? ZeroDivisionError: integer division or modulo by zero Sheila> The examples being currently uploaded to the Wiki may make up Sheila> for the "short coming" of having so many of the Sheila> documentation's examples shown as interactive mode. Sheila> I also want to re-iterate that I find the Albatross product Sheila> (and its docs) to be first rate, and only make negative Sheila> comments at all in the hope of offering feedback for Sheila> improvement of an already fine project. Thanks for the feedback. If people think that the above changes to the doctest samples make sense then I will change them. - Dave -- http://www.object-craft.com.au From djc at object-craft.com.au Sat Jul 5 09:00:23 2003 From: djc at object-craft.com.au (Dave Cole) Date: 05 Jul 2003 19:00:23 +1000 Subject: [albatross-users] Proposed changes to Albatross placed in wiki Message-ID: Rather than have all of these proposals fade into obscurity I have created a new page where they can be catalogued and discussed. http://www.object-craft.com.au/projects/albatross/wiki/ProposedChanges - Dave -- http://www.object-craft.com.au From matt at pollenation.net Sat Jul 5 09:27:44 2003 From: matt at pollenation.net (Matt Goodall) Date: 05 Jul 2003 10:27:44 +0100 Subject: [albatross-users] New version of the standalone http server In-Reply-To: References: <1057196415.18669.41.camel@localhost> <3F054E54.5000308@pollenation.net> <3F0581FD.3060205@pollenation.net> Message-ID: <1057397238.8364.11.camel@localhost> On Sat, 2003-07-05 at 03:53, Dave Cole wrote: > In preparing the source I noticed some formatting differences between > Albatross and your code. I went to PEP8 and had a read. Albatross is > still not PEP8 clean :-(. I might do some minor reformatting. I must read that PEP myself. > While placing the code into Albatross I realised that there is no > copyright on the code. What do you want to do? > > * Include a Matt Goodall BSD style copyright notice. > > * Assign the copyright to us so we can just apply the same BSD style > notice as is on the rest of the code. > > Since the code is not ours you need to decide what to do here. I hereby assign the copyright to you to be included in Albatross under the same licence as the rest of the project. Seems easier that way ;-). By the way the LICENSE file says (c) 2002. It would be nice if my name and email address appeared in the header, similar to the header you added to the fcgi module. Cheers, Matt -- Matt Goodall, Pollenation Internet Ltd w: http://www.pollenation.net e: matt@pollenation.net From matt at pollenation.net Sat Jul 5 09:39:23 2003 From: matt at pollenation.net (Matt Goodall) Date: 05 Jul 2003 10:39:23 +0100 Subject: [albatross-users] al-for and Template frustration and confusion In-Reply-To: References: <49126450.1056069096@SHEILA-LAPTOP> <20030620075929.E5F743C332@coffee.object-craft.com.au> <9948525.1056116333@SHEILA-LAPTOP> <981458372.1056843004@goddess> <1056877957.5434.265.camel@localhost> <1056929696.5434.427.camel@localhost> Message-ID: <1057397962.30521.24.camel@localhost> On Sat, 2003-07-05 at 07:34, Dave Cole wrote: > > Introduction > > ~~~~~~~~~~~~ > > I think the following are either missing or not specifically listed: > > - simple and flexible to use (as opposed to the framework itself) > > Not sure I should add a comment like that :-) Hah, I'm not sure I worded that very well :). Probably one of my late night sessions again. I /think/ what I was trying to highlight is that the intro talks of an "application framework which is flexible and extensible". What I was trying (very, very badly) to say is that the application code itself is very simple and flexible ... as opposed to the framework code. Is that better? Nah, probably best to just ignore me on this ;-). Cheers, Matt -- Matt Goodall, Pollenation Internet Ltd w: http://www.pollenation.net e: matt@pollenation.net From matt at pollenation.net Sat Jul 5 09:51:01 2003 From: matt at pollenation.net (Matt Goodall) Date: 05 Jul 2003 10:51:01 +0100 Subject: [albatross-users] Comments on using examples... In-Reply-To: References: <200307030350.h633oWc06073@firewall.darkqueen.org> <20727424.1057236559@SHEILA-LAPTOP> Message-ID: <1057398661.8364.35.camel@localhost> On Sat, 2003-07-05 at 09:14, Dave Cole wrote: > Thanks for the feedback. If people think that the above changes to > the doctest samples make sense then I will change them. Yeah, I think what Sheila says makes a lot of sense. I don't think I have ever copy and pasted code from the documentation but the interactive style code certainly makes it harder for me to read. It might be a bit stupid sometimes but at first I prefer to write *all* code myself using the documentation as a reference. I tend to find I understand things better that way. That's the reason I dislike most IDE let-us-do-it-all-for-you tools too. Cheers, Matt -- Matt Goodall, Pollenation Internet Ltd w: http://www.pollenation.net e: matt@pollenation.net From djc at object-craft.com.au Sat Jul 5 10:27:57 2003 From: djc at object-craft.com.au (Dave Cole) Date: 05 Jul 2003 20:27:57 +1000 Subject: [albatross-users] New version of the standalone http server In-Reply-To: <1057397238.8364.11.camel@localhost> References: <1057196415.18669.41.camel@localhost> <3F054E54.5000308@pollenation.net> <3F0581FD.3060205@pollenation.net> <1057397238.8364.11.camel@localhost> Message-ID: >>>>> "Matt" == Matt Goodall writes: Matt> On Sat, 2003-07-05 at 03:53, Dave Cole wrote: >> In preparing the source I noticed some formatting differences >> between Albatross and your code. I went to PEP8 and had a read. >> Albatross is still not PEP8 clean :-(. I might do some minor >> reformatting. Matt> I must read that PEP myself. >> While placing the code into Albatross I realised that there is no >> copyright on the code. What do you want to do? >> >> * Include a Matt Goodall BSD style copyright notice. >> >> * Assign the copyright to us so we can just apply the same BSD >> style notice as is on the rest of the code. >> >> Since the code is not ours you need to decide what to do here. Matt> I hereby assign the copyright to you to be included in Albatross Matt> under the same licence as the rest of the project. Seems easier Matt> that way ;-). By the way the LICENSE file says (c) 2002. Matt> It would be nice if my name and email address appeared in the Matt> header, similar to the header you added to the fcgi module. Thanks. That makes it easy. I have added this to the top of the files: # # Copyright 2003 by Object Craft P/L, Melbourne, Australia. # # LICENCE - see LICENCE file distributed with this software for details. # # AUTHOR(S) # Matt Goodall - Dave -- http://www.object-craft.com.au From djc at object-craft.com.au Sat Jul 5 10:41:40 2003 From: djc at object-craft.com.au (Dave Cole) Date: 05 Jul 2003 20:41:40 +1000 Subject: [albatross-users] al-for and Template frustration and confusion In-Reply-To: References: <49126450.1056069096@SHEILA-LAPTOP> <20030620075929.E5F743C332@coffee.object-craft.com.au> <9948525.1056116333@SHEILA-LAPTOP> <981458372.1056843004@goddess> <1056877957.5434.265.camel@localhost> <1056929696.5434.427.camel@localhost> Message-ID: >>>>> "Dave" == Dave Cole writes: >> 3.5.3 Multiple Argument Macros ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ >> This could probably do with a small example anyway. Dave> Good point. Will see what I can do. Added a small example. - Dave -- http://www.object-craft.com.au From djc at object-craft.com.au Sat Jul 5 11:11:34 2003 From: djc at object-craft.com.au (Dave Cole) Date: 05 Jul 2003 21:11:34 +1000 Subject: [albatross-users] Albatross 1.10 pre2 released In-Reply-To: References: Message-ID: I have just packaged up the 1.10pre2 release of Albatross. This resolves the problems encountered in the 1.10pre1 release and includes some very useful extra functionality. The changes since 1.10pre1 are: * Standalone BaseHTTPServer support. * mod_python Request now works with mod_python 2 and 3. * Python 2.2 features have been reverted to Python 2.1 equivalents. * Reintroduced TemplateLoadError as subclass of ApplicationError. * Nested tags now raise ApplicationError. * Added noescape to , , , and . * Implemented lazy attribute expression compilation in all tags. * Now using Python-2.3 for building documentation. * Minor reformatting to be closer to PEP-8. We are now including a summary of changes between releases in the back of the manual. http://www.object-craft.com.au/projects/albatross/albatross/changes.html There still is no documentation of the FastCGI and Standalone BaseHTTPServer support. I will try to add some documentation for these additions before the 1.10 final release. Our intention is to make this the last pre release of 1.10. This time next week we will release the real 1.10. - Dave -- http://www.object-craft.com.au From esj at harvee.org Sat Jul 5 12:40:18 2003 From: esj at harvee.org (Eric S. Johansson) Date: Sat, 05 Jul 2003 08:40:18 -0400 Subject: [albatross-users] Proposed changes to Albatross placed in wiki In-Reply-To: References: Message-ID: <3F06C732.3070902@harvee.org> Dave Cole wrote: > Rather than have all of these proposals fade into obscurity I have > created a new page where they can be catalogued and discussed. > > http://www.object-craft.com.au/projects/albatross/wiki/ProposedChanges I've updated ClassRenaming to include the more descriptive names floated by Cameron. Personally I find them more useful (and speakable) in contrast to the first set of proposed changes. Since I don't know enough about the current classes to flush out the set, I'm hoping somebody else will ---eric From matt at pollenation.net Sat Jul 5 20:43:15 2003 From: matt at pollenation.net (Matt Goodall) Date: 05 Jul 2003 21:43:15 +0100 Subject: [albatross-users] [wiki] simple example to display a list and allow sorting and filtering Message-ID: <1057437185.6158.4.camel@localhost> I just added a new example, http://www.object-craft.com.au/projects/albatross/wiki/Data_20Presentation, that demonstrates getting a list of people from a datastore (of sorts), displaying the list, sorting the list by clicking on a table header and a simple list filter. Could whoever added, "data presentation from a database or whatever source comes to your mind with some form processing for sorting columns and filtering data", to the RequestsForContent page have a look through and see if it makes sense. Cheers, Matt -- Matt Goodall, Pollenation Internet Ltd w: http://www.pollenation.net e: matt@pollenation.net From matt at pollenation.net Sat Jul 5 23:32:41 2003 From: matt at pollenation.net (Matt Goodall) Date: 06 Jul 2003 00:32:41 +0100 Subject: [albatross-users] more data tricks for the wiki In-Reply-To: References: <200307030144.LAA14395@lightning.itga.com.au> <3F038F94.5040902@harvee.org> <3F03F12B.2080102@pollenation.net> <3F043063.3060808@harvee.org> Message-ID: <1057447961.6158.23.camel@localhost> On Fri, 2003-07-04 at 01:42, Dave Cole wrote: > >>>>> "Eric" == Eric S Johansson writes: > > Eric> what's interesting is the difference in terms of what is > Eric> returned. An albatross, it's an iterator object; in Python > Eric> iterators (as demonstrated by examples in the article referenced > Eric> above) it's an ordinary piece of data (integer, float, string > Eric> etc.). > > One of the limitations that Albatross has to live with is that real > iterators and generators cannot be pickled. This means that they > cannot be saved in a session. If you use pagination in your > tag the ListIterator is placed in the session so it can "remember" > where you were in the sequence. Hmm, so the ListIterator is stored in the session and the ListIterator contains a reference to the sequence being iterated over. Does that mean that the whole sequence will be pickled, i.e. the entire result set from a database query perhaps? > Thinking out loud: > > Currently pagination is handled by saving a ListIterator in the > session. The browser request then issues a nextpage or prevpage > request and names the iterator. > > next > > > results in > > next > > > Maybe a better way to do this would be to place all of the information > required for pagination into the browser request. This would result > in output that looked something like this > > next > > > The nice outcome of this would be that we do not need to save anything > in the session anymore. It would also allow you to bookmark specific > pages in an application. I was thinking of implementing this just the other day although my reason for wanting purely request based paging was that clicking the next page link and then using the browser's refresh button makes the ListIterator jump forward another page. My only thought so far on this matter is to add a scope attribute to the tag whose default value is "session", "request" being the other choice. Cheers, Matt -- Matt Goodall, Pollenation Internet Ltd w: http://www.pollenation.net e: matt@pollenation.net From matt at pollenation.net Sun Jul 6 00:02:18 2003 From: matt at pollenation.net (Matt Goodall) Date: 06 Jul 2003 01:02:18 +0100 Subject: [albatross-users] more data tricks for the wiki In-Reply-To: <1057447961.6158.23.camel@localhost> References: <200307030144.LAA14395@lightning.itga.com.au> <3F038F94.5040902@harvee.org> <3F03F12B.2080102@pollenation.net> <3F043063.3060808@harvee.org> <1057447961.6158.23.camel@localhost> Message-ID: <1057449738.28875.28.camel@localhost> On Sun, 2003-07-06 at 00:32, Matt Goodall wrote: > On Fri, 2003-07-04 at 01:42, Dave Cole wrote: > > >>>>> "Eric" == Eric S Johansson writes: > > > > Eric> what's interesting is the difference in terms of what is > > Eric> returned. An albatross, it's an iterator object; in Python > > Eric> iterators (as demonstrated by examples in the article referenced > > Eric> above) it's an ordinary piece of data (integer, float, string > > Eric> etc.). > > > > One of the limitations that Albatross has to live with is that real > > iterators and generators cannot be pickled. This means that they > > cannot be saved in a session. If you use pagination in your > > tag the ListIterator is placed in the session so it can "remember" > > where you were in the sequence. > > Hmm, so the ListIterator is stored in the session and the ListIterator > contains a reference to the sequence being iterated over. Does that mean > that the whole sequence will be pickled, i.e. the entire result set from > a database query perhaps? The answer is ... no. Phew ;-). ListIterator has a __getstate__ method so only the start and pagesize are pickled. Cheers, Matt -- Matt Goodall, Pollenation Internet Ltd w: http://www.pollenation.net e: matt@pollenation.net From matt at pollenation.net Sun Jul 6 00:17:52 2003 From: matt at pollenation.net (Matt Goodall) Date: 06 Jul 2003 01:17:52 +0100 Subject: [albatross-users] check boxes again. In-Reply-To: <3F04C9C2.1020308@harvee.org> References: <200307040004.KAA08163@lightning.itga.com.au> <3F04C9C2.1020308@harvee.org> Message-ID: <1057450672.19240.37.camel@localhost> On Fri, 2003-07-04 at 01:26, Eric S. Johansson wrote: > Q: how do I get a complete list of all checkboxes checked and unchecked just > like you can with ordinary CGI Are you sure CGI does this? As far as I was aware browsers only send a request parameter for a checkbox when it is checked. If the browser doesn't send a request parameter how can CGI even know there were unchecked checkboxes on the page? Perhaps the browser behaves differently when the form data is posted? - Matt -- Matt Goodall, Pollenation Internet Ltd w: http://www.pollenation.net e: matt@pollenation.net From matt at pollenation.net Sun Jul 6 00:49:03 2003 From: matt at pollenation.net (Matt Goodall) Date: 06 Jul 2003 01:49:03 +0100 Subject: [albatross-users] check boxes again. In-Reply-To: <3F057074.7070205@harvee.org> References: <200307040004.KAA08163@lightning.itga.com.au> <3F04C9C2.1020308@harvee.org> <3F057074.7070205@harvee.org> Message-ID: <1057452543.19240.53.camel@localhost> On Fri, 2003-07-04 at 13:17, Eric S. Johansson wrote: > but seriously Dave, please consider adding some form of option to allow for > direct setting of checked or not checked (extension of checked attribute > perhaps) and for listing all checkboxes. Isn't this exactly the sort of thing the NameRecorderMixin could do? It is already told about every input that is added to a form so it could potentially track the values of inputs with the list attribute, pickle that into the hidden form form field and use it again when merge_request is called. There are two problems I can see with this though: * For large forms, the amount of hidden data would increase significantly. * The state of the checkboxes is passed to page_process as a list of the checked values. That would probably have to change to a dictionary to pass checked and unchecked in the same structure. That's a nasty change to make :(. Just my thoughts ... I may have completely misunderstood the NameRecorderMixin's purpose. Cheers, Matt -- Matt Goodall, Pollenation Internet Ltd w: http://www.pollenation.net e: matt@pollenation.net From djc at object-craft.com.au Sun Jul 6 01:30:29 2003 From: djc at object-craft.com.au (Dave Cole) Date: 06 Jul 2003 11:30:29 +1000 Subject: [albatross-users] more data tricks for the wiki In-Reply-To: <1057447961.6158.23.camel@localhost> References: <200307030144.LAA14395@lightning.itga.com.au> <3F038F94.5040902@harvee.org> <3F03F12B.2080102@pollenation.net> <3F043063.3060808@harvee.org> <1057447961.6158.23.camel@localhost> Message-ID: >>>>> "Matt" == Matt Goodall writes: >> Maybe a better way to do this would be to place all of the >> information required for pagination into the browser request. This >> would result in output that looked something like this >> >> next >> >> >> The nice outcome of this would be that we do not need to save >> anything in the session anymore. It would also allow you to >> bookmark specific pages in an application. Matt> I was thinking of implementing this just the other day although Matt> my reason for wanting purely request based paging was that Matt> clicking the next page link and then using the browser's refresh Matt> button makes the ListIterator jump forward another page. Matt> My only thought so far on this matter is to add a scope Matt> attribute to the tag whose default value is "session", Matt> "request" being the other choice. I think that the "goto,i,n" form is superior. Makes me wonder why I didn't think of it to begin with. If the goto form was available I cannot think of any reason why you would want the current "nextpage,i" form. - Dave -- http://www.object-craft.com.au From djc at object-craft.com.au Sun Jul 6 02:01:01 2003 From: djc at object-craft.com.au (Dave Cole) Date: 06 Jul 2003 12:01:01 +1000 Subject: [albatross-users] Comments on using examples... In-Reply-To: <200307030350.h633oWc06073@firewall.darkqueen.org> References: <200307030350.h633oWc06073@firewall.darkqueen.org> Message-ID: > Eg: www.object-craft.com.au/projects/albatross/albatross/tag-comment.html [snip] > Actually I just noticed that there is no output for that example. > In that case, shouldnt the example be > ... this will is here > ... > ... this isnt... > ... > ... and so is this. > > The comment should be one of the easiest examples. Good point. > I think Id much rather (for the simple examples) see > something like: > 'I would never do anything ' > renders to > 'I would never do anything bad ' How about a module in Albatross that contained useful interactive utilities. I figure that a function like the following might be sufficient for the above: def run_templ(text, ctx=None): if ctx is None: ctx = albatross.SimpleContext('.') albatross.Template(ctx, '', text).to_html(ctx) ctx.flush_content() This would allow you to do this: >>> from albatross.fiddle import * >>> run_templ('I would never do anything ') It would probably be a bit more sophisticated than the above to allow exceptions to be caught and reported with a template traceback. What should the module be called, and what functions should be in it? > Two lines.. excellent, I understanded al-owned now. > > Using a non silly example, which is more helpful than the listed > comment example: > 'pre middle post' > renders to: > 'pre post' > This example illustrates what happens with pre and post and > also spacing. Another good point. I have changed the example. > And the complex examples? I'd probably rather actual files that > I can download, install and run. That way I can modify them > and play! OK. I should have a go at changing the doctest samples to split them into .py and .out files. > Eg: www.object-craft.com.au/projects/albatross/albatross/tug-form2.html > > Who does import 'cgi' with albatross code? I dont. (Should I?) > I guess Im trying to ask who actually codes like that? > > Neat. 'setattr(ctx.locals, name, value)'. Especially now we all > understand ctx.locals :). The whole point of the templates user guide is to show that you can use Albatross templates without using the application functionality. Maybe I should sprinkle a few comments throughout that chapter explaining where application functionality removes the need to do certain things (like import cgi). > Eg: www.object-craft.com.au/projects/albatross/albatross/tug-form1.html > > "Using Forms to Receive User Input" is where I would first look > to see how to read input into my program. > > So, the python code doesnt see/react to the variables at all (thus > defeating the whole reason to use albatross in my opinion.) > > [I guess this example is saying, "you dont need python to use > form input". Yeah, ok. and I'd do that why? (I guess for some > simple UI details, but that is a clever hack, not the main > reason Im using Albatross)] There might be some people who would use Albatross just for the templating. It is doubtful though. - Dave -- http://www.object-craft.com.au From esj at harvee.org Sun Jul 6 02:26:54 2003 From: esj at harvee.org (Eric S. Johansson) Date: Sat, 05 Jul 2003 22:26:54 -0400 Subject: [albatross-users] check boxes again. In-Reply-To: <1057450672.19240.37.camel@localhost> References: <200307040004.KAA08163@lightning.itga.com.au> <3F04C9C2.1020308@harvee.org> <1057450672.19240.37.camel@localhost> Message-ID: <3F0788EE.3050209@harvee.org> Matt Goodall wrote: > On Fri, 2003-07-04 at 01:26, Eric S. Johansson wrote: > > >>Q: how do I get a complete list of all checkboxes checked and unchecked just >>like you can with ordinary CGI > > > Are you sure CGI does this? As far as I was aware browsers only send a > request parameter for a checkbox when it is checked. If the browser > doesn't send a request parameter how can CGI even know there were > unchecked checkboxes on the page? Perhaps the browser behaves > differently when the form data is posted? well, I must admit I have definitely opened my mouth and removed all doubt on that on point... I went back and looked at the code I was using. I had considered each display line an object and stored within each line a hidden variable containing the original token of the spamtrap entry. Then on processing (surprise, surprise) I look at the differences between those stored in hidden variables and those returned in checkboxes and derive two lists. (Sigh, thump, thump) I still think it would be a cool idea if albatross could do this (i.e. return a list of tuples indicating which checkbox and its state) but that's as far as I think I should probably go at this time. ---eric From djc at object-craft.com.au Sun Jul 6 08:34:10 2003 From: djc at object-craft.com.au (Dave Cole) Date: 06 Jul 2003 18:34:10 +1000 Subject: [albatross-users] More documentation changes Message-ID: I have been working my way to the end of the documentation to ensure that it is up to date. After pulling out my last three hairs I decided to automate the construction of the method location table for the SimpleContext http://www.object-craft.com.au/~djc/albatross/pack-simplecontext.html After automating the table construction I realised that it would be very easy to provide the same table for all of the classes in the chapter. Can people please tell me if the method tables in this chapter are useful or not? http://www.object-craft.com.au/~djc/albatross/pack-overview.html - Dave -- http://www.object-craft.com.au From matt at pollenation.net Sun Jul 6 13:35:33 2003 From: matt at pollenation.net (Matt Goodall) Date: 06 Jul 2003 14:35:33 +0100 Subject: [albatross-users] more data tricks for the wiki In-Reply-To: References: <200307030144.LAA14395@lightning.itga.com.au> <3F038F94.5040902@harvee.org> <3F03F12B.2080102@pollenation.net> <3F043063.3060808@harvee.org> <1057447961.6158.23.camel@localhost> Message-ID: <1057498533.28875.87.camel@localhost> On Sun, 2003-07-06 at 02:30, Dave Cole wrote: > >>>>> "Matt" == Matt Goodall writes: > > >> Maybe a better way to do this would be to place all of the > >> information required for pagination into the browser request. This > >> would result in output that looked something like this > >> > >> next > >> > >> > >> The nice outcome of this would be that we do not need to save > >> anything in the session anymore. It would also allow you to > >> bookmark specific pages in an application. > > Matt> I was thinking of implementing this just the other day although > Matt> my reason for wanting purely request based paging was that > Matt> clicking the next page link and then using the browser's refresh > Matt> button makes the ListIterator jump forward another page. > > Matt> My only thought so far on this matter is to add a scope > Matt> attribute to the tag whose default value is "session", > Matt> "request" being the other choice. > > I think that the "goto,i,n" form is superior. Makes me wonder why I > didn't think of it to begin with. If the goto form was available I > cannot think of any reason why you would want the current "nextpage,i" > form. > > - Dave Yes, I completely agree although that was not clear from my post. In general, relative page navigation does not work well with the browser navigation buttons. The combination of absolute page navigation (goto,i,n) and keeping the state in the page/request works much better. In fact, the less the session is used for anything that affects page navigation the better. I guess if I really wanted to keep my page position in the session I could put it there myself quite easily. Cheers, Matt -- Matt Goodall, Pollenation Internet Ltd w: http://www.pollenation.net e: matt@pollenation.net From matt at pollenation.net Sun Jul 6 13:42:28 2003 From: matt at pollenation.net (Matt Goodall) Date: 06 Jul 2003 14:42:28 +0100 Subject: [albatross-users] More documentation changes In-Reply-To: References: Message-ID: <1057498948.6158.93.camel@localhost> On Sun, 2003-07-06 at 09:34, Dave Cole wrote: > Can people please tell me if the method tables in this chapter are > useful or not? > > http://www.object-craft.com.au/~djc/albatross/pack-overview.html Yes, definitely. -- Matt Goodall, Pollenation Internet Ltd w: http://www.pollenation.net e: matt@pollenation.net From sheila at thinkspot.net Sun Jul 6 14:14:27 2003 From: sheila at thinkspot.net (Sheila King) Date: Sun, 06 Jul 2003 07:14:27 -0700 Subject: [albatross-users] More documentation changes In-Reply-To: <1057498948.6158.93.camel@localhost> References: <1057498948.6158.93.camel@localhost> Message-ID: <87595475.1057475667@SHEILA-LAPTOP> --On Sunday, July 06, 2003 2:42 PM +0100 Matt Goodall wrote: > On Sun, 2003-07-06 at 09:34, Dave Cole wrote: > > Can people please tell me if the method tables in this chapter are > > useful or not? > > > > http://www.object-craft.com.au/~djc/albatross/pack-overview.h > > tml > > Yes, definitely. Ditto. Being able to look them up alphabetically is a real plus. -- Sheila King http://www.thinkspot.net/sheila/ http://www.k12groups.org From albatross at tagancha.org Sun Jul 6 15:32:02 2003 From: albatross at tagancha.org (Alex. Moskalenko) Date: Sun, 6 Jul 2003 10:32:02 -0500 Subject: [albatross-users] [wiki] simple example to display a list and allow sorting and filtering In-Reply-To: <1057437185.6158.4.camel@localhost> References: <1057437185.6158.4.camel@localhost> Message-ID: <20030706153202.GA18997@purdue.edu> * Matt Goodall [2003-07-05 21:43:15 +0100]: > I just added a new example, > http://www.object-craft.com.au/projects/albatross/wiki/Data_20Presentation, > that demonstrates getting a list of people from a datastore (of > sorts), displaying the list, sorting the list by clicking on a table > header and a simple list filter. > > Could whoever added, "data presentation from a database or whatever > source comes to your mind with some form processing for sorting > columns and filtering data", to the RequestsForContent page have a > look through and see if it makes sense. > > Cheers, Matt > -- > Matt Goodall, Pollenation Internet Ltd > w: http://www.pollenation.net > e: matt@pollenation.net Matt, This is starting to make sense to me. Albatross documentation looks somewhat overwhelming, probably because I'm still at the beginning of the learning curve here, and examples like yours plus things that Eric Johansson and others have been discussing on the list lately really make a lot of it much clearer to me. Thank you very much. By the way, starting a Wiki was a TERRIFIC idea. I've been lurking on the mailing list for weeks now and really love what's been happening in the Albatross development/documentation lately. Regards, Alex. From matt at pollenation.net Mon Jul 7 00:06:11 2003 From: matt at pollenation.net (Matt Goodall) Date: 07 Jul 2003 01:06:11 +0100 Subject: [albatross-users] Problem with al-httpd and the httpd module Message-ID: <1057536370.26410.86.camel@localhost> As soon as I start using the standalone http server for something useful I come across a problem :-(. There is currently no way to serve static resources, i.e. images, as the server assumes that *everything* will be a request for a page. If anyone can think of a nice way around this I would be really grateful for any suggestions. Thanks, Matt -- Matt Goodall, Pollenation Internet Ltd w: http://www.pollenation.net e: matt@pollenation.net From korg at darkqueen.org Mon Jul 7 00:45:59 2003 From: korg at darkqueen.org (Cameron Blackwood) Date: Mon, 07 Jul 2003 10:45:59 +1000 Subject: [albatross-users] Proposed changes to Albatross placed in wiki In-Reply-To: Your message of "Sun, 06 Jul 2003 06:25:05 +1000." <20030705202505.10586.3689.Mailman@numbat.object-craft.com.au> Message-ID: <200307070045.h670jxd22387@firewall.darkqueen.org> From: "Eric S. Johansson" : | Message: 7 | Date: Sat, 05 Jul 2003 08:40:18 -0400 | From: "Eric S. Johansson" | To: Dave Cole | Cc: albatross-users | Subject: Re: [albatross-users] Proposed changes to Albatross placed in wiki | | Dave Cole wrote: | | > Rather than have all of these proposals fade into obscurity I have | > created a new page where they can be catalogued and discussed. | > | > http://www.object-craft.com.au/projects/albatross/wiki/ProposedChanges | | I've updated ClassRenaming to include the more descriptive names floated by | | Cameron. Personally I find them more useful (and speakable) in contrast to | the | first set of proposed changes. Since I don't know enough about the current | | classes to flush out the set, I'm hoping somebody else will It's UUUUGLY, but logically, it would be something like.... SimpleApp ClientSessPageObjApp App_Class_Context_stored_client SimpleSessionApp ServerSessPageObjApp App_Class_Context_stored_server_process SimpleSessionFileApp FileSessPageObjApp App_Class_Context_stored_server_file ModularApp ClientSessPageModApp App_Module_Context_stored_client ModularSessionApp ServerSessPageModApp App_Module_Context_stored_server_process ModularSessionFileApp FileSessPageModApp App_Module_Context_stored_server_file RandomModularApp ClientSessPageModByURLApp App_Module_via_URL_Context_stored_client RandomModularSessionApp ServerSessPageModByURLApp App_Module_via_URL_Context_stored_server_process RandomModularSessionFileApp FileSessPageModByURLApp App_Module_via_URL_Context_stored_server_side Damn, thats ugly :). I really should look at albatross internals and see if there is any chance of making smarter metaclasses that split the context store into just the context. | | ---eric cam -- / `Rev Dr' cam at darkqueen.org Roleplaying, virtual goth \ < http://darkqueen.org Poly, *nix, Python, C/C++, genetics, ATM > \ [+61 3] 9809 1523[h] skeptic, Evil GM(tm). Sysadmin for hire / ---------- Random Quote ---------- Give me a fish and I will eat today. Teach me to fish and I will eat forever. Eeeew. From korg at darkqueen.org Mon Jul 7 01:35:06 2003 From: korg at darkqueen.org (Cameron Blackwood) Date: Mon, 07 Jul 2003 11:35:06 +1000 Subject: [albatross-users] Comments on using examples... In-Reply-To: Your message of "06 Jul 2003 12:01:01 +1000." Message-ID: <200307070135.h671Z6O22916@firewall.darkqueen.org> Dave Cole writes In message : | | | How about a module in Albatross that contained useful interactive | utilities. I figure that a function like the following might be | sufficient for the above: I didnt reply to the comments about interactive python use because I felt bad for ranting about the docs :) :). Someone replied that they _do_ actually use interactive python (so I guess it is just a me thing) but did want to say that any interactive example over about 3-4 lines I tend to run in a file, because the chances are that Im going to want to make a change and if I want to make 3 or 4 test changes to an 8 line example, Id rather use a .py file and an editor than 3*8 line cut and pastes or python's history editing :). | | def run_templ(text, ctx=None): | if ctx is None: | ctx = albatross.SimpleContext('.') | albatross.Template(ctx, '', text).to_html(ctx) | ctx.flush_content() Yep, this would be cool. | | This would allow you to do this: | | >>> from albatross.fiddle import * | >>> run_templ('I would never do anything ') I find that way neater... I could easily cut and paste 2 lines. | | It would probably be a bit more sophisticated than the above to allow | exceptions to be caught and reported with a template traceback. | | What should the module be called, and what functions should be in it? *blinks* Errr..... :) | | > And the complex examples? I'd probably rather actual files that | > I can download, install and run. That way I can modify them | > and play! | | OK. I should have a go at changing the doctest samples to split them | into .py and .out files. Maybe you could use a function that returned the string, rather than flushing it, so you could have ------8< cut test.py >8------ from albatross.fiddle import * answer_is=run_templ('I would never do anything ') should_be='I would never do anything bad ' ------8< cut test.py >8------ or.. ------8< cut test.py >8------ from albatross.fiddle import * test_template( 'I would never do anything ', 'I would never do anything bad ') # Output: # Template: verified ok ------8< cut test.py >8------ Or that could be test_template( source=" me baby!", expected=" Foobar me baby!") ) | > Who does import 'cgi' with albatross code? I dont. (Should I?) | > I guess Im trying to ask who actually codes like that? | | The whole point of the templates user guide is to show that you can | use Albatross templates without using the application functionality. Point taken, but how often do people do that? Is that something we should be doing more often or do 90% of people use it mostly with albatross Apps. In that case Id argue for supporting the masses :). | | Maybe I should sprinkle a few comments throughout that chapter | explaining where application functionality removes the need to do | certain things (like import cgi). *nod* Although, to spoil my own comment, I should say that I appreciated the slow intro to albatross when I was starting and converting from a python cgi and adding templates was nicer than just starting from scratch with albatross apps :). Being eased into templates (without albatross apps and contexts) would seem to be the kind way to go :). I do seem to recall getting a little confused towards the end of that templating chapter. Maybe: # 3. intro to templates * 3.1 Introduction to templates * 3.2 Your First Template program * 3.3 Introducing Albatross Tags * 3.5 Albatross Macros o 3.5.1 Zero Argument Macros o 3.5.2 Single Argument Macros o 3.5.3 Multiple Argument Macros o 3.5.4 Nesting Macros * 3.7 White Space Removal in Albatross All this can be done just as a template file in.. rendered file out examples to learn templates. Just pure template and macro work (?) no CGI's, no context, no nothin'. # 4. templates and contexts * 3.3.1 Eliminating the Application (Applications in just templates) * 3.6 Lookup Tables * 3.8 Using Forms to Receive User Input * 3.9 Using Albatross Input Tags * 3.10 More on the Tag * 3.11 Streaming Application Output to the Browser * 3.12 Displaying Tree Structured Data Now we add contexts and variables and more advanced renders. Here is were we start to introduce magical template work with contexts. Also stuff like adding code to templates to make the user interface smarter and prettier. We probably need cgi examples here, but maybe have a 'we will explain this later' module to do the cgi<->template (or a really simple App class). # 5. Albatross applications * 3.4 Building a Useful Application Now we understand how to render output and use contexts, we add albatross applications and _real_ cgi examples. (chapter orig 4 stuff) | | - Dave cam -- / `Rev Dr' cam at darkqueen.org Roleplaying, virtual goth \ < http://darkqueen.org Poly, *nix, Python, C/C++, genetics, ATM > \ [+61 3] 9809 1523[h] skeptic, Evil GM(tm). Sysadmin for hire / ---------- Random Quote ---------- Do what you can to prolong your life, in the hope that someday you'll learn what it's for. From korg at darkqueen.org Mon Jul 7 01:47:13 2003 From: korg at darkqueen.org (Cameron Blackwood) Date: Mon, 07 Jul 2003 11:47:13 +1000 Subject: [albatross-users] [wiki] simple example to display a list and In-Reply-To: Your message of "Mon, 07 Jul 2003 06:25:03 +1000." <20030706202503.20130.26189.Mailman@numbat.object-craft.com.au> Message-ID: <200307070147.h671lDt23262@firewall.darkqueen.org> From: "Alex. Moskalenko" : | | * Matt Goodall [2003-07-05 21:43:15 +0100]: | | > I just added a new example, | > http://www.object-craft.com.au/projects/albatross/wiki/Data_20Presentatio | n, | > that demonstrates getting a list of people from a datastore (of | > sorts), displaying the list, sorting the list by clicking on a table | > header and a simple list filter. Matt's example code is a rocking idea! This is just the kind of stuff that I (and I assume others) use to learn!!! | | This is starting to make sense to me. Albatross documentation looks | somewhat overwhelming, probably because I'm still at the beginning of | the learning curve here, and examples like yours plus things that Eric | Johansson and others have been discussing on the list lately really make | a lot of it much clearer to me. Thank you very much. By the way, | starting a Wiki was a TERRIFIC idea. You know I did a wonderful subject at uni that basically concluded that the best people to help other people learn were people who had just learned rather than 'experts' so please do dive in with comments on whats confusing and what isnt. (Its been a while since I started albatross, so Im not sure I really feel qualified to comment on the documentation etc). | | I've been lurking on the mailing list for weeks now and really love | what's been happening in the Albatross development/documentation lately. | | Regards, | | Alex. cam -- / `Rev Dr' cam at darkqueen.org Roleplaying, virtual goth \ < http://darkqueen.org Poly, *nix, Python, C/C++, genetics, ATM > \ [+61 3] 9809 1523[h] skeptic, Evil GM(tm). Sysadmin for hire / ---------- Random Quote ---------- It's a naive, domestic operating system without any breeding, but I think you'll be amused by its presumption. From andrewm at object-craft.com.au Mon Jul 7 05:51:36 2003 From: andrewm at object-craft.com.au (Andrew McNamara) Date: Mon, 07 Jul 2003 15:51:36 +1000 Subject: [albatross-users] Problem with al-httpd and the httpd module In-Reply-To: Message from Matt Goodall of "07 Jul 2003 01:06:11 +0100." <1057536370.26410.86.camel@localhost> References: <1057536370.26410.86.camel@localhost> Message-ID: <20030707055136.254283C332@coffee.object-craft.com.au> >As soon as I start using the standalone http server for something useful >I come across a problem :-(. There is currently no way to serve static >resources, i.e. images, as the server assumes that *everything* will be >a request for a page. The obvious solution is to add support for serving static content (files) from a specified directory. -- Andrew McNamara, Senior Developer, Object Craft http://www.object-craft.com.au/ From sheila at thinkspot.net Mon Jul 7 06:15:25 2003 From: sheila at thinkspot.net (Sheila King) Date: Sun, 06 Jul 2003 23:15:25 -0700 Subject: [albatross-users] Wiki example and related extension: iterate over ctx/session Message-ID: <1671901176.1057533325@goddess> I REALLY appreciate this example, posted in the Wiki http://object-craft.com.au/projects/albatross/wiki/Displaying_20the_20Conte xt which is of a macro that iterates over all of the local context variables and their values. Is it possible to do the same for the session variables? -- Sheila King http://www.thinkspot.net/sheila/ http://www.k12groups.org From gnb at itga.com.au Mon Jul 7 08:20:01 2003 From: gnb at itga.com.au (Gregory Bond) Date: Mon, 07 Jul 2003 18:20:01 +1000 Subject: [albatross-users] Wiki example and related extension: iterate over ctx/session In-Reply-To: Your message of Sun, 06 Jul 2003 23:15:25 -0700. Message-ID: <200307070820.SAA16351@lightning.itga.com.au> > Is it possible to do the same for the session variables? Not in standard Albatross. The list of names in the session is stored in a dict called ctx.__vars and that's not available to templates. Can't get access to it from the python code due to funky '__<>' handling, too. Need to fix this in the SessionBase class. Perhaps the SessionBase ctor could do: self.locals.__session__ = self.__vars so your templates could do
From matt at pollenation.net Mon Jul 7 08:41:04 2003 From: matt at pollenation.net (Matt Goodall) Date: Mon, 07 Jul 2003 09:41:04 +0100 Subject: [albatross-users] Problem with al-httpd and the httpd module In-Reply-To: <20030707055136.254283C332@coffee.object-craft.com.au> References: <1057536370.26410.86.camel@localhost> <20030707055136.254283C332@coffee.object-craft.com.au> Message-ID: <3F093220.6090502@pollenation.net> Andrew McNamara wrote: >>As soon as I start using the standalone http server for something useful >>I come across a problem :-(. There is currently no way to serve static >>resources, i.e. images, as the server assumes that *everything* will be >>a request for a page. >> >> > >The obvious solution is to add support for serving static content (files) >from a specified directory. > Yes, that would work for me as I tend to store all images, stylesheets, etc under a single root directory called assets. I'll see what I can cope up with for the httpdapp module and al-httpd script. Thanks, Matt -- Matt Goodall, Pollenation Internet Ltd e: matt@pollenationinternet.com From matt at pollenation.net Mon Jul 7 10:21:55 2003 From: matt at pollenation.net (Matt Goodall) Date: Mon, 07 Jul 2003 11:21:55 +0100 Subject: [albatross-users] 1.10pre2 random app breakage Message-ID: <3F0949C3.8000404@pollenation.net> This is a multi-part message in MIME format. --------------080008010502000101020100 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit Hi, Using 1.10pre2, random apps run with mod_python or cgi are potentiall broken. The base_url patch I submitted was not quite correct although it seemed to work ok with 1.10pre1. Attached is another base_url patch, based on the 1.10pre2 code, which should fix things. Cheers, Matt -- Matt Goodall, Pollenation Internet Ltd w: http://www.pollenationinternet.com e: matt@pollenationinternet.com --------------080008010502000101020100 Content-Type: text/plain; name="base_url.patch" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="base_url.patch" diff -ru albatross-1.10pre2-original/albatross/app.py albatross-1.10pre2/albatross/app.py --- albatross-1.10pre2-original/albatross/app.py 2003-07-05 08:52:40.000000000 +0100 +++ albatross-1.10pre2/albatross/app.py 2003-07-07 11:08:48.000000000 +0100 @@ -221,11 +221,12 @@ def __init__(self, base_url): ResourceMixin.__init__(self) self.register_tagclasses(*tags.tags) - # Use a base_url of '/' if not provided - if base_url: - self.__base_url = base_url - else: + # Always append a '/' to the base_url if it is missing + self.__base_url = base_url + if not self.__base_url: self.__base_url = '/' + elif self.__base_url[-1] != '/': + self.__base_url = self.__base_url + '/' def run(self, req): '''Process a single browser request --------------080008010502000101020100-- From djc at object-craft.com.au Mon Jul 7 10:20:00 2003 From: djc at object-craft.com.au (Dave Cole) Date: 07 Jul 2003 20:20:00 +1000 Subject: [albatross-users] Wiki example and related extension: iterate over ctx/session In-Reply-To: <200307070820.SAA16351@lightning.itga.com.au> References: <200307070820.SAA16351@lightning.itga.com.au> Message-ID: > > Is it possible to do the same for the session variables? > Not in standard Albatross. The list of names in the session is > stored in a dict called ctx.__vars and that's not available to > templates. Can't get access to it from the python code due to funky > '__<>' handling, too. Need to fix this in the SessionBase class. > > Perhaps the SessionBase ctor could do: > self.locals.__session__ = self.__vars > so your templates could do >
    >
  • >
It might have slipped through the documentation updates (*ahem*) but I did remember to put it here http://www.object-craft.com.au/projects/albatross/albatross/rel-1.10-ctx.html This means that you could do something very kludgey like this:
- Dave -- http://www.object-craft.com.au From matt at pollenation.net Mon Jul 7 11:21:45 2003 From: matt at pollenation.net (Matt Goodall) Date: Mon, 07 Jul 2003 12:21:45 +0100 Subject: [albatross-users] Using additional path information as request parameters Message-ID: <3F0957C9.5020600@pollenation.net> In some cases I would like to have a _random_ app page process a request where the request parameters are appended to the URL in a path-like manner. For instance, I might have an Alabtross page that display a book's details. The conventional way to achieve it is to use the following url: /app.py/book?id=123 What I would rather use is a URL with 123 as the last part of the path: /app.py/book/123 In both cases the book module would process the request. The only way I can think of is to use some fairly complex mod_rewrite rules (which I prefer to avoid whenever possible) which turns book/123 into book?id=123. Does anyone have any better idea? The reason for all this? It produces search engine friendly URLs. Some search engines still crawl pages with request parameters. A great section for the Wiki would be integrating Albatross with Apache and possible IIS if anyone uses it. I'll add that to the list. Thanks, Matt -- Matt Goodall, Pollenation Internet Ltd w: http://www.pollenationinternet.com e: matt@pollenationinternet.com From djc at object-craft.com.au Mon Jul 7 13:03:26 2003 From: djc at object-craft.com.au (Dave Cole) Date: 07 Jul 2003 23:03:26 +1000 Subject: [albatross-users] Using additional path information as request parameters In-Reply-To: <3F0957C9.5020600@pollenation.net> References: <3F0957C9.5020600@pollenation.net> Message-ID: >>>>> "Matt" == Matt Goodall writes: Matt> In some cases I would like to have a _random_ app page process a Matt> request where the request parameters are appended to the URL in Matt> a path-like manner. For instance, I might have an Alabtross page Matt> that display a book's details. The conventional way to achieve Matt> it is to use the following url: Matt> /app.py/book?id=123 Matt> What I would rather use is a URL with 123 as the last part of Matt> the path: Matt> /app.py/book/123 Matt> In both cases the book module would process the request. Matt> The only way I can think of is to use some fairly complex Matt> mod_rewrite rules (which I prefer to avoid whenever possible) Matt> which turns book/123 into book?id=123. Does anyone have any Matt> better idea? Matt> The reason for all this? It produces search engine friendly Matt> URLs. Some search engines still crawl pages with request Matt> parameters. Matt> A great section for the Wiki would be integrating Albatross with Matt> Apache and possible IIS if anyone uses it. I'll add that to the Matt> list. An approach that might make sense is to bounce the URL up to the application so it can assist in cracking it. If you look at the Application.run() method it is the load_page() method that you should override: def run(self, req): '''Process a single browser request ''' ctx = None try: ctx = self.create_context() ctx.set_request(req) self.load_session(ctx) self.load_page(ctx) if self.validate_request(ctx): self.merge_request(ctx) self.process_request(ctx) self.display_response(ctx) self.save_session(ctx) ctx.flush_content() except Redirect, e: self.save_session(ctx) return req.redirect(e.loc) except: self.handle_exception(ctx, req) return req.status() This is how the current RandomPageModuleMixin class works. It provides a load_page() method that pulls apart the URL to locate a page module. You might even be able to bend the RandomPageModuleMixin.load_page() to suit your needs. Current RandomPageModuleMixin.load_page() method: def load_page(self, ctx): # Get page name from request URI uri = ctx.request.get_uri() page = '' try: base_path = urlparse.urlparse(self.base_url())[2] uri_path = urlparse.urlparse(uri)[2] page = uri_path.split(base_path, 1)[1] except IndexError: pass if not page: ctx.redirect(self.start_page()) # [snip] New method(s): def load_page(self, ctx): # Get page name from request URI uri = ctx.request.get_uri() page = self.get_page_from_uri(ctx, uri) if not page: ctx.redirect(self.start_page()) # [snip] def get_page_from_uri(self, ctx, uri): try: base_path = urlparse.urlparse(self.base_url())[2] uri_path = urlparse.urlparse(uri)[2] return uri_path.split(base_path, 1)[1] except IndexError: return None Then in your application you are free to implement any kind of URI splitting you like by overriding get_page_from_uri(). All you have to do is return something that the load_page_module() method (in PageModuleMixin) can use to load a page module. Does any of that make sense? - Dave -- http://www.object-craft.com.au From djc at object-craft.com.au Mon Jul 7 13:09:05 2003 From: djc at object-craft.com.au (Dave Cole) Date: 07 Jul 2003 23:09:05 +1000 Subject: [albatross-users] 1.10pre2 random app breakage In-Reply-To: <3F0949C3.8000404@pollenation.net> References: <3F0949C3.8000404@pollenation.net> Message-ID: > Hi, > Using 1.10pre2, random apps run with mod_python or cgi are potentiall > broken. The base_url patch I submitted was not quite correct although > it seemed to work ok with 1.10pre1. Attached is another base_url > patch, based on the 1.10pre2 code, which should fix things. > > Cheers, Matt > > -- > Matt Goodall, Pollenation Internet Ltd > w: http://www.pollenationinternet.com > e: matt@pollenationinternet.com > > diff -ru albatross-1.10pre2-original/albatross/app.py albatross-1.10pre2/albatross/app.py > --- albatross-1.10pre2-original/albatross/app.py 2003-07-05 08:52:40.000000000 +0100 > +++ albatross-1.10pre2/albatross/app.py 2003-07-07 11:08:48.000000000 +0100 > @@ -221,11 +221,12 @@ > def __init__(self, base_url): > ResourceMixin.__init__(self) > self.register_tagclasses(*tags.tags) > - # Use a base_url of '/' if not provided > - if base_url: > - self.__base_url = base_url > - else: > + # Always append a '/' to the base_url if it is missing > + self.__base_url = base_url > + if not self.__base_url: > self.__base_url = '/' > + elif self.__base_url[-1] != '/': > + self.__base_url = self.__base_url + '/' > > def run(self, req): > '''Process a single browser request Applied. - Dave -- http://www.object-craft.com.au From matt at pollenation.net Mon Jul 7 16:07:14 2003 From: matt at pollenation.net (Matt Goodall) Date: Mon, 07 Jul 2003 17:07:14 +0100 Subject: [albatross-users] AppContext.redirect_url() question Message-ID: <3F099AB2.80805@pollenation.net> Hi, Can anyone explain why the method in the subject is fiddling around with uri paths? It looks like it's trying to cope with the situation when the base uri and the request uri differ but I don't understand why and it's probably not quite right, i.e. what happens if the two URIs do not match correctly? When would the two URIs be different anyway? Also, why does Albatross not make use of path info (os.environ['PATH_INFO'] in cgi, req.path_info in mod_python; not sure for BaseHTTPServer)? I think path info could simplify the parsing and building or URLs which has been causing me a few problems today when I popped a mod_python app behind a mod_rewrite rule :(. I'm not being critical, just trying to understand things better. Thanks, Matt -- Matt Goodall, Pollenation Internet Ltd w: http://www.pollenationinternet.com e: matt@pollenationinternet.com From matt at pollenation.net Mon Jul 7 16:31:16 2003 From: matt at pollenation.net (Matt Goodall) Date: Mon, 07 Jul 2003 17:31:16 +0100 Subject: [albatross-users] Change to httpdapp module Message-ID: <3F09A054.4090004@pollenation.net> In httpdapp, Request.get_uri() currently returns an entire URL including server, port etc. I think it should be just returning the path as follows, but please check I'm not being daft first: def get_uri(self): return self._req.path Cheers, Matt -- Matt Goodall, Pollenation Internet Ltd w: http://www.pollenationinternet.com e: matt@pollenationinternet.com From matt at pollenation.net Mon Jul 7 22:10:54 2003 From: matt at pollenation.net (Matt Goodall) Date: 07 Jul 2003 23:10:54 +0100 Subject: [albatross-users] [patch] fastcgi bug fix Message-ID: <1057615854.26759.36.camel@localhost> --=-OJGc58suj1OOzWp93/5s Content-Type: text/plain Content-Transfer-Encoding: 7bit Hi, I don't know how this one got through (!) but I found a bug in the fcgiapp module. At the same time, I changed the code to look up dictionary items using get() rather than [] which is a bit more robust. How can we go about testing all these request adapters other than running them inside a web server? I guess it should be possible to spoof a straight CGI quite easily but the others are probably a bit trickier. - Matt -- Matt Goodall, Pollenation Internet Ltd w: http://www.pollenation.net e: matt@pollenation.net --=-OJGc58suj1OOzWp93/5s Content-Disposition: attachment; filename=fcgiapp_get_header.patch Content-Type: text/plain; name=fcgiapp_get_header.patch; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable --- albatross-1.10pre2/albatross/fcgiapp.py 2003-07-05 04:12:16.000000000 += 0100 +++ albatross-1.10pre2-patched/albatross/fcgiapp.py 2003-07-07 23:03:53.000= 000000 +0100 @@ -19,14 +19,14 @@ cgiapp.Request.__init__(self, fields) =20 def get_uri(self): - return self.__fcgi.env['REQUEST_URI'] + return self.__fcgi.env.get('REQUEST_URI') =20 def get_servername(self): - return self.__fcgi.env['SERVER_NAME'] + return self.__fcgi.env.get('SERVER_NAME') =20 def get_header(self, name): env_name =3D 'HTTP_' + name.upper().replace('-', '_') - return self.__req.env.get(env_name) + return self.__fcgi.env.get(env_name) =20 =20 def running(): --=-OJGc58suj1OOzWp93/5s-- From matt at pollenation.net Mon Jul 7 22:16:44 2003 From: matt at pollenation.net (Matt Goodall) Date: 07 Jul 2003 23:16:44 +0100 Subject: [albatross-users] Using additional path information as request parameters In-Reply-To: <3F0957C9.5020600@pollenation.net> References: <3F0957C9.5020600@pollenation.net> Message-ID: <1057616203.26759.39.camel@localhost> On Mon, 2003-07-07 at 12:21, Matt Goodall wrote: > The reason for all this? It produces search engine friendly URLs. Some > search engines still crawl pages with request parameters. Should have said, "Some search engines still do not crawl pages with request parameters.". - Matt -- Matt Goodall, Pollenation Internet Ltd w: http://www.pollenation.net e: matt@pollenation.net From andrewm at object-craft.com.au Mon Jul 7 23:57:19 2003 From: andrewm at object-craft.com.au (Andrew McNamara) Date: Tue, 08 Jul 2003 09:57:19 +1000 Subject: [albatross-users] [patch] fastcgi bug fix In-Reply-To: Message from Matt Goodall of "07 Jul 2003 23:10:54 +0100." <1057615854.26759.36.camel@localhost> References: <1057615854.26759.36.camel@localhost> Message-ID: <20030707235719.5A9703C332@coffee.object-craft.com.au> >I don't know how this one got through (!) but I found a bug in the >fcgiapp module. Oops. I suspect this was my fault. >At the same time, I changed the code to look up dictionary items using >get() rather than [] which is a bit more robust. I tend to prefer an exception is raised earlier than later (closer to the source of the failure), but I'm not fanatical about it. I've applied both fixes. >How can we go about testing all these request adapters other than >running them inside a web server? I guess it should be possible to spoof >a straight CGI quite easily but the others are probably a bit trickier. I guess we need to build a framework that looks like the fcgi one. The existing tests aren't even comprehensive when it comes to cgi... 8-( -- Andrew McNamara, Senior Developer, Object Craft http://www.object-craft.com.au/ From matt at pollenation.net Tue Jul 8 00:29:09 2003 From: matt at pollenation.net (Matt Goodall) Date: 08 Jul 2003 01:29:09 +0100 Subject: [albatross-users] [patch] fastcgi bug fix In-Reply-To: <20030707235719.5A9703C332@coffee.object-craft.com.au> References: <1057615854.26759.36.camel@localhost> <20030707235719.5A9703C332@coffee.object-craft.com.au> Message-ID: <1057624148.13763.6.camel@localhost> On Tue, 2003-07-08 at 00:57, Andrew McNamara wrote: > >I don't know how this one got through (!) but I found a bug in the > >fcgiapp module. > > Oops. I suspect this was my fault. Nah, you misunderstand. What I really meant was ... why on earth did I send you a broken file ;-). - Matt -- Matt Goodall, Pollenation Internet Ltd w: http://www.pollenation.net e: matt@pollenation.net From djc at object-craft.com.au Tue Jul 8 00:37:45 2003 From: djc at object-craft.com.au (Dave Cole) Date: 08 Jul 2003 10:37:45 +1000 Subject: [albatross-users] AppContext.redirect_url() question In-Reply-To: <3F099AB2.80805@pollenation.net> References: <3F099AB2.80805@pollenation.net> Message-ID: >>>>> "Matt" == Matt Goodall writes: Matt> Hi, Can anyone explain why the method in the subject is fiddling Matt> around with uri paths? It looks like it's trying to cope with Matt> the situation when the base uri and the request uri differ but I Matt> don't understand why and it's probably not quite right, Matt> i.e. what happens if the two URIs do not match correctly? When Matt> would the two URIs be different anyway? All of that code (which could probably be improved) is trying to ensure that only absolute redirect URLs come out of the application. You can see what it is trying to do by placing this application in your cgi-bin directory and pointing your browser at it. - - redirect.py - - - - - - - - - - - - - - - - - - - - - - - - - - - #!/usr/bin/python import sys import os if __name__ == '__main__': host = os.environ.get('HTTP_HOST') script_name = os.environ.get('SCRIPT_NAME') uri = os.environ.get('REQUEST_URI') page = uri[len(script_name):] sys.stderr.write('uri="%s", page="%s"\n' % (uri, page)) if page == '/there': print 'Content-Type: text/plain' print print 'You are there' else: # This works perfectly loc = 'http://%s%s/there' % (host, script_name) # These all cause all sorts of strife #loc = '/%s/there' % script_name #loc = 'there' print 'Location:', loc print 'Status:', '301 Moved Permanently' print - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - The Albatross code is just trying to figure out how to construct an absolute location for the requested redirect. It also tries to avoid fiddling with a URL that is already absolute. Matt> Also, why does Albatross not make use of path info Matt> (os.environ['PATH_INFO'] in cgi, req.path_info in mod_python; Matt> not sure for BaseHTTPServer)? I think path info could simplify Matt> the parsing and building or URLs which has been causing me a few Matt> problems today when I popped a mod_python app behind a Matt> mod_rewrite rule :(. I am more than happy to change the current code if you figure out a better way to do it. - Dave -- http://www.object-craft.com.au From sheila at thinkspot.net Tue Jul 8 03:53:58 2003 From: sheila at thinkspot.net (Sheila King) Date: Mon, 07 Jul 2003 20:53:58 -0700 Subject: [albatross-users] Wiki example and related extension: iterate over ctx/session In-Reply-To: References: <200307070820.SAA16351@lightning.itga.com.au> Message-ID: <1749814129.1057611238@goddess> --On Monday, July 07, 2003 8:20 PM +1000 Dave Cole wrote: > It might have slipped through the documentation updates (*ahem*) but I > did remember to put it here > > http://www.object-craft.com.au/projects/albatross/albatross/rel-1.10-ctx. > html > > This means that you could do something very kludgey like this: > >
    >
  • >
> It should be pointed out, that this will not work in the previous "official release" (1.01) I have not upgraded to 1.10 yet, as I am waiting for the official release, rather than the "pre-releases". -- Sheila King http://www.thinkspot.net/sheila/ http://www.k12groups.org From sheila at thinkspot.net Tue Jul 8 04:01:52 2003 From: sheila at thinkspot.net (Sheila King) Date: Mon, 07 Jul 2003 21:01:52 -0700 Subject: [albatross-users] Wiki example and related extension: iterate over ctx/session In-Reply-To: <200307070820.SAA16351@lightning.itga.com.au> References: <200307070820.SAA16351@lightning.itga.com.au> Message-ID: <1750288081.1057611712@goddess> --On Monday, July 07, 2003 6:20 PM +1000 Gregory Bond wrote: > Perhaps the SessionBase ctor could do: > self.locals.__session__ = self.__vars > so your templates could do >
    >
  • >
"ctor" ??? Do you mean the "creator" method? (i.e. __init__ for the class) I wonder what I would break in my current app by upgrading to the 1.10 prerelease right now. I do like David Cole's "kludge" a bit better, since it doesn't require me to override or change code in the basic albatross code. -- Sheila King http://www.thinkspot.net/sheila/ http://www.k12groups.org From andrewm at object-craft.com.au Tue Jul 8 04:27:16 2003 From: andrewm at object-craft.com.au (Andrew McNamara) Date: Tue, 08 Jul 2003 14:27:16 +1000 Subject: [albatross-users] Wiki example and related extension: iterate over ctx/session In-Reply-To: Message from Sheila King of "Mon, 07 Jul 2003 21:01:52 MST." <1750288081.1057611712@goddess> References: <200307070820.SAA16351@lightning.itga.com.au> <1750288081.1057611712@goddess> Message-ID: <20030708042716.C9AF53C024@coffee.object-craft.com.au> >> Perhaps the SessionBase ctor could do: >> self.locals.__session__ = self.__vars >> so your templates could do >>
    >>
  • >>
> >"ctor" ??? >Do you mean the "creator" method? (i.e. __init__ for the class) "ctor" is shorthand for constructor, so, yes. >I wonder what I would break in my current app by upgrading to the 1.10 >prerelease right now. I do like David Cole's "kludge" a bit better, since >it doesn't require me to override or change code in the basic albatross >code. Well, we'd like to know what will break so we can fix it before the release... that's the point of a -pre, although you might not want to use it in production. 8-) Dave's suggestion is pretty gross. I wonder if we should put a session_vars() method on the context that returns a list of session vars? -- Andrew McNamara, Senior Developer, Object Craft http://www.object-craft.com.au/ From djc at object-craft.com.au Tue Jul 8 04:29:45 2003 From: djc at object-craft.com.au (Dave Cole) Date: 08 Jul 2003 14:29:45 +1000 Subject: [albatross-users] Wiki example and related extension: iterate over ctx/session In-Reply-To: <20030708042716.C9AF53C024@coffee.object-craft.com.au> References: <200307070820.SAA16351@lightning.itga.com.au> <1750288081.1057611712@goddess> <20030708042716.C9AF53C024@coffee.object-craft.com.au> Message-ID: > >> Perhaps the SessionBase ctor could do: > >> self.locals.__session__ = self.__vars > >> so your templates could do > >>
    > >>
  • > >>
> > > >"ctor" ??? > >Do you mean the "creator" method? (i.e. __init__ for the class) > > "ctor" is shorthand for constructor, so, yes. > > >I wonder what I would break in my current app by upgrading to the > >1.10 prerelease right now. I do like David Cole's "kludge" a bit > >better, since it doesn't require me to override or change code in > >the basic albatross code. > > Well, we'd like to know what will break so we can fix it before the > release... that's the point of a -pre, although you might not want > to use it in production. 8-) > > Dave's suggestion is pretty gross. I wonder if we should put a > session_vars() method on the context that returns a list of session > vars? Couldn't hurt. - Dave -- http://www.object-craft.com.au From gnb at itga.com.au Tue Jul 8 04:39:20 2003 From: gnb at itga.com.au (Gregory Bond) Date: Tue, 08 Jul 2003 14:39:20 +1000 Subject: [albatross-users] Wiki example and related extension: iterate over ctx/session In-Reply-To: Your message of Tue, 08 Jul 2003 14:27:16 +1000. Message-ID: <200307080439.OAA04847@lightning.itga.com.au> > Dave's suggestion is pretty gross. I wonder if we should put a > session_vars() method on the context that returns a list of session vars? It sure wouldn't hurt, but it's not ideal - because in order to access the sessions names from a template, you need to put them into the ctx.locals - and do it at just the right time in the process so that you get the correct answer. (session_vars() will return a copy, so won't be updated as session vars are added/deleted.) This also means in order to put debugging in, you need to edit the page_display function as well as the template. The advantage of having the session dict in the ctx.locals is that you can do debugging by justy changing the template, and it will be up to date as no copies are involved. From sheila at thinkspot.net Tue Jul 8 04:39:42 2003 From: sheila at thinkspot.net (Sheila King) Date: Mon, 07 Jul 2003 21:39:42 -0700 Subject: [albatross-users] Wiki example and related extension: iterate over ctx/session In-Reply-To: References: <200307070820.SAA16351@lightning.itga.com.au> <1750288081.1057611712@goddess> <20030708042716.C9AF53C024@coffee.object-craft.com.au> Message-ID: <1752557915.1057613982@goddess> --On Tuesday, July 08, 2003 2:29 PM +1000 Dave Cole wrote: >> > I wonder what I would break in my current app by upgrading to the >> > 1.10 prerelease right now. I do like David Cole's "kludge" a bit >> > better, since it doesn't require me to override or change code in >> > the basic albatross code. >> >> Well, we'd like to know what will break so we can fix it before the >> release... that's the point of a -pre, although you might not want >> to use it in production. 8-) I will consider it. My problem is that I am so new and somewhat inept at Albatross, I'm likely to not know whether it is my code or the Albatross pre-release that is broken. IOW, may not be of any benefit to you and much confusion/frustration to me. >> Dave's suggestion is pretty gross. I wonder if we should put a >> session_vars() method on the context that returns a list of session >> vars? > > Couldn't hurt. > More than that, I'd say it would definitely help. I'm trying to use it as one would use a "debugger" to see, in my app, what I have stored and set at each step. Not having the ability to do this makes it much more difficult to keep track of what is going on. At least, for those of us who are not wizards. -- Sheila King http://www.thinkspot.net/sheila/ http://www.k12groups.org From andrewm at object-craft.com.au Tue Jul 8 04:54:35 2003 From: andrewm at object-craft.com.au (Andrew McNamara) Date: Tue, 08 Jul 2003 14:54:35 +1000 Subject: [albatross-users] Wiki example and related extension: iterate over ctx/session In-Reply-To: Message from Sheila King of "Mon, 07 Jul 2003 21:39:42 MST." <1752557915.1057613982@goddess> References: <200307070820.SAA16351@lightning.itga.com.au> <1750288081.1057611712@goddess> <20030708042716.C9AF53C024@coffee.object-craft.com.au> <1752557915.1057613982@goddess> Message-ID: <20030708045435.089F73C024@coffee.object-craft.com.au> >I will consider it. My problem is that I am so new and somewhat inept at >Albatross, I'm likely to not know whether it is my code or the Albatross >pre-release that is broken. IOW, may not be of any benefit to you and much >confusion/frustration to me. True, but the pre2 is the next best thing to a release - better to sort out any breakage now (yours or ours), rather than after the release is done. The new release has additional checks for common template errors - it might even solve some bugs for you... 8-) If you do want to play with it, you can always back it out and re-install the old version. The only gotchya is that you will probably need to delete the installed albatross before installing an older version (otherwise the *.pyc files won't be updated) - delete the albatross directory /usr/local/lib/python*/site-packages/albatross or /usr/lib/python*/site-packages/albatross (be careful if using "rm -rf" 8-). If "rm -rf" gives you the willies, you can always just touch all the albatross/*.py files in the distribution prior to doing "setup.py install". -- Andrew McNamara, Senior Developer, Object Craft http://www.object-craft.com.au/ From andrewm at object-craft.com.au Tue Jul 8 05:00:44 2003 From: andrewm at object-craft.com.au (Andrew McNamara) Date: Tue, 08 Jul 2003 15:00:44 +1000 Subject: [albatross-users] Wiki example and related extension: iterate over ctx/session In-Reply-To: Message from Gregory Bond of "Tue, 08 Jul 2003 14:39:20 +1000." <200307080439.OAA04847@lightning.itga.com.au> References: <200307080439.OAA04847@lightning.itga.com.au> Message-ID: <20030708050044.8DEAC3C024@coffee.object-craft.com.au> >It sure wouldn't hurt, but it's not ideal - because in order to access the >sessions names from a template, you need to put them into the ctx.locals - >and do it at just the right time in the process so that you get the >correct answer. (session_vars() will return a copy, so won't be updated >as session vars are added/deleted.) I'm not really sure what people are getting at here - ctx.add_session_vars() simply controls which attributes of ctx.locals are pickled - I can't see why you'd want to modify the return from session_vars() any way other than via ctx.(add|del)_session_vars()? >This also means in order to put debugging in, you need to edit the >page_display function as well as the template. If it's debugging, it's probably better just to put a bunch of writes to sys.stderr in the page module, rather than modifying the template (particularly with complex templates). -- Andrew McNamara, Senior Developer, Object Craft http://www.object-craft.com.au/ From gnb at itga.com.au Tue Jul 8 06:14:55 2003 From: gnb at itga.com.au (Gregory Bond) Date: Tue, 08 Jul 2003 16:14:55 +1000 Subject: [albatross-users] Wiki example and related extension: iterate over ctx/session In-Reply-To: Your message of Tue, 08 Jul 2003 15:00:44 +1000. Message-ID: <200307080614.QAA13994@lightning.itga.com.au> andrewm@object-craft.com.au said: > I'm not really sure what people are getting at here The sequence I was thinking of is this: def page_enter(self, ctx): ctx.locals.session = ctx.session_vars() # aka ctx.__vars.keys() # ... ctx.add_session_vars('new') def page_display(self, ctx): ctx.run_template('debug.ht') where debug.ht does Session Vars are:
This will not show 'new' as a session variable, because it was added after the session_vars() call. Putting (a reference to) the __vars dict into the session will not have this problem. The other way around the problem is to do the "ctx.locals.session = ctx.session_vars()" bit in every page_display() routine just before the run_template call, which is ugly and unnecessary boilerplate. Does that make it clearer? From djc at object-craft.com.au Tue Jul 8 13:13:19 2003 From: djc at object-craft.com.au (Dave Cole) Date: 08 Jul 2003 23:13:19 +1000 Subject: [albatross-users] Re: Using additional path information as request parameters In-Reply-To: References: <3F0957C9.5020600@pollenation.net> Message-ID: > Matt> What I would rather use is a URL with 123 as the last part of > Matt> the path: > > Matt> /app.py/book/123 [snip] > Matt> In both cases the book module would process the request. > You might even be able to bend the RandomPageModuleMixin.load_page() > to suit your needs. [snip] > New method(s): > > def load_page(self, ctx): > # Get page name from request URI > uri = ctx.request.get_uri() > page = self.get_page_from_uri(ctx, uri) > if not page: > ctx.redirect(self.start_page()) > # [snip] > > def get_page_from_uri(self, ctx, uri): > try: > base_path = urlparse.urlparse(self.base_url())[2] > uri_path = urlparse.urlparse(uri)[2] > return uri_path.split(base_path, 1)[1] > except IndexError: > return None > > Then in your application you are free to implement any kind of URI > splitting you like by overriding get_page_from_uri(). All you have to > do is return something that the load_page_module() method (in > PageModuleMixin) can use to load a page module. > > Does any of that make sense? I couldn't help myself - it seemed like such a simple change I just went ahead and did it. Check out the documentation: http://www.object-craft.com.au/~djc/albatross/mixin-randpage-module.html Read load_page() and get_page_from_uri(). Now you should be able to do something like this for your application class (although probably a little cleaner): import urlparse class MyApp(RandomModularApp): def get_page_from_uri(self, ctx, uri): # uri of form http://blah.com/path/app.py/book/123 path = urlparse.urlparse(uri)[2] # path of form /path/app.py/book/123 path = path.split('/app.py')[1] # path of form /book/123 args = path.split('/') # args of form ['', 'book', '123'] ctx.locals._page_args = args[2:] return args[1] -- http://www.object-craft.com.au From djc at object-craft.com.au Tue Jul 8 13:50:24 2003 From: djc at object-craft.com.au (Dave Cole) Date: 08 Jul 2003 23:50:24 +1000 Subject: [albatross-users] Wiki example and related extension: iterate over ctx/session In-Reply-To: <200307080614.QAA13994@lightning.itga.com.au> References: <200307080614.QAA13994@lightning.itga.com.au> Message-ID: > where debug.ht does > Session Vars are:
    >
  • al-for> >
> > This will not show 'new' as a session variable, because it was added > after the session_vars() call. Putting (a reference to) the __vars > dict into the session will not have this problem. > > The other way around the problem is to do the "ctx.locals.session = > ctx.session_vars()" bit in every page_display() routine just before > the run_template call, which is ugly and unnecessary boilerplate. How about this:
  • http://www.object-craft.com.au/~djc/albatross/mixin-ses-base.html - Dave -- http://www.object-craft.com.au From matt at pollenation.net Tue Jul 8 16:29:57 2003 From: matt at pollenation.net (Matt Goodall) Date: Tue, 08 Jul 2003 17:29:57 +0100 Subject: [albatross-users] AppContext.redirect_url() question In-Reply-To: References: <3F099AB2.80805@pollenation.net> Message-ID: <3F0AF185.2050209@pollenation.net> I'm probably being really stupid and missing something obvious but this is the bit from redirect_url() I'm confused about: this_path = urlparse.urlparse(self.request.get_uri())[2] base_path = urlparse.urlparse(self.app.base_url())[2] pos = this_path.find(base_path) new_base = this_path[:pos + len(base_path)] Firstly, this_path and base_path are normally the same up to the name of the script and so pos will be 0. The only time pos can be non-zero is when the URLs don't match at all or this_path contains an extra path at the start. I can't think of a situation where this_path has the extra path. So ... that makes new_base the same as base_path and so I don't understand why you cannot simply add the redirect location to the base_path. You can all humiliate me now and tell me that I can't read simple code if you want ;-). My big question is why bother with pos and the this_path slice? What is it needed for? Anyway, that is just me trying to figure out what's going on. More importantly, at least for me, when I put a mod_python app behind a mod_rewrite rule redirect_url() fails since mod_python's Request.get_uri() returns the *rewritten* path which may have no relationship to the application's base_url. That causes this_path.find() to return -1 and after that things get a little messy ;-). I have been playing around with using PATH_INFO (in CGI speak) as an alternative to decoding the URLs. A set of patches follow, I would be interested in your thoughts. Cheers, Matt Dave Cole wrote: >>>>>>"Matt" == Matt Goodall writes: >>>>>> >>>>>> > >Matt> Hi, Can anyone explain why the method in the subject is fiddling >Matt> around with uri paths? It looks like it's trying to cope with >Matt> the situation when the base uri and the request uri differ but I >Matt> don't understand why and it's probably not quite right, >Matt> i.e. what happens if the two URIs do not match correctly? When >Matt> would the two URIs be different anyway? > >All of that code (which could probably be improved) is trying to >ensure that only absolute redirect URLs come out of the application. > >You can see what it is trying to do by placing this application in >your cgi-bin directory and pointing your browser at it. > >- - redirect.py - - - - - - - - - - - - - - - - - - - - - - - - - - - >#!/usr/bin/python >import sys >import os > >if __name__ == '__main__': > host = os.environ.get('HTTP_HOST') > script_name = os.environ.get('SCRIPT_NAME') > uri = os.environ.get('REQUEST_URI') > > page = uri[len(script_name):] > sys.stderr.write('uri="%s", page="%s"\n' % (uri, page)) > if page == '/there': > print 'Content-Type: text/plain' > print > print 'You are there' > else: > # This works perfectly > loc = 'http://%s%s/there' % (host, script_name) > # These all cause all sorts of strife > #loc = '/%s/there' % script_name > #loc = 'there' > print 'Location:', loc > print 'Status:', '301 Moved Permanently' > print >- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - > >The Albatross code is just trying to figure out how to construct an >absolute location for the requested redirect. It also tries to avoid >fiddling with a URL that is already absolute. > >Matt> Also, why does Albatross not make use of path info >Matt> (os.environ['PATH_INFO'] in cgi, req.path_info in mod_python; >Matt> not sure for BaseHTTPServer)? I think path info could simplify >Matt> the parsing and building or URLs which has been causing me a few >Matt> problems today when I popped a mod_python app behind a >Matt> mod_rewrite rule :(. > >I am more than happy to change the current code if you figure out a >better way to do it. > >- Dave > > > -- Matt Goodall, Pollenation Internet Ltd w: http://www.pollenationinternet.com e: matt@pollenationinternet.com t: +44 (0)113 2252500 From matt at pollenation.net Tue Jul 8 17:03:19 2003 From: matt at pollenation.net (Matt Goodall) Date: Tue, 08 Jul 2003 18:03:19 +0100 Subject: [albatross-users] [patch] get_uri -> get_path_info changes Message-ID: <3F0AF957.6050402@pollenation.net> This is a multi-part message in MIME format. --------------080504040305000105010102 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit WARNING: This email contains experimental patches which may be harmful to small children and production systems. Attached are a series of patches that are sitting on my machine, some of which have already been accepted and applied: 01.base_url.patch - a patch to fix my previous patch. Already applied by Dave I think. 02.fcgiapp_get_header.patch - erm, see above ;-). Already applied by Andrew 03.httpdapp.patch - simplified version of Request.get_uri(). 04.get_path_info.patch - introduces get_path_info() methods into the request adapters. 05.use_path_info.patch - switch from using Request.get_uri() to Request.get_path_info(). This affects how the random page loader works and how the current and redirect urls are calculated. All patches are based on 1.10pre2 and were applied in the order above. I feel that I am getting a little out of my depth with these changes in that I'm not entirely sure what effect they may have on the rest of the framework. What I can say is that the popview5 and form4 samples still work and that a simple application (two linked pages, one with basic form processing) written as RandomModularSessionApp and SimpleSessionApp is working in cgi, fcgi, mod_python and httpdapp mode. These simple apps also work behind a mod_rewrite rule which previously failed for me and is the cause of my experimentation. I would really, really appreciate some feedback on the path_info changes since the mod_rewrite stuff could be quite important to me. I think I'd better do some real work tomorrow :(. Cheers, Matt -- Matt Goodall, Pollenation Internet Ltd w: http://www.pollenationinternet.com e: matt@pollenationinternet.com --------------080504040305000105010102 Content-Type: text/plain; name="01.base_url.patch" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="01.base_url.patch" diff -ru albatross-1.10pre2-original/albatross/app.py albatross-1.10pre2/albatross/app.py --- albatross-1.10pre2-original/albatross/app.py 2003-07-05 08:52:40.000000000 +0100 +++ albatross-1.10pre2/albatross/app.py 2003-07-07 11:08:48.000000000 +0100 @@ -221,11 +221,12 @@ def __init__(self, base_url): ResourceMixin.__init__(self) self.register_tagclasses(*tags.tags) - # Use a base_url of '/' if not provided - if base_url: - self.__base_url = base_url - else: + # Always append a '/' to the base_url if it is missing + self.__base_url = base_url + if not self.__base_url: self.__base_url = '/' + elif self.__base_url[-1] != '/': + self.__base_url = self.__base_url + '/' def run(self, req): '''Process a single browser request --------------080504040305000105010102 Content-Type: text/plain; name="02.fcgiapp_get_header.patch" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="02.fcgiapp_get_header.patch" --- albatross-1.10pre2/albatross/fcgiapp.py 2003-07-05 04:12:16.000000000 +0100 +++ albatross-1.10pre2-patched/albatross/fcgiapp.py 2003-07-07 23:03:53.000000000 +0100 @@ -19,14 +19,14 @@ cgiapp.Request.__init__(self, fields) def get_uri(self): - return self.__fcgi.env['REQUEST_URI'] + return self.__fcgi.env.get('REQUEST_URI') def get_servername(self): - return self.__fcgi.env['SERVER_NAME'] + return self.__fcgi.env.get('SERVER_NAME') def get_header(self, name): env_name = 'HTTP_' + name.upper().replace('-', '_') - return self.__req.env.get(env_name) + return self.__fcgi.env.get(env_name) def running(): --------------080504040305000105010102 Content-Type: text/plain; name="03.httpdapp.patch" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="03.httpdapp.patch" --- albatross-1.10pre2/albatross/httpdapp.py 2003-07-05 11:29:01.000000000 +0100 +++ albatross-1.10pre2-patched/albatross/httpdapp.py 2003-07-08 00:18:58.000000000 +0100 @@ -82,11 +82,7 @@ return self._fields.keys() def get_uri(self): - server_name = self._req.server.server_name - server_port = self._req.server.server_port - path = self._req.path - uri = 'http://%s:%d%s' % (server_name, server_port, path) - return uri + return self._req.path def get_servername(self): server_name = self._req.server.server_name --------------080504040305000105010102 Content-Type: text/plain; name="04.get_path_info.patch" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="04.get_path_info.patch" --- albatross-1.10pre2/albatross/apacheapp.py 2003-07-05 04:12:16.000000000 +0100 +++ albatross-1.10pre2-patched/albatross/apacheapp.py 2003-07-07 21:41:50.000000000 +0100 @@ -17,6 +17,9 @@ def get_uri(self): return self.__req.uri + def get_path_info(self): + return self.__req.path_info + def get_servername(self): try: return self.__req.hostname # mod_python 3 --- albatross-1.10pre2/albatross/cgiapp.py 2003-07-05 04:49:13.000000000 +0100 +++ albatross-1.10pre2-patched/albatross/cgiapp.py 2003-07-08 00:08:40.000000000 +0100 @@ -60,6 +60,9 @@ def get_uri(self): return os.environ.get('REQUEST_URI') + def get_path_info(self): + return os.environ.get('PATH_INFO') + def get_servername(self): return os.environ.get('SERVER_NAME') --- albatross-1.10pre2/albatross/fcgiapp.py 2003-07-08 00:07:02.000000000 +0100 +++ albatross-1.10pre2-patched/albatross/fcgiapp.py 2003-07-07 23:18:15.000000000 +0100 @@ -21,6 +21,9 @@ def get_uri(self): return self.__fcgi.env.get('REQUEST_URI') + def get_path_info(self): + return self.__fcgi.env.get('PATH_INFO') + def get_servername(self): return self.__fcgi.env.get('SERVER_NAME') --- albatross-1.10pre2/albatross/httpdapp.py 2003-07-08 00:21:08.000000000 +0100 +++ albatross-1.10pre2-patched/albatross/httpdapp.py 2003-07-08 00:20:38.000000000 +0100 @@ -84,6 +84,9 @@ def get_uri(self): return self._req.path + def get_path_info(self): + return self._req.path + def get_servername(self): server_name = self._req.server.server_name port = self._req.server.server_port --------------080504040305000105010102 Content-Type: text/plain; name="05.use_path_info.patch" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="05.use_path_info.patch" Only in albatross-1.10pre2-patched/albatross: .randompage.py.swp diff -ru albatross-1.10pre2.2/albatross/app.py albatross-1.10pre2-patched/albatross/app.py --- albatross-1.10pre2.2/albatross/app.py 2003-07-08 15:30:20.000000000 +0100 +++ albatross-1.10pre2-patched/albatross/app.py 2003-07-08 12:17:35.000000000 +0100 @@ -191,19 +191,22 @@ return self.app.base_url() def current_url(self): - uri = self.request.get_uri() - scheme, netloc, path = urlparse.urlparse(uri)[:3] - return path + if not self.request.get_path_info(): + this_path = '' + else: + this_path = urlparse.urlparse(self.request.get_path_info())[2] + base_path = urlparse.urlparse(self.app.base_url())[2] + if base_path and base_path[-1] == '/': + if this_path and this_path[0] == '/': + this_path = this_path[1:] + return base_path + this_path def redirect_url(self, loc): - this_path = urlparse.urlparse(self.request.get_uri())[2] base_path = urlparse.urlparse(self.app.base_url())[2] - pos = this_path.find(base_path) - new_base = this_path[:pos + len(base_path)] - if new_base[-1] != '/': - new_base = new_base + '/' + if base_path[-1] != '/': + base_path = base_path + '/' return urlparse.urlunparse(('http', self.request.get_servername(), - new_base + loc, '', '', '')) + base_path + loc, '', '', '')) def redirect(self, loc): scheme, netloc, path = urlparse.urlparse(loc)[:3] diff -ru albatross-1.10pre2.2/albatross/randompage.py albatross-1.10pre2-patched/albatross/randompage.py --- albatross-1.10pre2.2/albatross/randompage.py 2003-07-05 08:52:40.000000000 +0100 +++ albatross-1.10pre2-patched/albatross/randompage.py 2003-07-08 15:30:56.000000000 +0100 @@ -18,14 +18,9 @@ def load_page(self, ctx): # Get page name from request URI - uri = ctx.request.get_uri() - page = '' - try: - base_path = urlparse.urlparse(self.base_url())[2] - uri_path = urlparse.urlparse(uri)[2] - page = uri_path.split(base_path, 1)[1] - except IndexError: - pass + page = ctx.request.get_path_info() + if page and page[0] == '/': + page = page[1:] if not page: ctx.redirect(self.start_page()) --------------080504040305000105010102-- From gnb at itga.com.au Tue Jul 8 23:22:42 2003 From: gnb at itga.com.au (Gregory Bond) Date: Wed, 09 Jul 2003 09:22:42 +1000 Subject: [albatross-users] Wiki example and related extension: iterate over ctx/session In-Reply-To: Your message of 08 Jul 2003 23:50:24 +1000. Message-ID: <200307082322.JAA28934@lightning.itga.com.au> djc@object-craft.com.au said: > How about this: > >
  • >
    Kool. Works for me! From sheila at thinkspot.net Wed Jul 9 04:41:15 2003 From: sheila at thinkspot.net (Sheila King) Date: Tue, 08 Jul 2003 21:41:15 -0700 Subject: [albatross-users] Upgrade problems to albatross 1.10pre2 Message-ID: <312402881.1057700475@SHEILA-LAPTOP> OK, so I decided to try an upgrade to the latest pre-release. Downloaded it and put it on my server. Note: I do not have, and am not able to have root perms on the community server where my account is. However, I have installed my own local copy of Python, which I have aliased as "pythonx", and when I previously installed albatross 1.01 the following install command worked just fine: $ pythonx setup.py install and installed everything properly. OK, so I uploaded the tarball of 1.10pre2 to my home directory and unzipped it; everything looked fine. I gave the command: $ pythonx setup.py install All of the output looked fine. I cd to the /test directory. Unfortunately, there is a problem with running the test programs as directed. I entered $ make and got the following error output: PYTHONPATH=.. python all.py Traceback (innermost last): File "all.py", line 14, in ? import unittest ImportError: No module named unittest make: *** [unittests] Error 1 So, instead I tried this: $ pythonx all.py which seemed to work mostly fine. I did get one error result: ====================================================================== ERROR: runTest (sessions.basic.ServerBasicCase) ---------------------------------------------------------------------- Traceback (most recent call last): File "sessions/basic.py", line 26, in runTest ctx.load_session() File "/big/dom/xdomain/lib/python2.2/site-packages/albatross/session.py", line 50, in load_session sesid = self.app.new_session() File "/big/dom/xdomain/lib/python2.2/site-packages/albatross/session.py", line 149, in new_session self._server_connect() File "/big/dom/xdomain/lib/python2.2/site-packages/albatross/session.py", line 104, in _server_connect raise ServerError('could not connect to session server') ServerError: could not connect to session server ---------------------------------------------------------------------- Ran 92 tests in 0.289s FAILED (errors=1) Which, I guess is expected, as I am not running the session server ??? Anyhow, the next thing I did was try to go to my application, which I had tested this afternoon before upgrading to the latest albatross. I get the following error output when I try to go to the base URL for my application: Template traceback (most recent call last): Traceback (most recent call last): File "/big/dom/xdomain/lib/python2.2/site-packages/albatross/app.py", line 238, in run self.load_page(ctx) File "/big/dom/xdomain/lib/python2.2/site-packages/albatross/randompage.py ", line 35, in load_page self.load_page_module(ctx, page) File "/big/dom/xdomain/lib/python2.2/site-packages/albatross/app.py", line 372, in load_page_module file, filepath, desc = imp.find_module(name, [dirname]) ImportError: No module named login Which is really weird, because the login.py file hasn't moved. The app worked the last time I tried it, and the only thing that has changed, is that I have upgraded albatross. Thoughts? Suggestions? From andrewm at object-craft.com.au Wed Jul 9 05:16:21 2003 From: andrewm at object-craft.com.au (Andrew McNamara) Date: Wed, 09 Jul 2003 15:16:21 +1000 Subject: [albatross-users] Upgrade problems to albatross 1.10pre2 In-Reply-To: Message from Sheila King of "Tue, 08 Jul 2003 21:41:15 MST." <312402881.1057700475@SHEILA-LAPTOP> References: <312402881.1057700475@SHEILA-LAPTOP> Message-ID: <20030709051621.9388C3C024@coffee.object-craft.com.au> >Unfortunately, there is a problem with running the test programs as >directed. I entered > >$ make > >and got the following error output: > >PYTHONPATH=.. python all.py >Traceback (innermost last): > File "all.py", line 14, in ? > import unittest >ImportError: No module named unittest >make: *** [unittests] Error 1 > >So, instead I tried this: > >$ pythonx all.py Yes - the makefile ran the wrong python - your solution is the correct one. You could also have used "PYTHONPATH=.. pythonx all.py", which would allow you to run the tests without installing albatross. >which seemed to work mostly fine. I did get one error result: [...] >ServerError: could not connect to session server > >---------------------------------------------------------------------- >Ran 92 tests in 0.289s > >FAILED (errors=1) > >Which, I guess is expected, as I am not running the session server ??? That's right - if you started the session server (doesn't need to be root), this test would have passed, but there's not really a lot of point (and your hosts might get upset with random processes listening on random ports). >Anyhow, the next thing I did was try to go to my application, which I >had tested this afternoon before upgrading to the latest albatross. > >I get the following error output when I try to go to the base URL for >my application: > >Template traceback (most recent call last): > >Traceback (most recent call last): > File >"/big/dom/xdomain/lib/python2.2/site-packages/albatross/app.py", line >238, in run > self.load_page(ctx) > File >"/big/dom/xdomain/lib/python2.2/site-packages/albatross/randompage.py >", line 35, in load_page > self.load_page_module(ctx, page) > File >"/big/dom/xdomain/lib/python2.2/site-packages/albatross/app.py", line >372, in load_page_module > file, filepath, desc = imp.find_module(name, [dirname]) >ImportError: No module named login > >Which is really weird, because the login.py file hasn't moved. The >app worked the last time I tried it, and the only thing that has >changed, is that I have upgraded albatross. That's a curly one. I'd suggest putting some debug in before the above line in albatross. Write os.getcwd() and dirname to sys.stderr. If you don't have access to the web server's stderr output, you could write the debug to a file in /tmp, etc. "dirname" is derived from the module name ("login") and the module_path you specified when creating the app object. -- Andrew McNamara, Senior Developer, Object Craft http://www.object-craft.com.au/ From sheila at thinkspot.net Wed Jul 9 05:41:11 2003 From: sheila at thinkspot.net (Sheila King) Date: Tue, 08 Jul 2003 22:41:11 -0700 Subject: [albatross-users] Upgrade problems to albatross 1.10pre2 In-Reply-To: <20030709051621.9388C3C024@coffee.object-craft.com.au> References: <312402881.1057700475@SHEILA-LAPTOP> <20030709051621.9388C3C024@coffee.object-craft.com.au> Message-ID: <315999543.1057704071@SHEILA-LAPTOP> --On Wednesday, July 09, 2003 3:16 PM +1000 Andrew McNamara wrote: > > Anyhow, the next thing I did was try to go to my application, > > which I had tested this afternoon before upgrading to the latest > > albatross. > > > > I get the following error output when I try to go to the base URL > > for my application: > > > > Template traceback (most recent call last): > > > > Traceback (most recent call last): > > File > > "/big/dom/xdomain/lib/python2.2/site-packages/albatross/app.py", > > line 238, in run > > self.load_page(ctx) > > File > > "/big/dom/xdomain/lib/python2.2/site-packages/albatross/randompag > > e.py ", line 35, in load_page > > self.load_page_module(ctx, page) > > File > > "/big/dom/xdomain/lib/python2.2/site-packages/albatross/app.py", > > line 372, in load_page_module > > file, filepath, desc = imp.find_module(name, [dirname]) > > ImportError: No module named login > > > > Which is really weird, because the login.py file hasn't moved. > > The app worked the last time I tried it, and the only thing that > > has changed, is that I have upgraded albatross. > > That's a curly one. I'd suggest putting some debug in before the > above line in albatross. Write os.getcwd() and dirname to > sys.stderr. If you don't have access to the web server's stderr > output, you could write the debug to a file in /tmp, etc. > > "dirname" is derived from the module name ("login") and the > module_path you specified when creating the app object. > OK, good suggestions. I have done this, and the output was as follows: os.getcwd() = /big/dom/xdomain/cgi-bin/qa_auth dirname = / cwd looks correct, as that is the directory wherein the cgi file is stored for the main app file. I am using the SessionFileAppMixin and there is no place to specify an alternate directory for the template files (or at least there wasn't in the previous version). My class definition and __init__ is as follows: class qaApp(PickleSignMixin, Application, TemplateLoaderMixin, RandomPageModuleMixin, SessionFileAppMixin): def __init__(self, base_url = 'mgr.py', page_path = '.', start_page = 'login', secret = '-=-secret-=-', session_appid = 'questadmin', session_dir = './sessions'): Application.__init__(self, base_url) PickleSignMixin.__init__(self, secret) TemplateLoaderMixin.__init__(self, page_path) RandomPageModuleMixin.__init__(self, page_path, start_page) SessionFileAppMixin.__init__(self, session_appid, session_dir) Ah, actually I do see, there is a "page_path" and it is correct. The pages are all in the same directory with the main app file. K, so nothing looks wrong to me here. :/ -- Sheila King http://www.thinkspot.net/sheila/ http://www.k12groups.org From andrewm at object-craft.com.au Wed Jul 9 06:03:47 2003 From: andrewm at object-craft.com.au (Andrew McNamara) Date: Wed, 09 Jul 2003 16:03:47 +1000 Subject: [albatross-users] Upgrade problems to albatross 1.10pre2 In-Reply-To: Message from Sheila King of "Tue, 08 Jul 2003 22:41:11 MST." <315999543.1057704071@SHEILA-LAPTOP> References: <312402881.1057700475@SHEILA-LAPTOP> <20030709051621.9388C3C024@coffee.object-craft.com.au> <315999543.1057704071@SHEILA-LAPTOP> Message-ID: <20030709060347.283353C024@coffee.object-craft.com.au> >OK, good suggestions. I have done this, and the output was as follows: > >os.getcwd() = /big/dom/xdomain/cgi-bin/qa_auth >dirname = / Okay - this means that load_page_module has been called with name="/login" - this means the page name extraction code in RandomPageModuleMixin.load_page() is buggy. Dave will look at this shortly, I hope. Dave - we probably also need to add a check to ensure load_page_module is never called with an absolute path - it's a security problem. > def __init__(self, base_url = 'mgr.py', > page_path = '.', > start_page = 'login', > secret = '-=-secret-=-', > session_appid = 'questadmin', > session_dir = './sessions'): > Application.__init__(self, base_url) > PickleSignMixin.__init__(self, secret) > TemplateLoaderMixin.__init__(self, page_path) > RandomPageModuleMixin.__init__(self, page_path, start_page) > SessionFileAppMixin.__init__(self, session_appid, session_dir) > >Ah, actually I do see, there is a "page_path" and it is correct. The >pages are all in the same directory with the main app file. As a workaround, can you try setting base_url to 'mgr.py/' (note the addition of a slash to the end of the string)? -- Andrew McNamara, Senior Developer, Object Craft http://www.object-craft.com.au/ From sheila at thinkspot.net Wed Jul 9 06:29:09 2003 From: sheila at thinkspot.net (Sheila King) Date: Tue, 08 Jul 2003 23:29:09 -0700 Subject: [albatross-users] Upgrade problems to albatross 1.10pre2 In-Reply-To: <20030709060347.283353C024@coffee.object-craft.com.au> References: <312402881.1057700475@SHEILA-LAPTOP> <20030709051621.9388C3C024@coffee.object-craft.com.au> <315999543.1057704071@SHEILA-LAPTOP> <20030709060347.283353C024@coffee.object-craft.com.au> Message-ID: <318876900.1057706949@SHEILA-LAPTOP> --On Wednesday, July 09, 2003 4:03 PM +1000 Andrew McNamara wrote: > > As a workaround, can you try setting base_url to 'mgr.py/' (note the > addition of a slash to the end of the string)? OK, well this resulted in a very weird error. Instead of sending me to http://www.example.com/cgi-bin/qa_auth/mgr.py/login which is where it *should* send me, it sent me to the following: http://www.example.com/cgi-b/login which resulted in a 404 error from my web site's Apache server (i.e. the usual 404 page for my site, and not the Bad URL error from albatross) -- Sheila King http://www.thinkspot.net/sheila/ http://www.k12groups.org From andrewm at object-craft.com.au Wed Jul 9 06:42:14 2003 From: andrewm at object-craft.com.au (Andrew McNamara) Date: Wed, 09 Jul 2003 16:42:14 +1000 Subject: [albatross-users] Upgrade problems to albatross 1.10pre2 In-Reply-To: Message from Sheila King of "Tue, 08 Jul 2003 23:29:09 MST." <318876900.1057706949@SHEILA-LAPTOP> References: <312402881.1057700475@SHEILA-LAPTOP> <20030709051621.9388C3C024@coffee.object-craft.com.au> <315999543.1057704071@SHEILA-LAPTOP> <20030709060347.283353C024@coffee.object-craft.com.au> <318876900.1057706949@SHEILA-LAPTOP> Message-ID: <20030709064214.A35E43C024@coffee.object-craft.com.au> >> As a workaround, can you try setting base_url to 'mgr.py/' (note the >> addition of a slash to the end of the string)? > >OK, well this resulted in a very weird error. > >Instead of sending me to > >http://www.example.com/cgi-bin/qa_auth/mgr.py/login > >which is where it *should* send me, it sent me to the following: > >http://www.example.com/cgi-b/login > >which resulted in a 404 error from my web site's Apache server (i.e. >the usual 404 page for my site, and not the Bad URL error from >albatross) Ha. So much for that idea. The cause of the problem is Matt Goodall's patch to allow random page applications to work with his standalone server. Until we work out a solution that allows both deployment methods to work, it's probably enough just to revert this change - randompage.py, line 26: page = uri_path.split(base_path, 1)[1] should be changed to read: page = uri_path.split(base_path + '/', 1)[1] -- Andrew McNamara, Senior Developer, Object Craft http://www.object-craft.com.au/ From sheila at thinkspot.net Wed Jul 9 07:03:05 2003 From: sheila at thinkspot.net (Sheila King) Date: Wed, 09 Jul 2003 00:03:05 -0700 Subject: [albatross-users] Upgrade problems to albatross 1.10pre2 In-Reply-To: <20030709064214.A35E43C024@coffee.object-craft.com.au> References: <312402881.1057700475@SHEILA-LAPTOP> <20030709051621.9388C3C024@coffee.object-craft.com.au> <315999543.1057704071@SHEILA-LAPTOP> <20030709060347.283353C024@coffee.object-craft.com.au> <318876900.1057706949@SHEILA-LAPTOP> <20030709064214.A35E43C024@coffee.object-craft.com.au> Message-ID: <320913679.1057708985@SHEILA-LAPTOP> --On Wednesday, July 09, 2003 4:42 PM +1000 Andrew McNamara wrote: > >> As a workaround, can you try setting base_url to 'mgr.py/' (note > >> the addition of a slash to the end of the string)? > > > > OK, well this resulted in a very weird error. > > > > Instead of sending me to > > > > http://www.example.com/cgi-bin/qa_auth/mgr.py/login > > > > which is where it *should* send me, it sent me to the following: > > > > http://www.example.com/cgi-b/login > > > > which resulted in a 404 error from my web site's Apache server > > (i.e. the usual 404 page for my site, and not the Bad URL error > > from albatross) > > Ha. So much for that idea. The cause of the problem is Matt > Goodall's patch to allow random page applications to work with his > standalone server. Until we work out a solution that allows both > deployment methods to work, it's probably enough just to revert > this change - randompage.py, line 26: > > page = uri_path.split(base_path, 1)[1] > > should be changed to read: > > page = uri_path.split(base_path + '/', 1)[1] OK, well that gets me past that error. Now I have to deal with the fact that I've apparently got a problem due to setting session vars before they exist in the local name space (which is an error now, and didn't used to be). Also, there is now something weird with the way the headers are being written, and the headers are appearing in my web page. Thanks for your help so far. I don't think I would have figured out the path problems with the page module on my own. -- Sheila King http://www.thinkspot.net/sheila/ http://www.k12groups.org From andrewm at object-craft.com.au Wed Jul 9 08:00:10 2003 From: andrewm at object-craft.com.au (Andrew McNamara) Date: Wed, 09 Jul 2003 18:00:10 +1000 Subject: [albatross-users] Upgrade problems to albatross 1.10pre2 In-Reply-To: Message from Sheila King of "Wed, 09 Jul 2003 00:03:05 MST." <320913679.1057708985@SHEILA-LAPTOP> References: <312402881.1057700475@SHEILA-LAPTOP> <20030709051621.9388C3C024@coffee.object-craft.com.au> <315999543.1057704071@SHEILA-LAPTOP> <20030709060347.283353C024@coffee.object-craft.com.au> <318876900.1057706949@SHEILA-LAPTOP> <20030709064214.A35E43C024@coffee.object-craft.com.au> <320913679.1057708985@SHEILA-LAPTOP> Message-ID: <20030709080010.EC71C3C024@coffee.object-craft.com.au> >OK, well that gets me past that error. Now I have to deal with the >fact that I've apparently got a problem due to setting session vars >before they exist in the local name space (which is an error now, and >didn't used to be). Ah - yes. I'm sure this change seemed like a good idea at the time... 8-) I think very strange things happened later in the application's life if you forgot to set the session var. Rather than have albatross explode in obscure ways, we're enforcing the requirement that variables be set before they're registered. >Also, there is now something weird with the way the headers are being >written, and the headers are appearing in my web page. The header code had to have a revamp to allow arbitary headers to be set by the application (content encodings and things like that). Are you able to strip the application down to the simplest form that exhibits this problem and forward the result to me? >Thanks for your help so far. I don't think I would have figured out >the path problems with the page module on my own. Sticking debug into albatross itself is a useful technique (albatross should have more hooks for debugging). There's nothing sacred about the module - we intend people to mess around inside it. -- Andrew McNamara, Senior Developer, Object Craft http://www.object-craft.com.au/ From matt at pollenation.net Wed Jul 9 09:03:54 2003 From: matt at pollenation.net (Matt Goodall) Date: 09 Jul 2003 10:03:54 +0100 Subject: [albatross-users] Upgrade problems to albatross 1.10pre2 In-Reply-To: <20030709064214.A35E43C024@coffee.object-craft.com.au> References: <312402881.1057700475@SHEILA-LAPTOP> <20030709051621.9388C3C024@coffee.object-craft.com.au> <315999543.1057704071@SHEILA-LAPTOP> <20030709060347.283353C024@coffee.object-craft.com.au> <318876900.1057706949@SHEILA-LAPTOP> <20030709064214.A35E43C024@coffee.object-craft.com.au> Message-ID: <1057741433.27471.50.camel@localhost> On Wed, 2003-07-09 at 07:42, Andrew McNamara wrote: > Ha. So much for that idea. The cause of the problem is Matt Goodall's > patch to allow random page applications to work with his standalone > server. Eek, sorry! The 2nd patch for base_url will not fix this either as I never even considered that base_url would not be an absolute path on the server :-(. Cheers, Matt -- Matt Goodall, Pollenation Internet Ltd w: http://www.pollenation.net e: matt@pollenation.net From matt at pollenation.net Wed Jul 9 09:06:41 2003 From: matt at pollenation.net (Matt Goodall) Date: 09 Jul 2003 10:06:41 +0100 Subject: [albatross-users] AppContext.redirect_url() question In-Reply-To: <3F0AF185.2050209@pollenation.net> References: <3F099AB2.80805@pollenation.net> <3F0AF185.2050209@pollenation.net> Message-ID: <1057741600.29259.54.camel@localhost> On Tue, 2003-07-08 at 17:29, Matt Goodall wrote: > I'm probably being really stupid and missing something obvious but this > is the bit from redirect_url() I'm confused about: > > this_path = urlparse.urlparse(self.request.get_uri())[2] > base_path = urlparse.urlparse(self.app.base_url())[2] > pos = this_path.find(base_path) > new_base = this_path[:pos + len(base_path)] > > Firstly, this_path and base_path are normally the same up to the name of > the script and so pos will be 0. The only time pos can be non-zero is > when the URLs don't match at all or this_path contains an extra path at > the start. I can't think of a situation where this_path has the extra path. > > So ... that makes new_base the same as base_path and so I don't > understand why you cannot simply add the redirect location to the > base_path. You can all humiliate me now and tell me that I can't read > simple code if you want ;-). > > My big question is why bother with pos and the this_path slice? What is > it needed for? OK, now I know after reading Sheila's "Upgrade problems" thread. It's for when base_url is not absolute. -- Matt Goodall, Pollenation Internet Ltd w: http://www.pollenation.net e: matt@pollenation.net From andrewm at object-craft.com.au Wed Jul 9 09:22:45 2003 From: andrewm at object-craft.com.au (Andrew McNamara) Date: Wed, 09 Jul 2003 19:22:45 +1000 Subject: [albatross-users] Upgrade problems to albatross 1.10pre2 In-Reply-To: Message from Matt Goodall of "09 Jul 2003 10:03:54 +0100." <1057741433.27471.50.camel@localhost> References: <312402881.1057700475@SHEILA-LAPTOP> <20030709051621.9388C3C024@coffee.object-craft.com.au> <315999543.1057704071@SHEILA-LAPTOP> <20030709060347.283353C024@coffee.object-craft.com.au> <318876900.1057706949@SHEILA-LAPTOP> <20030709064214.A35E43C024@coffee.object-craft.com.au> <1057741433.27471.50.camel@localhost> Message-ID: <20030709092245.79B793C024@coffee.object-craft.com.au> >> Ha. So much for that idea. The cause of the problem is Matt Goodall's >> patch to allow random page applications to work with his standalone >> server. > >Eek, sorry! > >The 2nd patch for base_url will not fix this either as I never even >considered that base_url would not be an absolute path on the server >:-(. Ah well - we applied it without noticing either. Add some comments next time, Dave... (if in doubt, blame Dave)... 8-) -- Andrew McNamara, Senior Developer, Object Craft http://www.object-craft.com.au/ From matt at pollenation.net Wed Jul 9 09:44:09 2003 From: matt at pollenation.net (Matt Goodall) Date: 09 Jul 2003 10:44:09 +0100 Subject: [albatross-users] [patch] get_uri -> get_path_info changes In-Reply-To: <3F0AF957.6050402@pollenation.net> References: <3F0AF957.6050402@pollenation.net> Message-ID: <1057743848.28628.75.camel@localhost> In light of the problem Sheila found, below are some comments on the patches. On Tue, 2003-07-08 at 18:03, Matt Goodall wrote: > 01.base_url.patch - a patch to fix my previous patch. Already > applied by Dave I think. This was clearly the wrong solution as the original base_url patch did not consider that the base_url might not be absolute. > 02.fcgiapp_get_header.patch - erm, see above ;-). Already applied by > Andrew Necessary and already applied. > 03.httpdapp.patch - simplified version of Request.get_uri(). Not necessary but still an improvement. It's kind of irrelevant though as it doesn't work with the old base_url stuff. > 04.get_path_info.patch - introduces get_path_info() methods into the > request adapters. Not much point with 05 but it may be useful anyway. Dave/Andrew, it's up to you. > 05.use_path_info.patch - switch from using Request.get_uri() to > Request.get_path_info(). This affects how the random page loader > works and how the current and redirect urls are calculated. Completely breaks redirect_url when the base_url is not absolute. Do not apply. Cheers, Matt -- Matt Goodall, Pollenation Internet Ltd w: http://www.pollenation.net e: matt@pollenation.net From djc at object-craft.com.au Wed Jul 9 11:45:01 2003 From: djc at object-craft.com.au (Dave Cole) Date: 09 Jul 2003 21:45:01 +1000 Subject: [albatross-users] AppContext.redirect_url() question References: <3F099AB2.80805@pollenation.net> <3F0AF185.2050209@pollenation.net> Message-ID: > I'm probably being really stupid and missing something obvious but > this is the bit from redirect_url() I'm confused about: Not stupid, just not able to read my mind... > this_path = urlparse.urlparse(self.request.get_uri())[2] > base_path = urlparse.urlparse(self.app.base_url())[2] > pos = this_path.find(base_path) > new_base = this_path[:pos + len(base_path)] The idea here is that the URI for a request might be something like this: http://blah.com/path/to/app/app.py/page/here When you call the application constructor you might have specified a base_url of 'app.py'. The toolkit needs to be able to find the page/here part of the request URI. The first step is to isolate the path component of both request URI and the base_url. That is done by the first two lines. this_path = urlparse.urlparse(self.request.get_uri())[2] base_path = urlparse.urlparse(self.app.base_url())[2] For the example above this leads to the following paths this_path path/to/app/app.py/page/here and base_path app.py Then the following lines get executed: pos = this_path.find(base_path) new_base = this_path[:pos + len(base_path)] So new_base is new_base = path/to/app/app.py > Firstly, this_path and base_path are normally the same up to the > name of the script and so pos will be 0. The only time pos can be > non-zero is when the URLs don't match at all or this_path contains > an extra path at the start. I can't think of a situation where > this_path has the extra path. You already answered this in a later email :-) I had to go out tonight so did not get to finish this message until now. > Anyway, that is just me trying to figure out what's going on. More > importantly, at least for me, when I put a mod_python app behind a > mod_rewrite rule redirect_url() fails since mod_python's > Request.get_uri() returns the *rewritten* path which may have no > relationship to the application's base_url. That causes > this_path.find() to return -1 and after that things get a little > messy ;-). I have been thinking that there should be enough information in the request to remove the need to specify base_url. The base_url is only there for the following reasons: * To allow the application to generate URLs to itself. * To allow the application to work out the above (split base from page). > I have been playing around with using PATH_INFO (in CGI speak) as an > alternative to decoding the URLs. A set of patches follow, I would > be interested in your thoughts. I will have a look. I would be interested to know if you think we can eliminate the need to specify a base_url to the application constructor. This would probably make URI parsing a lot more easy. - Dave -- http://www.object-craft.com.au From djc at object-craft.com.au Wed Jul 9 13:04:38 2003 From: djc at object-craft.com.au (Dave Cole) Date: 09 Jul 2003 23:04:38 +1000 Subject: [albatross-users] Upgrade problems to albatross 1.10pre2 In-Reply-To: <20030709060347.283353C024@coffee.object-craft.com.au> References: <312402881.1057700475@SHEILA-LAPTOP> <20030709051621.9388C3C024@coffee.object-craft.com.au> <315999543.1057704071@SHEILA-LAPTOP> <20030709060347.283353C024@coffee.object-craft.com.au> Message-ID: >>>>> "Andrew" == Andrew McNamara writes: >> OK, good suggestions. I have done this, and the output was as >> follows: >> >> os.getcwd() = /big/dom/xdomain/cgi-bin/qa_auth dirname = / Andrew> Okay - this means that load_page_module has been called with Andrew> name="/login" - this means the page name extraction code in Andrew> RandomPageModuleMixin.load_page() is buggy. Dave will look at Andrew> this shortly, I hope. I have been wondering if it is possible for the application to discover the base_url from the web server. It certainly is using CGI, so probably is with FastCGI too, but I am not so sure about mod_python. I am certain the BaseHTTPServer cannot supply enough information. With CGI the SCRIPT_NAME environment tells you the base_url. Just played a bit With mod_python. The path_info does not help me as much as it could. Maybe I have missed something in my Apache configuration. I have allowed .htaccess files by doing this: AllowOverride FileInfo Indexes Order allow,deny Allow from all Then in the /var/www/alsamp/simple directory I have added this .htacess file: DirectoryIndex simple.py SetHandler python-program PythonHandler simple Now the funny thing is that when I look at the Request.path_info information there is one path element missing... uri /alsamp/simple/something/missing path_info /missing I was sure that the 'something/' would appear in the path_info. If there was some way to find the missing path element then there would be no need for the base_url argument to the application constructor. This would allow the toolkit to be certain about the part of the URI that corresponded to the application location, and so it would be able to find the path to the right of that. Andrew> Dave - we probably also need to add a check to ensure Andrew> load_page_module is never called with an absolute path - it's Andrew> a security problem. I think we need to prevent any attempt to climb directories. Didn't you have some code for that somewhere? - Dave -- http://www.object-craft.com.au From djc at object-craft.com.au Wed Jul 9 13:35:26 2003 From: djc at object-craft.com.au (Dave Cole) Date: 09 Jul 2003 23:35:26 +1000 Subject: [albatross-users] Upgrade problems to albatross 1.10pre2 In-Reply-To: <20030709092245.79B793C024@coffee.object-craft.com.au> References: <312402881.1057700475@SHEILA-LAPTOP> <20030709051621.9388C3C024@coffee.object-craft.com.au> <315999543.1057704071@SHEILA-LAPTOP> <20030709060347.283353C024@coffee.object-craft.com.au> <318876900.1057706949@SHEILA-LAPTOP> <20030709064214.A35E43C024@coffee.object-craft.com.au> <1057741433.27471.50.camel@localhost> <20030709092245.79B793C024@coffee.object-craft.com.au> Message-ID: >>>>> "Andrew" == Andrew McNamara writes: >>> Ha. So much for that idea. The cause of the problem is Matt >>> Goodall's patch to allow random page applications to work with his >>> standalone server. >> Eek, sorry! >> >> The 2nd patch for base_url will not fix this either as I never even >> considered that base_url would not be an absolute path on the >> server :-(. Andrew> Ah well - we applied it without noticing either. Add some Andrew> comments next time, Dave... (if in doubt, blame Dave)... 8-) Always a good move - you are seldom wrong... I am completely stumped trying to get a path_info that is not missing the first directory element. Try out the following files with mod_python and tell me what I am doing wrong. - Dave - - /var/www/alsamp/simple/.htaccess - - - - - - - - - - - - - - - - DirectoryIndex app.py SetHandler python-program PythonHandler app - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - /var/www/alsamp/simple/app.py - - - - - - - - - - - - - - - - - from mod_python import apache from albatross import SimpleContext def handler(req): req.content_type = 'text/html' req.send_http_header() ctx = SimpleContext('.') ctx.locals.req = req templ = ctx.load_template('/var/www/alsamp/simple/req.html') ctx.push_content_trap() templ.to_html(ctx) req.write(ctx.pop_content_trap()) return apache.OK - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - /var/www/alsamp/simple/req.html - - - - - - - - - - - - - - - - The mod_python environment Request members
    get_config()
    get_dirs()
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -- http://www.object-craft.com.au From matt at pollenation.net Wed Jul 9 14:16:51 2003 From: matt at pollenation.net (Matt Goodall) Date: 09 Jul 2003 15:16:51 +0100 Subject: [albatross-users] [patch] Another attempt at "fixing" base_url Message-ID: <1057760211.28628.269.camel@localhost> --=-9GXKMzKrz+DiGLRJckg4 Content-Type: text/plain Content-Transfer-Encoding: 7bit Attached is another patch, against stock 1.10pre2, which attempts to make the base_url + httpdapp combination work without breaking everything else ;-). This time, with the knowledge that a relative base_url is perfectly valid, I have taken the approach of "fixing up" the base_url where it is used to determine the page and build redirect urls. I hope this approach is a little more successful than the previous one! I have tested this for a RandomModularSessionApp in cgiapp, fcgiapp and apacheapp mode with an absolute and relative base_url. It also works for httpdapp. Cheers, Matt -- Matt Goodall, Pollenation Internet Ltd w: http://www.pollenation.net e: matt@pollenation.net --=-9GXKMzKrz+DiGLRJckg4 Content-Disposition: attachment; filename=base_url.patch Content-Type: text/x-patch; name=base_url.patch; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable diff -ru albatross-1.10pre2/albatross/app.py albatross-1.10pre2-matt/albatr= oss/app.py --- albatross-1.10pre2/albatross/app.py 2003-07-05 08:52:40.000000000 +0100 +++ albatross-1.10pre2-matt/albatross/app.py 2003-07-09 15:11:13.000000000 = +0100 @@ -198,6 +198,9 @@ def redirect_url(self, loc): this_path =3D urlparse.urlparse(self.request.get_uri())[2] base_path =3D urlparse.urlparse(self.app.base_url())[2] + # If no base_path then the application is mounted at the root + if not base_path: + base_path =3D '/' pos =3D this_path.find(base_path) new_base =3D this_path[:pos + len(base_path)] if new_base[-1] !=3D '/': @@ -221,11 +224,7 @@ def __init__(self, base_url): ResourceMixin.__init__(self) self.register_tagclasses(*tags.tags) - # Use a base_url of '/' if not provided - if base_url: - self.__base_url =3D base_url - else: - self.__base_url =3D '/' + self.__base_url =3D base_url =20 def run(self, req): '''Process a single browser request diff -ru albatross-1.10pre2/albatross/randompage.py albatross-1.10pre2-matt= /albatross/randompage.py --- albatross-1.10pre2/albatross/randompage.py 2003-07-05 08:52:40.00000000= 0 +0100 +++ albatross-1.10pre2-matt/albatross/randompage.py 2003-07-09 13:14:32.000= 000000 +0100 @@ -23,6 +23,12 @@ try: base_path =3D urlparse.urlparse(self.base_url())[2] uri_path =3D urlparse.urlparse(uri)[2] + # Fixup base_path to end with a '/' so that it can be used as + # a root path. + if not base_path: + base_path =3D '/' + elif base_path[-1] !=3D '/': + base_path =3D base_path + '/' page =3D uri_path.split(base_path, 1)[1] except IndexError: pass --=-9GXKMzKrz+DiGLRJckg4-- From matt at pollenation.net Wed Jul 9 15:50:54 2003 From: matt at pollenation.net (Matt Goodall) Date: 09 Jul 2003 16:50:54 +0100 Subject: path_info (was Re: [albatross-users] Upgrade problems to albatross 1.10pre2) In-Reply-To: References: <312402881.1057700475@SHEILA-LAPTOP> <20030709051621.9388C3C024@coffee.object-craft.com.au> <315999543.1057704071@SHEILA-LAPTOP> <20030709060347.283353C024@coffee.object-craft.com.au> <318876900.1057706949@SHEILA-LAPTOP> <20030709064214.A35E43C024@coffee.object-craft.com.au> <1057741433.27471.50.camel@localhost> <20030709092245.79B793C024@coffee.object-craft.com.au> Message-ID: <1057765854.28628.282.camel@localhost> On Wed, 2003-07-09 at 14:35, Dave Cole wrote: > I am completely stumped trying to get a path_info that is not missing > the first directory element. Try out the following files with > mod_python and tell me what I am doing wrong. I get the same missing path element when relying on the DirectoryIndex but it works when I add app.py to the URL: /~matt/simple/1/2/3 filename: /home/matt/public_html/simple/1 path_info: /2/3 /~matt/simple/app.py/1/2/3 filename: /home/matt/public_html/simple/app.py path:info: /1/2/3 Very strange, it's as if mod_python just assumes that the first bit is the script name. I'll ask on the mod_python list. We might have an answer by the time Australia wakes up. Cheers, Matt -- Matt Goodall, Pollenation Internet Ltd w: http://www.pollenation.net e: matt@pollenation.net From matt at pollenation.net Wed Jul 9 16:13:16 2003 From: matt at pollenation.net (Matt Goodall) Date: 09 Jul 2003 17:13:16 +0100 Subject: base_url discovery (was Re: [albatross-users] Upgrade problems to albatross 1.10pre2) In-Reply-To: References: <312402881.1057700475@SHEILA-LAPTOP> <20030709051621.9388C3C024@coffee.object-craft.com.au> <315999543.1057704071@SHEILA-LAPTOP> <20030709060347.283353C024@coffee.object-craft.com.au> Message-ID: <1057767195.28628.311.camel@localhost> On Wed, 2003-07-09 at 14:04, Dave Cole wrote: > I have been wondering if it is possible for the application to > discover the base_url from the web server. It certainly is using CGI, > so probably is with FastCGI too, As you pointed out, neither of these should be a problem. > but I am not so sure about mod_python. The problem with this is the one I hit the other day when using mod_rewrite. The uri that Albatross sees is the rewritten uri which can be completely different to what is typed into the browser url bar. Having said that, mod_python has req.the_request which is the http request header, i.e. 'GET /~matt/simple/app.py/1/2/3 HTTP/1.1'. We may be able to make use of that but I haven't looked into it anymore. > I am certain the BaseHTTPServer cannot supply enough > information. No, but it probably doesn't need to as the application is always mounted at '/'. Cheers, Matt -- Matt Goodall, Pollenation Internet Ltd w: http://www.pollenation.net e: matt@pollenation.net From matt at pollenation.net Wed Jul 9 16:35:26 2003 From: matt at pollenation.net (Matt Goodall) Date: 09 Jul 2003 17:35:26 +0100 Subject: [albatross-users] missing path element in path_info Message-ID: <1057768526.27471.335.camel@localhost> Hi, Over in the world of Albatross (http://www.object-craft.com.au/projects/albatross/) we've been playing with path_info and have come across something that we don't quite understand. Here's some example code to demonstrate: ----- .htaccess ----- DirectoryIndex app.py SetHandler python-program PythonHandler app ----- ----- app.py ----- from mod_python import apache def handler(req): req.content_type = 'text/plain' req.send_http_header() req.write('the_request: %s\n' % req.the_request) req.write('unparsed_uri: %s\n' % req.unparsed_uri) req.write('uri: %s\n' % req.uri) req.write('filename: %s\n' % req.filename) req.write('path_info: %s\n' % req.path_info) return apache.OK ----- If I put those files in /~matt/test on the web server then this is what I see for each URL: = URL /~matt/test/1/2/3 = the_request: GET /~matt/test/app.py/1/2/3 HTTP/1.1 unparsed_uri: /~matt/test/app.py/1/2/3 uri: /~matt/test/app.py/1/2/3 filename: /home/matt/public_html/test/app.py path_info: /1/2/3 = /~matt/test/app.py/1/2/3 = the_request: GET /~matt/test/app.py/1/2/3 HTTP/1.1 unparsed_uri: /~matt/test/app.py/1/2/3 uri: /~matt/test/app.py/1/2/3 filename: /home/matt/public_html/test/app.py path_info: /1/2/3 = /~matt/test/1/2/3 = the_request: GET /~matt/test/1/2/3 HTTP/1.1 unparsed_uri: /~matt/test/1/2/3 uri: /~matt/test/1/2/3 filename: /home/matt/public_html/test/1 path_info: /2/3 The first two are as expected but the last one drops app.py completely and thinks that the first element of path_info is part of the filename. Can anyone explain this? Server details: Apache 1.3.27 mod_python 2.7.8 Linux 2.4.x, Gentoo and Debian (I think). Thanks in advance. - Matt -- Matt Goodall, Pollenation Internet Ltd w: http://www.pollenation.net e: matt@pollenation.net From matt at pollenation.net Wed Jul 9 16:42:32 2003 From: matt at pollenation.net (Matt Goodall) Date: 09 Jul 2003 17:42:32 +0100 Subject: [albatross-users] request debugging results Message-ID: <1057768952.27471.342.camel@localhost> I just added some debugging to the cgi, fcgi and mod_python request adapters to dump everything out. I thought the results might be useful with the current discussions about base_url and path_info. - Matt ***** cgiapp PATH_INFO: /home SCRIPT_FILENAME: /home/matt/public_html/albatross/path_info/connector.cgi SCRIPT_NAME: /~matt/albatross/path_info/connector.cgi HTTP_HOST: mattgoodall.dyndns.org QUERY_STRING: PATH_TRANSLATED: /home/httpd/htdocs/home REQUEST_URI: /~matt/albatross/path_info/connector.cgi/home SERVER_NAME: mattgoodall.dyndns.org SERVER_PORT: 80 DOCUMENT_ROOT: /home/httpd/htdocs/ ***** fcgiapp PATH_INFO: /home SCRIPT_FILENAME: /home/matt/public_html/albatross/path_info/connector.fcgi SCRIPT_NAME: /~matt/albatross/path_info/connector.fcgi HTTP_HOST: mattgoodall.dyndns.org QUERY_STRING: PATH_TRANSLATED: /home/httpd/htdocs/home REQUEST_URI: /~matt/albatross/path_info/connector.fcgi/home SERVER_NAME: mattgoodall.dyndns.org SERVER_PORT: 80 DOCUMENT_ROOT: /home/httpd/htdocs/ ***** apacheapp req.the_request: GET /~matt/albatross/path_info/connector.py/home HTTP/1.1 req.unparsed_uri: /~matt/albatross/path_info/connector.py/home req.uri: /~matt/albatross/path_info/connector.py/home req.filename: /home/matt/public_html/albatross/path_info/connector.py req.path_info: /home req.args: None req.server.server_hostname: mattgoodall.dyndns.org req.server.port: 80 -- Matt Goodall, Pollenation Internet Ltd w: http://www.pollenation.net e: matt@pollenation.net From matt at pollenation.net Wed Jul 9 21:35:32 2003 From: matt at pollenation.net (Matt Goodall) Date: 09 Jul 2003 22:35:32 +0100 Subject: [albatross-users] missing path element in path_info In-Reply-To: <1057768526.27471.335.camel@localhost> References: <1057768526.27471.335.camel@localhost> Message-ID: <1057786532.28628.527.camel@localhost> OK, so I got the example output completely wrong (boy, what a day I've had!) but once I corrected it I got a response from the mod_python list which I have summarised below. re: the missing path element in path_info ... "In the last one, the reason "1" is not part of path_info: path_info is something apache figures out. I think the rule is that it sees that "test" is a directory, and the next thing after it isn't, thus, it must refer to a file (whether or not the file exists doesn't matter). Everything after a file is path_info." re: is there a foolproof way to deduce the correct base url and path_info ... "... it is impossible or very difficult to do, because the transformation from "~matt/test" to "/home/matt/public_html/test" is not "reversible" and is hidden somewhere in apache config, yet this mapping is necessary to produce the results above." If you're interested in the full thread see http://www.modpython.org/pipermail/mod_python/2003-July/003420.html. Cheers, Matt On Wed, 2003-07-09 at 17:35, Matt Goodall wrote: > Hi, > > Over in the world of Albatross > (http://www.object-craft.com.au/projects/albatross/) we've been playing > with path_info and have come across something that we don't quite > understand. > > Here's some example code to demonstrate: > > ----- .htaccess ----- > DirectoryIndex app.py > SetHandler python-program > PythonHandler app > ----- > > ----- app.py ----- > from mod_python import apache > def handler(req): > req.content_type = 'text/plain' > req.send_http_header() > > req.write('the_request: %s\n' % req.the_request) > req.write('unparsed_uri: %s\n' % req.unparsed_uri) > req.write('uri: %s\n' % req.uri) > req.write('filename: %s\n' % req.filename) > req.write('path_info: %s\n' % req.path_info) > > return apache.OK > ----- > > If I put those files in /~matt/test on the web server then this is what > I see for each URL: > > = URL /~matt/test/1/2/3 = > the_request: GET /~matt/test/app.py/1/2/3 HTTP/1.1 > unparsed_uri: /~matt/test/app.py/1/2/3 > uri: /~matt/test/app.py/1/2/3 > filename: /home/matt/public_html/test/app.py > path_info: /1/2/3 > > = /~matt/test/app.py/1/2/3 = > the_request: GET /~matt/test/app.py/1/2/3 HTTP/1.1 > unparsed_uri: /~matt/test/app.py/1/2/3 > uri: /~matt/test/app.py/1/2/3 > filename: /home/matt/public_html/test/app.py > path_info: /1/2/3 > > = /~matt/test/1/2/3 = > the_request: GET /~matt/test/1/2/3 HTTP/1.1 > unparsed_uri: /~matt/test/1/2/3 > uri: /~matt/test/1/2/3 > filename: /home/matt/public_html/test/1 > path_info: /2/3 > > The first two are as expected but the last one drops app.py completely > and thinks that the first element of path_info is part of the filename. > > Can anyone explain this? > > Server details: > > Apache 1.3.27 > mod_python 2.7.8 > Linux 2.4.x, Gentoo and Debian (I think). > > Thanks in advance. > > - Matt -- Matt Goodall, Pollenation Internet Ltd w: http://www.pollenation.net e: matt@pollenation.net t: 0113 2252500 From rbw at demec.ufpe.br Wed Jul 9 17:59:35 2003 From: rbw at demec.ufpe.br (Ramiro Brito Willmersdorf) Date: Wed, 9 Jul 2003 14:59:35 -0300 Subject: [albatross-users] Encrypting passwords in a session Message-ID: <20030709175935.GA17731@demec.ufpe.br> Hi, I just built a small application. I think albatross is great, because once you get the hang of it, things flow very smoothly. I need one last thing though, which I'm sure someone must have needed before. I'm storing passwords in session variables, and I'm using the file system to store passwords. This seems to be the glaring security hole (not that there isnt' any others :). Surely someone has solved a similar problem before? I tried googling for something without luck. Most schemes I came up with involved storing an encryption key as a session variable together with the encrypted password. Duh! The next best thing was to generate a random key, encrypt the password with it, store the encrypted password in the server and the key (unique for each session) in the user browser with a cookie (which I was trying hard to avoid, since I want my application to work with the simplest text browsers.) As cryptography algoriths are things best left to professionals, I'm asking for suggestions here. Many thanks for any input, -- Ramiro Brito Willmersdorf rbw@demec.ufpe.br GPG key: http://www.demec.ufpe.br/~rbw/GPG/gpg_key.txt From esj at harvee.org Thu Jul 10 01:03:34 2003 From: esj at harvee.org (Eric S. Johansson) Date: Wed, 09 Jul 2003 21:03:34 -0400 Subject: [albatross-users] Encrypting passwords in a session In-Reply-To: <20030709175935.GA17731@demec.ufpe.br> References: <20030709175935.GA17731@demec.ufpe.br> Message-ID: <3F0CBB66.7060102@harvee.org> Ramiro Brito Willmersdorf wrote: > > Most schemes I came up with involved storing an encryption ... > As cryptography algoriths are things best left to professionals, > I'm asking for suggestions here. good: http://www.unixpapa.com/auth/ better: http://cookies.lcs.mit.edu/ It seems to me that this kind of problems is something that is very common and destined to be reimplemented (poorly). it might make sense to create a class called Simple_authenticated_application (derived from SimpleApp) which gives one the ability to be directed to a login template and do all the fun things like timeouts etc. I'll think about the class overnight and post suggestion in the morning. ---eric From esj at harvee.org Thu Jul 10 13:00:13 2003 From: esj at harvee.org (Eric S. Johansson) Date: Thu, 10 Jul 2003 09:00:13 -0400 Subject: [albatross-users] Encrypting passwords in a session In-Reply-To: <3F0CBB66.7060102@harvee.org> References: <20030709175935.GA17731@demec.ufpe.br> <3F0CBB66.7060102@harvee.org> Message-ID: <3F0D635D.6070807@harvee.org> Eric S. Johansson wrote: > I'll think about > the class overnight and post suggestion in the morning. Simple_authenticated_application would need to additional arguments. First is the login screen URL, second is the lifetime of an authentication token. Default values should be available for both. It also seems that we wouldn't need much in the way of additional: logout_user(): invalidates login token for this user and removes token from HTML output stream. who_is_user(): yields username of user. (Note: Login process should also set remote_user environment variable) login_duration(): (would be nice) yields time since user login all of the checking for a valid login, redirection to login screen etc. would all happen invisibly to the user as part of the new class which means the application code really doesn't need to change. using the design for authentication tokens shown in section 4 of http://cookies.lcs.mit.edu/pubs/webauth:tr.pdf, we don't need to have any persistent server side session state if we're willing to accept some of the trade-offs (i.e. difficulty in terminating authentication authorization before expiration) make sense? ---eric From esj at harvee.org Thu Jul 10 20:31:16 2003 From: esj at harvee.org (Eric S. Johansson) Date: Thu, 10 Jul 2003 16:31:16 -0400 Subject: [albatross-users] HTML editors Message-ID: <3F0DCD14.5090906@harvee.org> are there any good HTML editors that can be expanded to include albatross tags (and any sub tags). I normally use something like Mozilla composer or amaya to create the rough HTML outline that I need. Then I go and hack it to bloody bits in Emacs and I'm almost at the cusp of creating albatross specific macros in my speech recognition environment but I figured I should ask before working hard. ---eric From matt at pollenation.net Thu Jul 10 23:02:23 2003 From: matt at pollenation.net (Matt Goodall) Date: 11 Jul 2003 00:02:23 +0100 Subject: [albatross-users] Problem with al-httpd and the httpd module In-Reply-To: <20030710222658.GA1841@rantac.com> References: <1057536370.26410.86.camel@localhost> <20030707055136.254283C332@coffee.object-craft.com.au> <3F093220.6090502@pollenation.net> <20030710222658.GA1841@rantac.com> Message-ID: <1057878142.8421.86.camel@localhost> On Thu, 2003-07-10 at 23:26, Osvaldo Santana Neto wrote: > On Mon, Jul 07, 2003 at 09:41:04AM +0100, Matt Goodall wrote: > > Andrew McNamara wrote: > > > > >>As soon as I start using the standalone http server for something useful > > >>I come across a problem :-(. There is currently no way to serve static > > >>resources, i.e. images, as the server assumes that *everything* will be > > >>a request for a page. > > >> > > >> > > > > > >The obvious solution is to add support for serving static content (files) > > >from a specified directory. > > > > > Yes, that would work for me as I tend to store all images, stylesheets, > > etc under a single root directory called assets. I'll see what I can > > cope up with for the httpdapp module and al-httpd script. > > > > Thanks, Matt > > I've the same problem. How did you resolved this problem? Sorry, but I haven't had the chance to do anything with it yet. Dave Cole has since added some code that could also help. See his post, http://www.object-craft.com.au/pipermail/albatross-users/2003-July/000682.html. I was wondering about using this to provide a "page" to serve the static content. The get_page_from_url() is not in 1.10pre2 but I guess it will not be too long before another release. - Matt -- Matt Goodall, Pollenation Internet Ltd w: http://www.pollenation.net e: matt@pollenation.net From osvaldo at rantac.com Thu Jul 10 22:26:58 2003 From: osvaldo at rantac.com (Osvaldo Santana Neto) Date: Thu, 10 Jul 2003 19:26:58 -0300 Subject: [albatross-users] Problem with al-httpd and the httpd module In-Reply-To: <3F093220.6090502@pollenation.net> References: <1057536370.26410.86.camel@localhost> <20030707055136.254283C332@coffee.object-craft.com.au> <3F093220.6090502@pollenation.net> Message-ID: <20030710222658.GA1841@rantac.com> On Mon, Jul 07, 2003 at 09:41:04AM +0100, Matt Goodall wrote: > Andrew McNamara wrote: > > >>As soon as I start using the standalone http server for something useful > >>I come across a problem :-(. There is currently no way to serve static > >>resources, i.e. images, as the server assumes that *everything* will be > >>a request for a page. > >> > >> > > > >The obvious solution is to add support for serving static content (files) > >from a specified directory. > > > Yes, that would work for me as I tend to store all images, stylesheets, > etc under a single root directory called assets. I'll see what I can > cope up with for the httpdapp module and al-httpd script. > > Thanks, Matt I've the same problem. How did you resolved this problem? -- Osvaldo Santana Neto osvaldo@rantac.com - ICQ: 11287184 From sheila at thinkspot.net Fri Jul 11 07:38:57 2003 From: sheila at thinkspot.net (Sheila King) Date: Fri, 11 Jul 2003 00:38:57 -0700 Subject: [albatross-users] Writing Headers Message-ID: <144878163.1057883937@SHEILA-LAPTOP> OK, I'm sufficiently confused about the new method of handling headers to remark upon it. In the application that I am working on (which I started with Albatross 1.01), I needed to send custom headers of my own. Since header handling has changed in 1.10, I need to fix my app. But I'm going over the new documentation and getting a bit confused. (P.S. you need to fix the copyright date in a lot of your files...as it is only copyright 2001.) Anyhow, I'm trying to fix this up, and the documentation seems to have some flaws/omissions or something. In section 7 (documentation for Mixins) http://object-craft.com.au/projects/albatross/albatross/mixin-ref.html there is no mention of the new ResponseMixin (this is a new Mixin class, right?) Also, when I try to look up in the documentation index the "write_headers()" method, I go to "w" and http://object-craft.com.au/projects/albatross/albatross/genindex.html #letter-w the "write_headers" method is listed there, but it is listed for all the AppContexts from which it was removed? But it is not listed for the new ResponseMixin class. When I search the new .pdf document for "set_header" it only appears in the schematic diagrams for the pre-rolled classes (Chapter 8) Same with "write_header" except for one mention in Chapter 5 for the Fake Application harness. Otherwise only mentioned in the schematic diagrams of Chapter 8. I sure would like to see some examples of setting headers so I would have a better idea how I ought to use this. At least, what I mean is, the documentation would be more complete with such an example. I'm sure I will figure it out eventually by reviewing the source code and experimenting, but it would be nicer if I didn't have to. Anyhow, I will put this off until tomorrow. Am too tired to mess with it any more right now. Good night, -- Sheila King http://www.thinkspot.net/sheila/ http://www.k12groups.org From matt at pollenation.net Fri Jul 11 09:03:16 2003 From: matt at pollenation.net (Matt Goodall) Date: Fri, 11 Jul 2003 10:03:16 +0100 Subject: [albatross-users] Writing Headers In-Reply-To: <144878163.1057883937@SHEILA-LAPTOP> References: <144878163.1057883937@SHEILA-LAPTOP> Message-ID: <3F0E7D54.9020006@pollenation.net> You are right, this stuff is handled by the ResponseMixin which is included by the AppContext class so it should be there for all of the standard context classes. Since there is no documentation for this at the moment you are best off looking at the code for more detail, it is in app.py and is very simple. As it happens I played around with this just the other day. I probably don't understand it all but I have written a "page" that sends an image back to the browser which will probably get you going. def page_display(ctx): f = None try: f = file('/home/matt/public_html/test/assets/images/%s' % ctx.locals.file) img_data = f.read() finally: if f: f.close() ctx.set_header('content-type', 'image/png') ctx.send_content(img_data) The above code is only an experiment but it should demonstrate the basics. Obviously, if you are returning non-HTML then you will need to set the "content-type" to the correct MIME type, not hard code it like I did (have a look at the mimetypes module). If you are returning HTML and just need to set your own headers then I suspect you only need to call ctx.set_header() and leave the rest to Albatross, i.e. def page_display(ctx): ctx.set_header('blah-blah', '123') ctx.run_template('something.html') You don't seem to need to worry about calling write_headers(), it's presumably handled for you by the context and request adapter. Hope this helps. Cheers, Matt Sheila King wrote: > OK, I'm sufficiently confused about the new method of handling headers > to remark upon it. > > In the application that I am working on (which I started with > Albatross 1.01), I needed to send custom headers of my own. Since > header handling has changed in 1.10, I need to fix my app. > > But I'm going over the new documentation and getting a bit confused. > > (P.S. you need to fix the copyright date in a lot of your files...as > it is only copyright 2001.) > > Anyhow, I'm trying to fix this up, and the documentation seems to have > some flaws/omissions or something. > > In section 7 (documentation for Mixins) > http://object-craft.com.au/projects/albatross/albatross/mixin-ref.html > > there is no mention of the new ResponseMixin (this is a new Mixin > class, right?) > Also, when I try to look up in the documentation index the > "write_headers()" method, I go to "w" and > http://object-craft.com.au/projects/albatross/albatross/genindex.html > #letter-w > > the "write_headers" method is listed there, but it is listed for all > the AppContexts from which it was removed? But it is not listed for > the new ResponseMixin class. > > When I search the new .pdf document for "set_header" it only appears > in the schematic diagrams for the pre-rolled classes (Chapter 8) > > Same with "write_header" except for one mention in Chapter 5 for the > Fake Application harness. Otherwise only mentioned in the schematic > diagrams of Chapter 8. > > I sure would like to see some examples of setting headers so I would > have a better idea how I ought to use this. At least, what I mean is, > the documentation would be more complete with such an example. I'm > sure I will figure it out eventually by reviewing the source code and > experimenting, but it would be nicer if I didn't have to. > > Anyhow, I will put this off until tomorrow. Am too tired to mess with > it any more right now. > > Good night, > -- Matt Goodall, Pollenation Internet Ltd w: http://www.pollenationinternet.com e: matt@pollenationinternet.com t: +44 (0)113 2252500 From matt at pollenation.net Fri Jul 11 14:07:26 2003 From: matt at pollenation.net (Matt Goodall) Date: Fri, 11 Jul 2003 15:07:26 +0100 Subject: [albatross-users] [Fwd: Welcome to the "Pyweb" mailing list] Message-ID: <3F0EC49E.2000208@pollenation.net> Just in case you don't subscribe to the comp.lang.python.announce newsgroup ... - Matt -------- Original Message -------- Subject: Welcome to the "Pyweb" mailing list Date: Fri, 11 Jul 2003 09:52:57 -0400 From: pyweb-request@amk.ca To: matt@pollenation.net Welcome to the Pyweb@amk.ca mailing list! To post to this list, send your email to: pyweb@amk.ca General information about the mailing list is at: http://www.amk.ca/mailman/listinfo/pyweb If you ever want to unsubscribe or change your options (eg, switch to or from digest mode, change your password, etc.), visit your subscription page at: http://www.amk.ca/mailman/options/pyweb/matt%40pollenation.net You can also make such adjustments via email by sending a message to: Pyweb-request@amk.ca with the word `help' in the subject or body (don't include the quotes), and you will get back a message with instructions. You must know your password to change your options (including changing the password, itself) or to unsubscribe. It is: mu5hr00m Normally, Mailman will remind you of your amk.ca mailing list passwords once every month, although you can disable this if you prefer. This reminder will also include instructions on how to unsubscribe or change your account options. There is also a button on your options page that will email your current password to you. -- Matt Goodall, Pollenation Internet Ltd w: http://www.pollenationinternet.com e: matt@pollenationinternet.com t: +44 (0)113 2252500 From matt at pollenation.net Fri Jul 11 14:10:52 2003 From: matt at pollenation.net (Matt Goodall) Date: Fri, 11 Jul 2003 15:10:52 +0100 Subject: [albatross-users] [Fwd: Welcome to the "Pyweb" mailing list] In-Reply-To: <3F0EC49E.2000208@pollenation.net> References: <3F0EC49E.2000208@pollenation.net> Message-ID: <3F0EC56C.3060104@pollenation.net> Jeez, I don't believe I just did that, I think I'm losing it! I'll just pop off to change my password and then I'll send the correct link. - Matt From matt at pollenationinternet.com Fri Jul 11 14:13:40 2003 From: matt at pollenationinternet.com (Matt Goodall) Date: Fri, 11 Jul 2003 15:13:40 +0100 Subject: [albatross-users] [Fwd: Mailing list for Web framework discussion] Message-ID: <3F0EC614.90703@pollenationinternet.com> Just in case you don't subscribe to the comp.lang.python.announce newsgroup ... - Matt -------- Original Message -------- Subject: Mailing list for Web framework discussion Date: Fri, 11 Jul 2003 08:46:20 -0400 From: A.M. Kuchling Organization: None Newsgroups: comp.lang.python.announce I've created a mailing list called pyweb for discussion of Python Web frameworks. The initial topic of the list will likely be a discussion of what to use as an example web application, continuing the current python-list thread. It's a Mailman list, so just point your web browser at: http://www.amk.ca/mailman/listinfo/pyweb/ and follow the usual steps. --amk From djc at object-craft.com.au Sat Jul 12 03:16:45 2003 From: djc at object-craft.com.au (Dave Cole) Date: 12 Jul 2003 13:16:45 +1000 Subject: [albatross-users] Writing Headers In-Reply-To: <3F0E7D54.9020006@pollenation.net> References: <144878163.1057883937@SHEILA-LAPTOP> <3F0E7D54.9020006@pollenation.net> Message-ID: >>>>> "Matt" == Matt Goodall writes: Matt> You are right, this stuff is handled by the ResponseMixin which Matt> is included by the AppContext class so it should be there for Matt> all of the standard context classes. Since there is no Matt> documentation for this at the moment you are best off looking at Matt> the code for more detail, it is in app.py and is very simple. Ooops - I completely forgot about documenting ResponseMixin. I will do that today. The ResponseMixin was introduced to simplify the process of sending different types of content to the browser. Matt is 100% on the money with his examples. Matt> def page_display(ctx): Matt> f = None Matt> try: Matt> f = file('/home/matt/public_html/test/assets/images/%s' % Matt> ctx.locals.file) Matt> img_data = f.read() Matt> finally: Matt> if f: Matt> f.close() Matt> ctx.set_header('content-type', 'image/png') Matt> ctx.send_content(img_data) Matt> The above code is only an experiment but it should demonstrate Matt> the basics. It is more than an experiment. It is a perfect example of how to manipulate the headers. One subtle thing we did in relation to this was to make sure that the session is saved before the output is flushed to the browser. This allows you to do things like include non-inline dynamically generated images inside pages served to the browser. Matt> If you are returning HTML and just need to set your own headers Matt> then I suspect you only need to call ctx.set_header() and leave Matt> the rest to Albatross, i.e. Matt> Matt> def page_display(ctx): Matt> ctx.set_header('blah-blah', '123') Matt> ctx.run_template('something.html') Matt> Matt> You don't seem to need to worry about calling write_headers(), it's Matt> presumably handled for you by the context and request adapter. Yes. Excellent summary. - Dave -- http://www.object-craft.com.au From djc at object-craft.com.au Sat Jul 12 03:18:51 2003 From: djc at object-craft.com.au (Dave Cole) Date: 12 Jul 2003 13:18:51 +1000 Subject: [albatross-users] Problem with al-httpd and the httpd module In-Reply-To: <1057878142.8421.86.camel@localhost> References: <1057536370.26410.86.camel@localhost> <20030707055136.254283C332@coffee.object-craft.com.au> <3F093220.6090502@pollenation.net> <20030710222658.GA1841@rantac.com> <1057878142.8421.86.camel@localhost> Message-ID: >>>>> "Matt" == Matt Goodall writes: Matt> Dave Cole has since added some code that could also help. See Matt> his post, Matt> http://www.object-craft.com.au/pipermail/albatross-users/2003-July/000682.html. I Matt> was wondering about using this to provide a "page" to serve the Matt> static content. The get_page_from_url() is not in 1.10pre2 but I Matt> guess it will not be too long before another release. I am going to try to get a pre3 release out this weekend. - Dave -- http://www.object-craft.com.au From djc at object-craft.com.au Sat Jul 12 03:25:23 2003 From: djc at object-craft.com.au (Dave Cole) Date: 12 Jul 2003 13:25:23 +1000 Subject: [albatross-users] HTML editors In-Reply-To: <3F0DCD14.5090906@harvee.org> References: <3F0DCD14.5090906@harvee.org> Message-ID: >>>>> "Eric" == Eric S Johansson writes: Eric> are there any good HTML editors that can be expanded to include Eric> albatross tags (and any sub tags). I just installed the latest version of bluefish to see if it was better than the releases I tried around a year ago. They seem to have made some real progress. http://bluefish.openoffice.nl/ Eric> I normally use something like Mozilla composer or amaya to Eric> create the rough HTML outline that I need. Then I go and hack Eric> it to bloody bits in Emacs and I'm almost at the cusp of Eric> creating albatross specific macros in my speech recognition Eric> environment but I figured I should ask before working hard. Have a look at bluefish. - Dave -- http://www.object-craft.com.au From djc at object-craft.com.au Sat Jul 12 03:45:44 2003 From: djc at object-craft.com.au (Dave Cole) Date: 12 Jul 2003 13:45:44 +1000 Subject: [albatross-users] Encrypting passwords in a session In-Reply-To: <3F0D635D.6070807@harvee.org> References: <20030709175935.GA17731@demec.ufpe.br> <3F0CBB66.7060102@harvee.org> <3F0D635D.6070807@harvee.org> Message-ID: >>>>> "Eric" == Eric S Johansson writes: Eric> Eric S. Johansson wrote: >> I'll think about the class overnight and post suggestion in the >> morning. That would be good. Eric> Simple_authenticated_application would need to additional Eric> arguments. First is the login screen URL, second is the Eric> lifetime of an authentication token. Default values should be Eric> available for both. Eric> It also seems that we wouldn't need much in the way of Eric> additional: Eric> logout_user(): invalidates login token for this user and removes Eric> token from HTML output stream. who_is_user(): yields username Eric> of user. (Note: Login process should also set remote_user Eric> environment variable) login_duration(): (would be nice) yields Eric> time since user login Eric> all of the checking for a valid login, redirection to login Eric> screen etc. would all happen invisibly to the user as part of Eric> the new class which means the application code really doesn't Eric> need to change. I am looking forward to seeing the sample. Adding something like this to the documentation would be a very good thing. Eric> using the design for authentication tokens shown in section 4 of Eric> http://cookies.lcs.mit.edu/pubs/webauth:tr.pdf, we don't need to Eric> have any persistent server side session state if we're willing Eric> to accept some of the trade-offs (i.e. difficulty in terminating Eric> authentication authorization before expiration) Thanks for the URL. I have some more reading to do... - Dave -- http://www.object-craft.com.au From djc at object-craft.com.au Sat Jul 12 03:58:13 2003 From: djc at object-craft.com.au (Dave Cole) Date: 12 Jul 2003 13:58:13 +1000 Subject: base_url discovery (was Re: [albatross-users] Upgrade problems to albatross 1.10pre2) In-Reply-To: <1057767195.28628.311.camel@localhost> References: <312402881.1057700475@SHEILA-LAPTOP> <20030709051621.9388C3C024@coffee.object-craft.com.au> <315999543.1057704071@SHEILA-LAPTOP> <20030709060347.283353C024@coffee.object-craft.com.au> <1057767195.28628.311.camel@localhost> Message-ID: >>>>> "Matt" == Matt Goodall writes: Matt> On Wed, 2003-07-09 at 14:04, Dave Cole wrote: >> I have been wondering if it is possible for the application to >> discover the base_url from the web server. It certainly is using >> CGI, so probably is with FastCGI too, Matt> As you pointed out, neither of these should be a problem. >> but I am not so sure about mod_python. Matt> The problem with this is the one I hit the other day when using Matt> mod_rewrite. The uri that Albatross sees is the rewritten uri Matt> which can be completely different to what is typed into the Matt> browser url bar. That probably means that it will be very hard to remove base_url. Into the too hard basket. Matt> Having said that, mod_python has req.the_request which is the Matt> http request header, i.e. 'GET /~matt/simple/app.py/1/2/3 Matt> HTTP/1.1'. We may be able to make use of that but I haven't Matt> looked into it anymore. >> I am certain the BaseHTTPServer cannot supply enough information. Matt> No, but it probably doesn't need to as the application is always Matt> mounted at '/'. True. - Dave -- http://www.object-craft.com.au From esj at harvee.org Sat Jul 12 04:01:46 2003 From: esj at harvee.org (Eric S. Johansson) Date: Sat, 12 Jul 2003 00:01:46 -0400 Subject: [albatross-users] HTML editors In-Reply-To: References: <3F0DCD14.5090906@harvee.org> Message-ID: <3F0F882A.9010308@harvee.org> Dave Cole wrote: >>>>>>"Eric" == Eric S Johansson writes: > > > Eric> are there any good HTML editors that can be expanded to include > Eric> albatross tags (and any sub tags). > > I just installed the latest version of bluefish to see if it was > better than the releases I tried around a year ago. They seem to have > made some real progress. > > http://bluefish.openoffice.nl/ > I know about bluefish and have tried the 0.9 version that came with Red Hat 8 and I'm quite aware of its improvements. they still don't do syntax highlighting correctly (just use don't in the body of your text). I also haven't figured out how to add albatross tags. I will dig further. ---eric From djc at object-craft.com.au Sat Jul 12 04:08:04 2003 From: djc at object-craft.com.au (Dave Cole) Date: 12 Jul 2003 14:08:04 +1000 Subject: [albatross-users] Change to httpdapp module In-Reply-To: <3F09A054.4090004@pollenation.net> References: <3F09A054.4090004@pollenation.net> Message-ID: Matt> In httpdapp, Request.get_uri() currently returns an entire URL Matt> including server, port etc. I think it should be just returning Matt> the path as follows, but please check I'm not being daft first: Matt> Matt> def get_uri(self): Matt> return self._req.path I think the above is the correct thing to return. I will change the module. - Dave -- http://www.object-craft.com.au From djc at object-craft.com.au Sat Jul 12 04:42:59 2003 From: djc at object-craft.com.au (Dave Cole) Date: 12 Jul 2003 14:42:59 +1000 Subject: [albatross-users] [patch] get_uri -> get_path_info changes In-Reply-To: <1057743848.28628.75.camel@localhost> References: <3F0AF957.6050402@pollenation.net> <1057743848.28628.75.camel@localhost> Message-ID: >>>>> "Matt" == Matt Goodall writes: Matt> In light of the problem Sheila found, below are some comments on Matt> the patches. Matt> On Tue, 2003-07-08 at 18:03, Matt Goodall wrote: >> 01.base_url.patch - a patch to fix my previous patch. Already >> applied by Dave I think. Matt> This was clearly the wrong solution as the original base_url Matt> patch did not consider that the base_url might not be absolute. Now back to this in Application.__init__(): # Use a base_url of '/' if not provided if base_url: self.__base_url = base_url else: self.__base_url = '/' >> 03.httpdapp.patch - simplified version of Request.get_uri(). Matt> Not necessary but still an improvement. It's kind of irrelevant Matt> though as it doesn't work with the old base_url stuff. Applied (already said this in other email). >> 04.get_path_info.patch - introduces get_path_info() methods into >> the request adapters. Matt> Not much point with 05 but it may be useful anyway. Dave/Andrew, Matt> it's up to you. Applied. >> 05.use_path_info.patch - switch from using Request.get_uri() to >> Request.get_path_info(). This affects how the random page loader >> works and how the current and redirect urls are calculated. Matt> Completely breaks redirect_url when the base_url is not Matt> absolute. Do not apply. Not applied. - Dave -- http://www.object-craft.com.au From djc at object-craft.com.au Sat Jul 12 05:04:31 2003 From: djc at object-craft.com.au (Dave Cole) Date: 12 Jul 2003 15:04:31 +1000 Subject: [albatross-users] [patch] Another attempt at "fixing" base_url In-Reply-To: <1057760211.28628.269.camel@localhost> References: <1057760211.28628.269.camel@localhost> Message-ID: > Attached is another patch, against stock 1.10pre2, which attempts to > make the base_url + httpdapp combination work without breaking > everything else ;-). The pain that goes into a few lines of code. I am sorry that you have suffered so much. It really highlights a large shortcoming in the current code - comments. > This time, with the knowledge that a relative base_url is perfectly > valid, I have taken the approach of "fixing up" the base_url where > it is used to determine the page and build redirect urls. I hope > this approach is a little more successful than the previous one! I have been looking at the patch and think it can be simplified. See comments below. > diff -ru albatross-1.10pre2/albatross/app.py albatross-1.10pre2-matt/albatross/app.py > --- albatross-1.10pre2/albatross/app.py 2003-07-05 08:52:40.000000000 +0100 > +++ albatross-1.10pre2-matt/albatross/app.py 2003-07-09 15:11:13.000000000 +0100 > @@ -198,6 +198,9 @@ > def redirect_url(self, loc): > this_path = urlparse.urlparse(self.request.get_uri())[2] > base_path = urlparse.urlparse(self.app.base_url())[2] > + # If no base_path then the application is mounted at the root > + if not base_path: > + base_path = '/' > pos = this_path.find(base_path) > new_base = this_path[:pos + len(base_path)] > if new_base[-1] != '/': > @@ -221,11 +224,7 @@ > def __init__(self, base_url): > ResourceMixin.__init__(self) > self.register_tagclasses(*tags.tags) > - # Use a base_url of '/' if not provided > - if base_url: > - self.__base_url = base_url > - else: > - self.__base_url = '/' > + self.__base_url = base_url > > def run(self, req): > '''Process a single browser request If you leave the base_url code untouched in the Application constructor then there is no need for the change in redirect_url(). This means that we can leave this file unpatched. The effect of this non-change also changes the patch to randompage.py > diff -ru albatross-1.10pre2/albatross/randompage.py albatross-1.10pre2-matt/albatross/randompage.py > --- albatross-1.10pre2/albatross/randompage.py 2003-07-05 08:52:40.000000000 +0100 > +++ albatross-1.10pre2-matt/albatross/randompage.py 2003-07-09 13:14:32.000000000 +0100 > @@ -23,6 +23,12 @@ > try: > base_path = urlparse.urlparse(self.base_url())[2] > uri_path = urlparse.urlparse(uri)[2] > + # Fixup base_path to end with a '/' so that it can be used as > + # a root path. > + if not base_path: > + base_path = '/' > + elif base_path[-1] != '/': > + base_path = base_path + '/' > page = uri_path.split(base_path, 1)[1] > except IndexError: > pass The first check is no longer necessary if we do not change base_url logic in the Application constructor. This reduces the patch to this: try: base_path = urlparse.urlparse(self.base_url())[2] uri_path = urlparse.urlparse(uri)[2] + # Fixup base_path to end with a '/' so that it can be used as + # a root path. + if not base_path.endswith('/'): + base_path = base_path + '/' page = uri_path.split(base_path, 1)[1] except IndexError: pass Can you see any reason why this is not equivalent to your patch? Am I missing something else? - Dave -- http://www.object-craft.com.au From sheila at thinkspot.net Sat Jul 12 05:43:09 2003 From: sheila at thinkspot.net (Sheila King) Date: Fri, 11 Jul 2003 22:43:09 -0700 Subject: [albatross-users] Session Variables not saved Message-ID: <40971904.1057963389@SHEILA-LAPTOP> I am still having serious difficulties with my application since the upgrade to Albatross 1.10pre2. I am using RandomApp with Server side file sessions. I got past the problems with the base_url (thanks to tips from Dave) and I got past the header writing issues (I think). Thanks Matt. But now it appears that my session/authentication code is all fubar. The thing is, I finally figured out tonight, that even though I am (in my code) adding session vars to the session, they do not appear to be saved. I am working on making a stripped down example of my code to show this (as I cannot share the app itself) but wanted to toss this feeler out there, just in case it "rang a bell" for anyone. Once I get a stripped down example, I will post it to the list. I don't know if I will get it done within the next 1.5 hours. If not, I will be off to bed, and it will have to wait until late tomorrow. -- Sheila King http://www.thinkspot.net/sheila/ http://www.k12groups.org From djc at object-craft.com.au Sat Jul 12 07:06:50 2003 From: djc at object-craft.com.au (Dave Cole) Date: 12 Jul 2003 17:06:50 +1000 Subject: [albatross-users] Documented ResponseMixin class Message-ID: For the curious I have documented the ResponseMixin class. http://www.object-craft.com.au/~djc/albatross/mixin-response.html This will be included in the pre3 release that I hope to get out this weekend. The only outstanding task is to confirm my changes to Matt's latest base_url patch. - Dave -- http://www.object-craft.com.au From djc at object-craft.com.au Sat Jul 12 07:11:32 2003 From: djc at object-craft.com.au (Dave Cole) Date: 12 Jul 2003 17:11:32 +1000 Subject: [albatross-users] check boxes again. In-Reply-To: <1057450672.19240.37.camel@localhost> References: <200307040004.KAA08163@lightning.itga.com.au> <3F04C9C2.1020308@harvee.org> <1057450672.19240.37.camel@localhost> Message-ID: >>>>> "Matt" == Matt Goodall writes: Matt> On Fri, 2003-07-04 at 01:26, Eric S. Johansson wrote: >> Q: how do I get a complete list of all checkboxes checked and >> unchecked just like you can with ordinary CGI Matt> Are you sure CGI does this? As far as I was aware browsers only Matt> send a request parameter for a checkbox when it is checked. If Matt> the browser doesn't send a request parameter how can CGI even Matt> know there were unchecked checkboxes on the page? Perhaps the Matt> browser behaves differently when the form data is posted? The browser never sends checkbox fields that are not checked. That is one of the reasons for the NameRecorderMixin. It records all of the input fields in a form (in the __albstate__ hidden field) so that the request merging can do things like clear the value associated with an unchecked checkbox. - Dave -- http://www.object-craft.com.au From djc at object-craft.com.au Sat Jul 12 07:12:18 2003 From: djc at object-craft.com.au (Dave Cole) Date: 12 Jul 2003 17:12:18 +1000 Subject: [albatross-users] check boxes again. In-Reply-To: References: <200307040004.KAA08163@lightning.itga.com.au> <3F04C9C2.1020308@harvee.org> <1057450672.19240.37.camel@localhost> Message-ID: >>>>> "Dave" == Dave Cole writes: >>>>> "Matt" == Matt Goodall writes: Matt> On Fri, 2003-07-04 at 01:26, Eric S. Johansson wrote: >>> Q: how do I get a complete list of all checkboxes checked and >>> unchecked just like you can with ordinary CGI Matt> Are you sure CGI does this? As far as I was aware browsers only Matt> send a request parameter for a checkbox when it is checked. If Matt> the browser doesn't send a request parameter how can CGI even Matt> know there were unchecked checkboxes on the page? Perhaps the Matt> browser behaves differently when the form data is posted? Dave> The browser never sends checkbox fields that are not checked. Dave> That is one of the reasons for the NameRecorderMixin. It Dave> records all of the input fields in a form (in the __albstate__ ^^^^^^^^^^^^ Ooops, make that the __albform__ field. - Dave -- http://www.object-craft.com.au From sheila at thinkspot.net Sat Jul 12 08:21:52 2003 From: sheila at thinkspot.net (Sheila King) Date: Sat, 12 Jul 2003 01:21:52 -0700 Subject: [albatross-users] Session Variables not saved In-Reply-To: <40971904.1057963389@SHEILA-LAPTOP> References: <40971904.1057963389@SHEILA-LAPTOP> Message-ID: <50495048.1057972912@SHEILA-LAPTOP> --On Friday, July 11, 2003 10:43 PM -0700 Sheila King wrote: > I am still having serious difficulties with my application since > the upgrade to Albatross 1.10pre2. > > I am using RandomApp with Server side file sessions. [snip] > > But now it appears that my session/authentication code is all fubar. > > The thing is, I finally figured out tonight, that even though I am > (in my code) adding session vars to the session, they do not appear > to be saved. > > I am working on making a stripped down example of my code to show > this ... OK, here is the stripped down example. It's ugly, but I think demonstrates my point... Code is available here: http://www.mathxy.com/temp/ The .zip file contains all the files without the .txt extensions (if you want the whole thing to run for yourself) Working example is available here: http://mathxy.com/cgi-bin/test/mgr.py account number = 123456 email = test@example.com passwd = test1234 All of the local variables and session vars are displayed to the page. What is so weird is that the session vars do contain _last_access _authstatus as session variables when the login page is first displayed But then when you log in and go to the expired page (which is an error...it should take you to the Main Account page, but this doesn't work right...is my problem I'm trying to solve...) Notice that the _last_access and _authstatus are no longer session variables. And what is weird is that there is no place in the code where I am removing the session or deleting any session variables. So how did those variables get removed from the session? I believe that the reason my authentication code no longer works, is because the _last_access variable is no longer stored in the session. If I'm doing something stupid here, OK...but I don't think so. This code (or something darn similar to it) worked fine with the last version of Albatross. I am beating my head against a wall here to figure out why. One thing that I thought was possible, is that it is happening in the "redirect" as I know that the account gets validated long enough to go into the main.py file but when it rechecks for validation there, it fails and redirects to the expired page. Basic process is: mgr.py <-- main application login.py <-- start page module line 15 of login.py is apparently successfully authenticating the account line 20 in login.py is redirecting to main.py line 5 of main.py is determining that the authentication is not valid line 6 of main.py is redirecting to expired.py That's what's happening now. Authentication check should *not* be failing in main.py line 5. :\ -- Sheila King http://www.thinkspot.net/sheila/ http://www.k12groups.org From matt at pollenation.net Sat Jul 12 10:24:29 2003 From: matt at pollenation.net (Matt Goodall) Date: 12 Jul 2003 11:24:29 +0100 Subject: [albatross-users] [patch] Another attempt at "fixing" base_url In-Reply-To: References: <1057760211.28628.269.camel@localhost> Message-ID: <1058005469.22647.62.camel@localhost> On Sat, 2003-07-12 at 06:04, Dave Cole wrote: > > Attached is another patch, against stock 1.10pre2, which attempts to > > make the base_url + httpdapp combination work without breaking > > everything else ;-). Dave's simplified versions of my patches. > Can you see any reason why this is not equivalent to your patch? Am I > missing something else? Seems ok to me although the whole patches to patches thing is a little hard to follow ;-). I'm finding it difficult to picture exactly what's in your source code right now. I have applied the changes to 1.10pre2 that I think you have applied here and in your recent messages to the list and it seems to be working ok. Cheers, Matt -- Matt Goodall, Pollenation Internet Ltd w: http://www.pollenation.net e: matt@pollenation.net From matt at pollenation.net Sat Jul 12 10:59:52 2003 From: matt at pollenation.net (Matt Goodall) Date: 12 Jul 2003 11:59:52 +0100 Subject: [albatross-users] [patch] Another attempt at "fixing" base_url In-Reply-To: References: <1057760211.28628.269.camel@localhost> Message-ID: <1058007592.5901.115.camel@localhost> On Sat, 2003-07-12 at 06:04, Dave Cole wrote: > > Attached is another patch, against stock 1.10pre2, which attempts to > > make the base_url + httpdapp combination work without breaking > > everything else ;-). > > The pain that goes into a few lines of code. I am sorry that you have > suffered so much. Hey, no problem. It was my choice to contribute to the project. I thought Albatross looked really useful but saw a couple of "gaps" that I needed to fill, mostly for my own use. In this case, I didn't consider one of the possibilities for base_url so didn't test things fully. Besides, we're not in the open source thing for an easy ride, it's about community, creating great software (generally better than the commercial offerings) and seeing others make use and benefit from the code. The positive comments about my small contributions to the project are more than enough payback. /matt steps down from his soapbox ;-) > It really highlights a large shortcoming in the > current code - comments. Yes, a few more comments in the important places would be useful (redirect_url is probably a good example) but unit tests are probably more important. Obviously, there's the interaction with the web server to take into account too which is often not easy to test. Having said that, I now have a suite of simple test applications using some (six, so far) of the standard application classes, each running as cgi, fcgi etc. I'm running through these apps manually at the moment (very tedious!) but if I can script up that you are welcome to suck the suite into Albatross as a final set of tests. Cheers, Matt -- Matt Goodall, Pollenation Internet Ltd w: http://www.pollenation.net e: matt@pollenation.net From matt at pollenation.net Sat Jul 12 21:26:01 2003 From: matt at pollenation.net (Matt Goodall) Date: 12 Jul 2003 22:26:01 +0100 Subject: [albatross-users] Session Variables not saved In-Reply-To: <50495048.1057972912@SHEILA-LAPTOP> References: <40971904.1057963389@SHEILA-LAPTOP> <50495048.1057972912@SHEILA-LAPTOP> Message-ID: <1058045161.15822.129.camel@localhost> On Sat, 2003-07-12 at 09:21, Sheila King wrote: > --On Friday, July 11, 2003 10:43 PM -0700 Sheila King > wrote: > > > I am still having serious difficulties with my application since > > the upgrade to Albatross 1.10pre2. I just spent a few minutes stepping through the code debugging this, I'm getting the same here too. The problem is that on redirect only the 'Location' and 'Status' headers are being sent to the browser. The critical one that is missing is 'Set-Cookie', i.e. the browser is never told what its session id is! This appears to affect all the request adapters. I'm also fairly sure that I didn't break it this time ;-). Hope this helps. Cheers, Matt p.s. if anyone needs a recommendation for a Python debugger then wingide works really well. -- Matt Goodall, Pollenation Internet Ltd w: http://www.pollenation.net e: matt@pollenation.net From sheila at thinkspot.net Sat Jul 12 22:22:09 2003 From: sheila at thinkspot.net (Sheila King) Date: Sat, 12 Jul 2003 15:22:09 -0700 Subject: [albatross-users] Session Variables not saved In-Reply-To: <1058045161.15822.129.camel@localhost> References: <40971904.1057963389@SHEILA-LAPTOP> <50495048.1057972912@SHEILA-LAPTOP> <1058045161.15822.129.camel@localhost> Message-ID: <344633526.1058023329@goddess> --On Saturday, July 12, 2003 10:26 PM +0100 Matt Goodall wrote: > On Sat, 2003-07-12 at 09:21, Sheila King wrote: >> --On Friday, July 11, 2003 10:43 PM -0700 Sheila King >> wrote: >> >> > I am still having serious difficulties with my application since >> > the upgrade to Albatross 1.10pre2. > The problem is that on redirect only the 'Location' and 'Status' headers > are being sent to the browser. The critical one that is missing is > 'Set-Cookie', i.e. the browser is never told what its session id is! Thank you SO much for that sanity check. Although I did look at the redirect code for the cgiapp Request class, I didn't see what the problem was. Grrr. I *should* have though, as I had worked with that code closely before. Guess I was too tired and was just trying to figure out exactly where the error was occurring. Have already spent more than a full day on this issue alone. :(( Thank goodness for your post. I was about to crank up and make an even more stripped down version. -- Sheila King http://www.thinkspot.net/sheila/ http://www.k12groups.org From djc at object-craft.com.au Sun Jul 13 02:32:52 2003 From: djc at object-craft.com.au (Dave Cole) Date: 13 Jul 2003 12:32:52 +1000 Subject: [albatross-users] [patch] Another attempt at "fixing" base_url In-Reply-To: <1058007592.5901.115.camel@localhost> References: <1057760211.28628.269.camel@localhost> <1058007592.5901.115.camel@localhost> Message-ID: >>>>> "Matt" == Matt Goodall writes: Matt> Hey, no problem. It was my choice to contribute to the Matt> project. I thought Albatross looked really useful but saw a Matt> couple of "gaps" that I needed to fill, mostly for my own Matt> use. In this case, I didn't consider one of the possibilities Matt> for base_url so didn't test things fully. Testing is a hard job. Matt> Besides, we're not in the open source thing for an easy ride, Matt> it's about community, creating great software (generally better Matt> than the commercial offerings) and seeing others make use and Matt> benefit from the code. The positive comments about my small Matt> contributions to the project are more than enough payback. It is a big help. You see things differently to us in some ways. This tests our assumptions and makes the code better. Matt> Yes, a few more comments in the important places would be useful Matt> (redirect_url is probably a good example) but unit tests are Matt> probably more important. In a way we are always playing catchup with documentation. Comments are something that I should start to work on too. Matt> Obviously, there's the interaction with the web server to take Matt> into account too which is often not easy to test. Having said Matt> that, I now have a suite of simple test applications using some Matt> (six, so far) of the standard application classes, each running Matt> as cgi, fcgi etc. I'm running through these apps manually at the Matt> moment (very tedious!) but if I can script up that you are Matt> welcome to suck the suite into Albatross as a final set of Matt> tests. That would be excellent. - Dave -- http://www.object-craft.com.au From djc at object-craft.com.au Sun Jul 13 02:35:19 2003 From: djc at object-craft.com.au (Dave Cole) Date: 13 Jul 2003 12:35:19 +1000 Subject: [albatross-users] Session Variables not saved In-Reply-To: <344633526.1058023329@goddess> References: <40971904.1057963389@SHEILA-LAPTOP> <50495048.1057972912@SHEILA-LAPTOP> <1058045161.15822.129.camel@localhost> <344633526.1058023329@goddess> Message-ID: >>>>> "Sheila" == Sheila King writes: >> The problem is that on redirect only the 'Location' and 'Status' >> headers are being sent to the browser. The critical one that is >> missing is 'Set-Cookie', i.e. the browser is never told what its >> session id is! Sheila> Thank you SO much for that sanity check. I looked at the code and could not see anything you were doing wrong - I assumed I was just missing something. Turned out it was Albatross doing something wrong - thanks again Matt. I am just in the process of packaging up a pre3 release. This is hopefully the last one. Sheila> Although I did look at the redirect code for the cgiapp Sheila> Request class, I didn't see what the problem was. Grrr. I Sheila> *should* have though, as I had worked with that code closely Sheila> before. Guess I was too tired and was just trying to figure Sheila> out exactly where the error was occurring. Have already spent Sheila> more than a full day on this issue alone. :(( Ouch. Sorry about that. - Dave -- http://www.object-craft.com.au From djc at object-craft.com.au Sun Jul 13 02:55:40 2003 From: djc at object-craft.com.au (Dave Cole) Date: 13 Jul 2003 12:55:40 +1000 Subject: [albatross-users] Albatross 1.10 pre3 released In-Reply-To: References: Message-ID: I have just packaged up the 1.10pre3 release of Albatross. This resolves the problems encountered in the 1.10pre2 release. The changes since 1.10pre2 are: * Request classes now have a get_path_info() method. * Redirect now sends the session id cookie when it is defined. The logic has been moved into ResponseMixin.redirect(). * SessionBase now has a session_vars() method that returns a list of the names in the session. * Random page URI handling is back to 1.10pre1 state. The base_path used to split the requested URI will always end with '/'. * Random page URI cracking has been moved into the get_page_from_uri() method. This allows application to redefine the cracking method. * More documentation updates - especially in the prepackaged classes chapter. * Most samples have been changed to allow them to be run using the al-httpd program. There still is no documentation of the FastCGI and Standalone BaseHTTPServer support. The pre2 was supposed to be the last pre release of 1.10. This time for sure... If there are no issues reported with this one we will release the real 1.10 by the end of the week. - Dave -- http://www.object-craft.com.au From esj at harvee.org Sun Jul 13 04:48:58 2003 From: esj at harvee.org (Eric S. Johansson) Date: Sun, 13 Jul 2003 00:48:58 -0400 Subject: [albatross-users] crafting get arg urls Message-ID: <3F10E4BA.90802@harvee.org> I'm hitting another cognitive brick wall. It's probably because I'm up too late but here is what's messing with my head. Need to create a get style URL for the spamtrap entry display. was using a single argument and manually generated the anchor record just fine. Tried adding an argument and things got confused with the & and all. here's what I'm generating for albatross: here is what I'm getting: what I wanted: now I'm probably missing an exec somewhere and if I need to grope around, I'll figure it out sooner or later. The real problem is getting clarity on quoting mixed in with variable execution. I realize as I'm working on these problems that I don't know or can't find easily a simple statement on how to retrieve values and substitute them into strings simply and easily as the case above demonstrates. it's a real simple thing and common to virtually every aspect of albatross. The answer to this problem will probably occurred to me in the morning but for now, it's irritating the hell out of me. ---eric From sheila at thinkspot.net Sun Jul 13 05:57:48 2003 From: sheila at thinkspot.net (Sheila King) Date: Sat, 12 Jul 2003 22:57:48 -0700 Subject: [albatross-users] Redirect problems continue... Message-ID: <9733165.1058050668@SHEILA-LAPTOP> OK, thanks for the really quick release of patches for the issues with redirect and not saving the cookie etc... I've installed the pre3 release and tried again with the stripped down application code I shared last night. As a reminder, code is available here: http://mathxy.com/temp/ Unfortunately, the code, when I attempt to run it, now generates a 500 Internal Server error. Here is the error entry from the logs: %% [Sun Jul 13 01:37:59 2003] GET /cgi-bin/test/mgr.py HTTP/1.1 %% 500 /big/dom/xexample/cgi-bin/test/mgr.py %request Accept: application/x-shockwave-flash,text/xml,application/xml,application/xhtml+xm l,text/html;q=0.9,text/pl ain;q=0.8,video/x-mng,image/png,image/jpeg,image/gif;q=0.2,*/*;q=0.1 Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7 Accept-Encoding: gzip,deflate,compress;q=0.9 Accept-Language: en-us,en;q=0.5 Cache-Control: max-age=0 Connection: keep-alive Host: example.com Keep-Alive: 300 User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.3) Gecko/20030312 %response %stderr Traceback (most recent call last): File "mgr.py", line 60, in ? app.run(qaRequest()) File "/big/dom/xexample/lib/python2.2/site-packages/albatross/app.py", line 253, in run return ctx.redirect(e.loc) File "/big/dom/xexample/lib/python2.2/site-packages/albatross/app.py", line 217, in redirect raise Redirect(loc) albatross.app.Redirect: I'm looking at the app.py file, and I don't see what the problem is. The code from app.py involved in raising the redirect exception appears to me to be unchanged between 1.01 and 1.10pre3. ??? -- Sheila King http://www.thinkspot.net/sheila/ http://www.k12groups.org From djc at object-craft.com.au Sun Jul 13 06:08:23 2003 From: djc at object-craft.com.au (Dave Cole) Date: 13 Jul 2003 16:08:23 +1000 Subject: [albatross-users] Redirect problems continue... In-Reply-To: <9733165.1058050668@SHEILA-LAPTOP> References: <9733165.1058050668@SHEILA-LAPTOP> Message-ID: > OK, thanks for the really quick release of patches for the issues > with redirect and not saving the cookie etc... > > I've installed the pre3 release and tried again with the stripped > down application code I shared last night. As a reminder, code is > available here: http://mathxy.com/temp/ > > Unfortunately, the code, when I attempt to run it, now generates a > 500 Internal Server error. Here is the error entry from the logs: > > Traceback (most recent call last): > File "mgr.py", line 60, in ? > app.run(qaRequest()) > File "/big/dom/xexample/lib/python2.2/site-packages/albatross/app.py", > line 253, in run > return ctx.redirect(e.loc) > File "/big/dom/xexample/lib/python2.2/site-packages/albatross/app.py", > line 217, in redirect > raise Redirect(loc) > albatross.app.Redirect: > I'm looking at the app.py file, and I don't see what the problem > is. The code from app.py involved in raising the redirect exception > appears to me to be unchanged between 1.01 and 1.10pre3. I can't believe I did that... Hold on a second. - Dave -- http://www.object-craft.com.au From djc at object-craft.com.au Sun Jul 13 06:52:45 2003 From: djc at object-craft.com.au (Dave Cole) Date: 13 Jul 2003 16:52:45 +1000 Subject: [albatross-users] Albatross 1.10 pre4 released In-Reply-To: References: Message-ID: So much for 1.10pre3. For my next trick I have packaged up the 1.10pre4 release of Albatross. This resolves the problems encountered in the 1.10pre2 release. The changes since 1.10pre3 are: * ResponseMixin redirect() renamed to send_redirect(). The changes since 1.10pre2 are: * Request classes now have a get_path_info() method. * Redirect now sends the session id cookie when it is defined. The logic has been moved into ResponseMixin.redirect(). * SessionBase now has a session_vars() method that returns a list of the names in the session. * Random page URI handling is back to 1.10pre1 state. The base_path used to split the requested URI will always end with '/'. * Random page URI cracking has been moved into the get_page_from_uri() method. This allows application to redefine the cracking method. * More documentation updates - especially in the prepackaged classes chapter. * Most samples have been changed to allow them to be run using the al-httpd program. There still is no documentation of the FastCGI and Standalone BaseHTTPServer support. The pre2 was supposed to be the last pre release of 1.10. This time for sure... If there are no issues reported with this one we will release the real 1.10 by the end of the week. - Dave -- http://www.object-craft.com.au From djc at object-craft.com.au Sun Jul 13 07:18:55 2003 From: djc at object-craft.com.au (Dave Cole) Date: 13 Jul 2003 17:18:55 +1000 Subject: [albatross-users] crafting get arg urls In-Reply-To: <3F10E4BA.90802@harvee.org> References: <3F10E4BA.90802@harvee.org> Message-ID: > I'm hitting another cognitive brick wall. It's probably because I'm > up too late but here is what's messing with my head. > > Need to create a get style URL for the spamtrap entry display. was > using a single argument and manually generated the anchor record > just fine. Tried adding an argument and things got confused with > the & and all. > > here's what I'm generating for albatross: > href="'spamtrap_display.cgi?repository=dumpster&token='+line.value().token" > target="spamtrap_display"> Try: The expr attribute is used to evaluate an href attribute. The href attribute is then mostly untouched. It gets the current_url() prefixed when '?' cannot be found in the value you specify. If you specify the href directly then the prefix is still added if necessary. > The real problem is getting clarity on quoting mixed in with > variable execution. I realize as I'm working on these problems that > I don't know or can't find easily a simple statement on how to > retrieve values and substitute them into strings simply and easily > as the case above demonstrates. > > it's a real simple thing and common to virtually every aspect of > albatross. The answer to this problem will probably occurred to me in > the morning but for now, it's irritating the hell out of me. More explanation is probably necessary in the documentation, - Dave -- http://www.object-craft.com.au From esj at harvee.org Sun Jul 13 14:16:02 2003 From: esj at harvee.org (Eric S. Johansson) Date: Sun, 13 Jul 2003 10:16:02 -0400 Subject: [albatross-users] crafting get arg urls In-Reply-To: References: <3F10E4BA.90802@harvee.org> Message-ID: <3F1169A2.6000501@harvee.org> Dave Cole wrote: > Try: > expr="'repository=dumpster&token='+line.value().token" > target="spamtrap_display"> > thanks. That put me in the right area. > > More explanation is probably necessary in the documentation, yes, I would suggest adding a complete section on this topic (data extraction from the context storage and merging bits of strings and data in expr statements ---eric From sheila at thinkspot.net Sun Jul 13 16:17:36 2003 From: sheila at thinkspot.net (Sheila King) Date: Sun, 13 Jul 2003 09:17:36 -0700 Subject: [albatross-users] pre4 - Problems still ... In-Reply-To: References: Message-ID: <1900622.1058087856@SHEILA-LAPTOP> --On Sunday, July 13, 2003 4:52 PM +1000 Dave Cole wrote: > So much for 1.10pre3. For my next trick I have packaged up the > 1.10pre4 release of Albatross. This resolves the problems encountered > in the 1.10pre2 release. This does prevent me from getting 500 Internal Server error now on my test app. Current Problem: Session Variables are still being lost, as before. If you go to the initial log in page, it shows four session variables, including _last_access and _authstatus but when you go to the next page (after entering log in information and attempting to authenticate) you go to the Expired page (which is an error) and the two session variables mentioned above are no longer in the session. The code contains NO statements that remove the session or delete session variables. Live demo here: http://mathxy.com/cgi-bin/test/mgr.py account num = 123456 email = test@example.com passwd = test1234 (only the login page should/would work. create login and lost password disabled.) Code (still) available here: http://mathxy.com/temp/ -- Sheila King http://www.thinkspot.net/sheila/ http://www.k12groups.org From djc at object-craft.com.au Sun Jul 13 22:29:44 2003 From: djc at object-craft.com.au (Dave Cole) Date: 14 Jul 2003 08:29:44 +1000 Subject: [albatross-users] Re: pre4 - Problems still ... In-Reply-To: <1900622.1058087856@SHEILA-LAPTOP> References: <1900622.1058087856@SHEILA-LAPTOP> Message-ID: >>>>> "Sheila" == Sheila King writes: Sheila> --On Sunday, July 13, 2003 4:52 PM +1000 Dave Cole Sheila> wrote: >> So much for 1.10pre3. For my next trick I have packaged up the >> 1.10pre4 release of Albatross. This resolves the problems >> encountered in the 1.10pre2 release. Sheila> This does prevent me from getting 500 Internal Server error Sheila> now on my test app. Sheila> Current Problem: Session Variables are still being lost, as Sheila> before. If you go to the initial log in page, it shows four Sheila> session variables, including _last_access and _authstatus but Sheila> when you go to the next page (after entering log in Sheila> information and attempting to authenticate) you go to the Sheila> Expired page (which is an error) and the two session variables Sheila> mentioned above are no longer in the session. The code Sheila> contains NO statements that remove the session or delete Sheila> session variables. Sheila> Live demo here: http://mathxy.com/cgi-bin/test/mgr.py Sheila> account num = 123456 email = test@example.com passwd = Sheila> test1234 (only the login page should/would work. create login Sheila> and lost password disabled.) Sheila> Code (still) available here: http://mathxy.com/temp/ The problem is a bit difficult to spot. If you run ngrep you will see it though. It looks like you have some tags somewhere (haven't looked at the source yet) because I can see requests like this: GET http://mathxy.com/cgi-bin/test/mgr.py/spacer.gif This is followed by a traceback response which you do not see because the browser thinks it should be getting an image. After the traceback Albatross deletes the session, so you get dropped back to a session expired state. - Dave -- http://www.object-craft.com.au From esj at harvee.org Mon Jul 14 13:35:46 2003 From: esj at harvee.org (Eric S. Johansson) Date: Mon, 14 Jul 2003 09:35:46 -0400 Subject: [albatross-users] unscriptable object Message-ID: <3F12B1B2.3090805@harvee.org> Traceback (most recent call last): File "/usr/lib/python2.2/site-packages/albatross/app.py", line 221, in run self.merge_request(ctx) File "/usr/lib/python2.2/site-packages/albatross/app.py", line 301, in merge_request ctx.merge_request() File "/usr/lib/python2.2/site-packages/albatross/context.py", line 306, in merge_request self.set_value(name, value) File "/usr/lib/python2.2/site-packages/albatross/context.py", line 336, in set_value if name[0] == '_': TypeError: unsubscriptable object the Q is where and why? _ is a legal character and used in other places. From sheila at thinkspot.net Mon Jul 14 14:08:30 2003 From: sheila at thinkspot.net (Sheila King) Date: Mon, 14 Jul 2003 07:08:30 -0700 Subject: [albatross-users] unscriptable object In-Reply-To: <3F12B1B2.3090805@harvee.org> References: <3F12B1B2.3090805@harvee.org> Message-ID: <305789.1058166510@SHEILA-LAPTOP> --On Monday, July 14, 2003 9:35 AM -0400 "Eric S. Johansson" wrote: > Traceback (most recent call last): > File "/usr/lib/python2.2/site-packages/albatross/app.py", line > 221, in run self.merge_request(ctx) > File "/usr/lib/python2.2/site-packages/albatross/app.py", line > 301, in merge_request > ctx.merge_request() > File "/usr/lib/python2.2/site-packages/albatross/context.py", > line 306, in merge_request > self.set_value(name, value) > File "/usr/lib/python2.2/site-packages/albatross/context.py", > line 336, in set_value > if name[0] == '_': > TypeError: unsubscriptable object > > > > the Q is where and why? _ is a legal character and used in other > places. When I have received this error in the past, it is usually because the object was a None type. I bet that your name sequence is empty (i.e. None). OK, well that is my guess. -- Sheila King http://www.thinkspot.net/sheila/ http://www.k12groups.org From sheila at thinkspot.net Mon Jul 14 14:12:09 2003 From: sheila at thinkspot.net (Sheila King) Date: Mon, 14 Jul 2003 07:12:09 -0700 Subject: [albatross-users] unscriptable object In-Reply-To: <3F12B1B2.3090805@harvee.org> References: <3F12B1B2.3090805@harvee.org> Message-ID: <525505.1058166729@SHEILA-LAPTOP> --On Monday, July 14, 2003 9:35 AM -0400 "Eric S. Johansson" wrote: > Traceback (most recent call last): > File "/usr/lib/python2.2/site-packages/albatross/app.py", line > 221, in run self.merge_request(ctx) > File "/usr/lib/python2.2/site-packages/albatross/app.py", line > 301, in merge_request > ctx.merge_request() > File "/usr/lib/python2.2/site-packages/albatross/context.py", > line 306, in merge_request > self.set_value(name, value) > File "/usr/lib/python2.2/site-packages/albatross/context.py", > line 336, in set_value > if name[0] == '_': > TypeError: unsubscriptable object > > > > the Q is where and why? _ is a legal character and used in other > places. > Another thought (this has bit me before): Do all of your form elements have a name field? I had a problem once where I forgot to put names in the HTML template for my form elements, and IIRC got this type of error, especially if you have more than one form element without a name, as then albatross thinks it is a list type. -- Sheila King http://www.thinkspot.net/sheila/ http://www.k12groups.org From esj at harvee.org Mon Jul 14 14:36:01 2003 From: esj at harvee.org (Eric S. Johansson) Date: Mon, 14 Jul 2003 10:36:01 -0400 Subject: [albatross-users] unscriptable object In-Reply-To: <305789.1058166510@SHEILA-LAPTOP> References: <3F12B1B2.3090805@harvee.org> <305789.1058166510@SHEILA-LAPTOP> Message-ID: <3F12BFD1.3090009@harvee.org> Sheila King wrote: > --On Monday, July 14, 2003 9:35 AM -0400 "Eric S. Johansson" > wrote: > >> Traceback (most recent call last): >> File "/usr/lib/python2.2/site-packages/albatross/app.py", line >> 221, in run self.merge_request(ctx) >> File "/usr/lib/python2.2/site-packages/albatross/app.py", line >> 301, in merge_request >> ctx.merge_request() >> File "/usr/lib/python2.2/site-packages/albatross/context.py", >> line 306, in merge_request >> self.set_value(name, value) >> File "/usr/lib/python2.2/site-packages/albatross/context.py", >> line 336, in set_value >> if name[0] == '_': >> TypeError: unsubscriptable object >> >> >> >> the Q is where and why? _ is a legal character and used in other >> places. > > > When I have received this error in the past, it is usually because the > object was a None type. > > I bet that your name sequence is empty (i.e. None). OK, well that is my > guess. OK, I missing something here. What name sequence are you talking about? and as for missing names on form elements, I have all input types named. Especially the submit buttons. FYI, here's the essential form elements and the albatross glue code I used to connect to my data extraction code.

    Instructions:

    Red messages strongly suspected to be spam. Green messages are strongly suspected to be not spam.

    Your job is: Correct message with wrong classification.

    There are only two ways a message can have the wrong classification. Either:

    • The email is spam, and was classified as good e-mail
    • Or the email is not spam, and was classified as spam.
    • If you are not sure, check the message detail by following the subject link.
    In order to change the classification, press the button on the line labeled "change classification". Repeat until all messages have been processed.

    The dumpster contains messages.

    Sort display by:

    go to or page

    >
    Select Score To From Subject (for detail follow link)

    aaaa

    class correction: def page_enter(self, context): if not configuration_data['is_global_spamtrap']: user = os.environ["REMOTE_USER"] else: user = None syslog.syslog("page_enter") context.locals.screen_buffer = {} context.add_session_vars('screen_buffer') context.locals.current_line_index = 0 context.add_session_vars('current_line_index') context.locals.spamtrap_size = 0 context.add_session_vars('spamtrap_size') context.locals.sort_item = "Date" context.add_session_vars('sort_item') context.locals.sort_list = [ 'Date', 'From', 'To', 'Subject' ] context.locals.spamtrap_size, context.locals.screen_buffer = generate_spamtrap_matrix(user) #syslog.syslog("spamtrap_size, screen_buffer %s %s" % (context.locals.spamtrap_size, context.locals.screen_buffer)) def page_process(self, context): if not configuration_data['is_global_spamtrap']: user = os.environ["REMOTE_USER"] else: user = None #if context.locals.train: # syslog.syslog("train button pressed") syslog.syslog("any? button pressed") for entry in context.locals.__dict__: syslog.syslog("key %s" % (entry)) # old code remnant if context.req_equals("submitaction"): if os.environ["REMOTE_USER"] == "e.johansson" and \ os.environ["REMOTE_ADDR"] == "192.168.25.1" or \ os.environ["REMOTE_USER"] == "albatross" : context.locals.action_denied= "no-go" else: context.locals.action_denied= "go-go" pass #if context.req_equals("sort_item"): def page_display (self, context): context.locals.page_width="100%" syslog.syslog("type = %s" % type(context.locals.screen_buffer)) sort_buffer = [] for token in context.locals.screen_buffer.keys(): line = context.locals.screen_buffer[token] #syslog.syslog("page_display line == %s" %line) if context.locals.sort_item == "Date": sort_buffer.append(str(line.date)+":"+token) elif context.locals.sort_item == "To": sort_buffer.append(str(line.destination)+":"+token) elif context.locals.sort_item == "From": sort_buffer.append(str(line.from_address)+":"+token) elif context.locals.sort_item == "Subject": sort_buffer.append(str(line.destination)+":"+token) else: syslog.syslog("no such item on select list %s" % context.locals.sort_item) sort_buffer.append(str(line.date)+":"+token) sort_buffer.sort() display_limit = 0 display_list = [] for index in sort_buffer: display_limit = display_limit + 1 if display_limit > configuration_data['spamtrap_display_lines']: break # extract items from screen_buffer according to the sort_buffer (junk,token) = index.split(":") display_list.append(context.locals.screen_buffer[token]) # transfer display list of X lines to template variable space context.locals.display_list = display_list context.run_template("reclaim.html") syslog.syslog("emd of display") app = SimpleApp(base_url = 'reclaim.py', template_path = '.', start_page = 'reclaim', secret = '-=-secret-=-') app.register_page('reclaim', correction()) app.run(Request()) From sheila at thinkspot.net Mon Jul 14 18:14:56 2003 From: sheila at thinkspot.net (Sheila King) Date: Mon, 14 Jul 2003 11:14:56 -0700 Subject: [albatross-users] unscriptable object In-Reply-To: <3F12BFD1.3090009@harvee.org> References: <3F12B1B2.3090805@harvee.org> <305789.1058166510@SHEILA-LAPTOP> <3F12BFD1.3090009@harvee.org> Message-ID: <3220060.1058181296@SHEILA-LAPTOP> --On Monday, July 14, 2003 10:36 AM -0400 "Eric S. Johansson" wrote: > Sheila King wrote: > >> --On Monday, July 14, 2003 9:35 AM -0400 "Eric S. Johansson" >> wrote: >> >>> Traceback (most recent call last): >>> File "/usr/lib/python2.2/site-packages/albatross/app.py", line >>> 221, in run self.merge_request(ctx) >>> File "/usr/lib/python2.2/site-packages/albatross/app.py", line >>> 301, in merge_request >>> ctx.merge_request() >>> File "/usr/lib/python2.2/site-packages/albatross/context.py", >>> line 306, in merge_request >>> self.set_value(name, value) >>> File "/usr/lib/python2.2/site-packages/albatross/context.py", >>> line 336, in set_value >>> if name[0] == '_': >>> TypeError: unsubscriptable object >>> >>> >>> >>> the Q is where and why? _ is a legal character and used in other >>> places. >> >> >> When I have received this error in the past, it is usually because >> the object was a None type. >> >> I bet that your name sequence is empty (i.e. None). OK, well that >> is my guess. > > OK, I missing something here. What name sequence are you talking > about? OK, never mind about the "name sequence" nonsense I wrote earlier. But the error is being caused because whatever is being passed in to the set_value function in context.py is an object that cannot be referenced by indexes. That's why it says "unsubscriptable" I would recommend having your program print out or display somewhere what the value of "name" is before it gets to the line where the error is occurring. Hopefully that will give you better insight into what is occurring. But you can be assured that "name" is not a string. Yes, the "_" character is allowed in names, but the object that is assigned to "name" at that point in your program is not a string type object. -- Sheila King http://www.thinkspot.net/sheila/ http://www.k12groups.org From djc at object-craft.com.au Mon Jul 14 21:37:45 2003 From: djc at object-craft.com.au (Dave Cole) Date: 15 Jul 2003 07:37:45 +1000 Subject: [albatross-users] unscriptable object In-Reply-To: <3F12BFD1.3090009@harvee.org> References: <3F12B1B2.3090805@harvee.org> <305789.1058166510@SHEILA-LAPTOP> <3F12BFD1.3090009@harvee.org> Message-ID: > Try using nameexpr="categorize" It looks like it may be a good idea to check that input fields have a non-None name in the template interpreter... - Dave -- http://www.object-craft.com.au From djc at object-craft.com.au Mon Jul 14 21:39:04 2003 From: djc at object-craft.com.au (Dave Cole) Date: 15 Jul 2003 07:39:04 +1000 Subject: [albatross-users] unscriptable object In-Reply-To: <525505.1058166729@SHEILA-LAPTOP> References: <3F12B1B2.3090805@harvee.org> <525505.1058166729@SHEILA-LAPTOP> Message-ID: >>>>> "Sheila" == Sheila King writes: Sheila> Another thought (this has bit me before): Sheila> Do all of your form elements have a name field? I had a Sheila> problem once where I forgot to put names in the HTML template Sheila> for my form elements, and IIRC got this type of error, Exactly what I was thinking. - Dave -- http://www.object-craft.com.au From djc at object-craft.com.au Mon Jul 14 23:51:13 2003 From: djc at object-craft.com.au (Dave Cole) Date: 15 Jul 2003 09:51:13 +1000 Subject: [albatross-users] unscriptable object In-Reply-To: <3F12B1B2.3090805@harvee.org> References: <3F12B1B2.3090805@harvee.org> Message-ID: > Traceback (most recent call last): > File "/usr/lib/python2.2/site-packages/albatross/app.py", line 221, in run > self.merge_request(ctx) > File "/usr/lib/python2.2/site-packages/albatross/app.py", line 301, > in merge_request > ctx.merge_request() > File "/usr/lib/python2.2/site-packages/albatross/context.py", line > 306, in merge_request > self.set_value(name, value) > File "/usr/lib/python2.2/site-packages/albatross/context.py", line > 336, in set_value > if name[0] == '_': > TypeError: unsubscriptable object > > the Q is where and why? _ is a legal character and used in other places. What release of Albatross are you using? - Dave -- http://www.object-craft.com.au From esj at harvee.org Mon Jul 14 23:50:43 2003 From: esj at harvee.org (Eric S. Johansson) Date: Mon, 14 Jul 2003 19:50:43 -0400 Subject: [albatross-users] unscriptable object In-Reply-To: References: <3F12B1B2.3090805@harvee.org> <305789.1058166510@SHEILA-LAPTOP> <3F12BFD1.3090009@harvee.org> Message-ID: <3F1341D3.4000001@harvee.org> Dave Cole wrote: >> > > > Try using nameexpr="categorize" bingo. that was it. > It looks like it may be a good idea to check that input fields have a > non-None name in the template interpreter... you have an interesting problem. How do you syntax check when you pass through all of the things that the manager keywords. Maybe we should start building a "safe-to-pass" dictionary? ---eric From djc at object-craft.com.au Mon Jul 14 23:58:09 2003 From: djc at object-craft.com.au (Dave Cole) Date: 15 Jul 2003 09:58:09 +1000 Subject: [albatross-users] unscriptable object In-Reply-To: <3F1341D3.4000001@harvee.org> References: <3F12B1B2.3090805@harvee.org> <305789.1058166510@SHEILA-LAPTOP> <3F12BFD1.3090009@harvee.org> <3F1341D3.4000001@harvee.org> Message-ID: >>>>> "Eric" == Eric S Johansson writes: Eric> Dave Cole wrote: >>> >> Try using nameexpr="categorize" Eric> bingo. that was it. >> It looks like it may be a good idea to check that input fields have >> a non-None name in the template interpreter... Eric> you have an interesting problem. How do you syntax check when Eric> you pass through all of the things that the manager keywords. Eric> Maybe we should start building a "safe-to-pass" dictionary? Rather than try to validate HTML all we do is look for the attributes that are important to Albatross. Validating HTML is a pretty big job. - Dave -- http://www.object-craft.com.au From matt at pollenation.net Tue Jul 15 00:14:25 2003 From: matt at pollenation.net (Matt Goodall) Date: 15 Jul 2003 01:14:25 +0100 Subject: [albatross-users] unscriptable object In-Reply-To: References: <3F12B1B2.3090805@harvee.org> <305789.1058166510@SHEILA-LAPTOP> <3F12BFD1.3090009@harvee.org> <3F1341D3.4000001@harvee.org> Message-ID: <1058228065.10475.16.camel@localhost> On Tue, 2003-07-15 at 00:58, Dave Cole wrote: > >>>>> "Eric" == Eric S Johansson writes: > > Eric> Dave Cole wrote: > >>> > >> Try using nameexpr="categorize" > > Eric> bingo. that was it. > > >> It looks like it may be a good idea to check that input fields have > >> a non-None name in the template interpreter... > > Eric> you have an interesting problem. How do you syntax check when > Eric> you pass through all of the things that the manager keywords. > Eric> Maybe we should start building a "safe-to-pass" dictionary? > > Rather than try to validate HTML all we do is look for the attributes > that are important to Albatross. Validating HTML is a pretty big job. Only "pretty big"? ;-) The way Albatross only processes known attributes, passing through unknown attributes untouched, is crucial to its success as a templating engine. I have used (and discarded) a number of templating engines that tamper with attributes or plain refuse to let them through ... that's so annoying. Cheers, Matt -- Matt Goodall, Pollenation Internet Ltd w: http://www.pollenation.net e: matt@pollenation.net From esj at harvee.org Tue Jul 15 00:30:00 2003 From: esj at harvee.org (Eric S. Johansson) Date: Mon, 14 Jul 2003 20:30:00 -0400 Subject: [albatross-users] unscriptable object In-Reply-To: References: <3F12B1B2.3090805@harvee.org> Message-ID: <3F134B08.4070104@harvee.org> Dave Cole wrote: > > What release of Albatross are you using? 1.10pre1 From djc at object-craft.com.au Tue Jul 15 00:36:31 2003 From: djc at object-craft.com.au (Dave Cole) Date: 15 Jul 2003 10:36:31 +1000 Subject: [albatross-users] unscriptable object In-Reply-To: <3F134B08.4070104@harvee.org> References: <3F12B1B2.3090805@harvee.org> <3F134B08.4070104@harvee.org> Message-ID: >>>>> "Eric" == Eric S Johansson writes: Eric> Dave Cole wrote: >> What release of Albatross are you using? Eric> 1.10pre1 Can you please try 1.10pre4 and see if it catches the problem? - Dave -- http://www.object-craft.com.au From esj at harvee.org Tue Jul 15 00:43:26 2003 From: esj at harvee.org (Eric S. Johansson) Date: Mon, 14 Jul 2003 20:43:26 -0400 Subject: [albatross-users] unscriptable object In-Reply-To: References: <3F12B1B2.3090805@harvee.org> <305789.1058166510@SHEILA-LAPTOP> <3F12BFD1.3090009@harvee.org> <3F1341D3.4000001@harvee.org> Message-ID: <3F134E2E.2090406@harvee.org> Dave Cole wrote: > Eric> you have an interesting problem. How do you syntax check when > Eric> you pass through all of the things that the manager keywords. > Eric> Maybe we should start building a "safe-to-pass" dictionary? > > Rather than try to validate HTML all we do is look for the attributes > that are important to Albatross. Validating HTML is a pretty big job. yes, validating HTML is a huge job. However, the task gets much smaller if you ask the question "is this a valid HTML/albatross string". then you would catch misspellings like the one I made without adding a huge amount of weight. The hard part then becomes combing the HTML documentation for valid symbols or strings or whatever you want to call them. additionally, this does not need to be a hard and fast error but can simply be a syslog directed warning turned on by explicit call. just an idea and worth exactly what you paid for it. ;-) ---eric From matt at pollenation.net Tue Jul 15 00:52:22 2003 From: matt at pollenation.net (Matt Goodall) Date: 15 Jul 2003 01:52:22 +0100 Subject: [albatross-users] New get_page_from_uri functionality Message-ID: <1058230342.30947.55.camel@localhost> I've just made use of the new method, get_page_from_uri, that Dave added a week or so ago. It works very nicely - thanks Dave. I now have a page module, assets.py, which handles all requests for the /assets uri tree, i.e. /assets/styles/default.css sends the content of styles/default.css straight from the file system to the browser. I'll try to add this as an example to the Wiki when I have a few minutes. Feel free to hassle me to do this sooner if it would be useful to you. Thanks again Dave. Cheers, Matt -- Matt Goodall, Pollenation Internet Ltd w: http://www.pollenation.net e: matt@pollenation.net From andrewm at object-craft.com.au Tue Jul 15 00:58:33 2003 From: andrewm at object-craft.com.au (Andrew McNamara) Date: Tue, 15 Jul 2003 10:58:33 +1000 Subject: [albatross-users] unscriptable object In-Reply-To: Message from "Eric S. Johansson" of "Mon, 14 Jul 2003 20:43:26 -0400." <3F134E2E.2090406@harvee.org> References: <3F12B1B2.3090805@harvee.org> <305789.1058166510@SHEILA-LAPTOP> <3F12BFD1.3090009@harvee.org> <3F1341D3.4000001@harvee.org> <3F134E2E.2090406@harvee.org> Message-ID: <20030715005833.D26CA3C421@coffee.object-craft.com.au> >yes, validating HTML is a huge job. However, the task gets much smaller >if you ask the question "is this a valid HTML/albatross string". then you >would catch misspellings like the one I made without adding a huge amount >of weight. The hard part then becomes combing the HTML documentation for >valid symbols or strings or whatever you want to call them. > >additionally, this does not need to be a hard and fast error but can >simply be a syslog directed warning turned on by explicit call. Validation is something that's only of interest to the developer - it's probably better to have a stand-alone validator that you run over the templates while developing them, than to wear the cost of validation every time to run a template. I'd presume there are HTML validators out there than can be taught about albatross's tags, although it would be difficult with things like . -- Andrew McNamara, Senior Developer, Object Craft http://www.object-craft.com.au/ From djc at object-craft.com.au Tue Jul 15 01:06:58 2003 From: djc at object-craft.com.au (Dave Cole) Date: 15 Jul 2003 11:06:58 +1000 Subject: [albatross-users] unscriptable object In-Reply-To: <3F134E2E.2090406@harvee.org> References: <3F12B1B2.3090805@harvee.org> <305789.1058166510@SHEILA-LAPTOP> <3F12BFD1.3090009@harvee.org> <3F1341D3.4000001@harvee.org> <3F134E2E.2090406@harvee.org> Message-ID: >>>>> "Eric" == Eric S Johansson writes: Eric> Dave Cole wrote: you have an interesting problem. How do you Eric> syntax check when you pass through all of the things that the Eric> manager keywords. Maybe we should start building a Eric> "safe-to-pass" dictionary? >> Rather than try to validate HTML all we do is look for the >> attributes that are important to Albatross. Validating HTML is a >> pretty big job. Eric> yes, validating HTML is a huge job. However, the task gets much Eric> smaller if you ask the question "is this a valid HTML/albatross Eric> string". then you would catch misspellings like the one I made Eric> without adding a huge amount of weight. The hard part then Eric> becomes combing the HTML documentation for valid symbols or Eric> strings or whatever you want to call them. Eric> additionally, this does not need to be a hard and fast error but Eric> can simply be a syslog directed warning turned on by explicit Eric> call. Eric> just an idea and worth exactly what you paid for it. ;-) I just did some research... On Debian you can install two packages; tidy-proxy and wdg-html-validator. This will probably show you all sorts of things about the HTML coming out of your application. - Dave -- http://www.object-craft.com.au From djc at object-craft.com.au Tue Jul 15 01:17:39 2003 From: djc at object-craft.com.au (Dave Cole) Date: 15 Jul 2003 11:17:39 +1000 Subject: [albatross-users] New get_page_from_uri functionality In-Reply-To: <1058230342.30947.55.camel@localhost> References: <1058230342.30947.55.camel@localhost> Message-ID: >>>>> "Matt" == Matt Goodall writes: Matt> I've just made use of the new method, get_page_from_uri, that Matt> Dave added a week or so ago. It works very nicely - thanks Dave. It seems like such an obvious feature in retrospect. Matt> I now have a page module, assets.py, which handles all requests Matt> for the /assets uri tree, i.e. /assets/styles/default.css sends Matt> the content of styles/default.css straight from the file system Matt> to the browser. Cool. It does open up all sorts of weird and wonderful URL schemes. Matt> I'll try to add this as an example to the Wiki when I have a few Matt> minutes. Feel free to hassle me to do this sooner if it would be Matt> useful to you. It would be excellent to get an example up there. Matt> Thanks again Dave. My pleasure. Thanks for taking it for a spin. - Dave -- http://www.object-craft.com.au From matt at pollenation.net Tue Jul 15 01:27:32 2003 From: matt at pollenation.net (Matt Goodall) Date: 15 Jul 2003 02:27:32 +0100 Subject: [albatross-users] Feature request Message-ID: <1058232452.31165.90.camel@localhost> It would be nice if the code for multiples pages in a random app could be kept in a single Python module. Something like a mix of page object and page module (see below) might work although I am aware that page objects are created once and are registered with the application. users.py -------- # Page for uri of /users/list class ListUsers: name = 'list' def page_display(self, ctx): pass # Page for uri of /users/add class AddUser: name = 'add' def page_process(self, ctx): pass def page_display(self, ctx): pass ----- Perhaps there is a better way than this? - Matt -- Matt Goodall, Pollenation Internet Ltd w: http://www.pollenation.net e: matt@pollenation.net From sheila at thinkspot.net Tue Jul 15 20:28:34 2003 From: sheila at thinkspot.net (Sheila King) Date: Tue, 15 Jul 2003 13:28:34 -0700 Subject: [albatross-users] Re: pre4 - Problems still ... In-Reply-To: References: <1900622.1058087856@SHEILA-LAPTOP> Message-ID: <6834747.1058275714@SHEILA-LAPTOP> --On Monday, July 14, 2003 8:29 AM +1000 Dave Cole wrote: >>>>>> "Sheila" == Sheila King writes: > > Sheila> --On Sunday, July 13, 2003 4:52 PM +1000 Dave Cole > Sheila> wrote: > Sheila> Current Problem: Session Variables are still being lost, as > Sheila> before. If you go to the initial log in page, it shows four > Sheila> session variables, including _last_access and _authstatus but > Sheila> when you go to the next page (after entering log in > Sheila> information and attempting to authenticate) you go to the > Sheila> Expired page (which is an error) and the two session variables > Sheila> mentioned above are no longer in the session. The code > Sheila> contains NO statements that remove the session or delete > Sheila> session variables. > The problem is a bit difficult to spot. If you run ngrep you will see > it though. > > It looks like you have some tags somewhere (haven't looked at > the source yet) because I can see requests like this: > > GET http://mathxy.com/cgi-bin/test/mgr.py/spacer.gif > > This is followed by a traceback response which you do not see because > the browser thinks it should be getting an image. > > After the traceback Albatross deletes the session, so you get dropped > back to a session expired state. OK, I've been working on this, and I do agree now that there is/are error(s) in my code causing the session to drop. I've installed Ethereal () and am trying to learn how to use it to see the http response packets so that I can see these errors you are mentioning. There is definitely something different about the error handling in pre4 as opposed to previous versions of Albatross. The error you mention above is essentially a 404 error. There was no al-img tag, but my commonmacros.html file did have a normal HTML tag and the image refereced was not on the server, and so should generate a 404 error. However, it has apparently been like that for a long time (this image is also called in my full application program) and has never caused session to drop before. Maybe it should cause session to drop. Dunno. But, even if I fix that problem, there are other errors I've found, such as expressions not being defined in the local context name space. Before these always took me to the default Albatross error page (which I've not tried to overwrite) with a nice traceback. When this happened, I KNEW that something in my code was wrong. Now it is not doing that. It is taking me to the expired session page in my application and the only way I can see the tracebacks for anything (it seems) is by sniffing packets. I'm not a neophyte cgi programmer, although I'm no expert either. But I have a fair/modest amount of experience in this area, and I've never had to sniff packets before to read the error messages sent by a Python cgi script. :( Is this again something peculiar to the redirect/random URL type of applications? It looks to me like this new send_redirect function could be the culprit? Or is at least involved in some way? def send_redirect(self, loc): cookie = self.get_header('Set-Cookie') if cookie: self.request.write_header('Set-Cookie', cookie) return self.request.redirect(loc) Could this be the reason that after the handle_exception method prints out the traceback, that the request is still redirected to the previously requested redirect page? If so, IMO this behavior should be modified. handle_exception should print the output (traceback) and then halt. I'm just grasping about to try and think why it is so flipping hard for me to see that there are errors in my code, when with previous versions of Albatross it was easy. -- Sheila King http://www.thinkspot.net/sheila/ http://www.k12groups.org From matt at pollenation.net Tue Jul 15 21:12:12 2003 From: matt at pollenation.net (Matt Goodall) Date: 15 Jul 2003 22:12:12 +0100 Subject: [albatross-users] Re: pre4 - Problems still ... In-Reply-To: <6834747.1058275714@SHEILA-LAPTOP> References: <1900622.1058087856@SHEILA-LAPTOP> <6834747.1058275714@SHEILA-LAPTOP> Message-ID: <1058303532.8094.4.camel@localhost> On Tue, 2003-07-15 at 21:28, Sheila King wrote: > I've installed Ethereal () and am trying to learn > how to use it to see the http response packets so that I can see these > errors you are mentioning. If you're using Mozilla you might find the LiveHTTPHeaders tool a bit more convenient than Ethereal. http://livehttpheaders.mozdev.org/ If you're not using Mozilla then you should be ;-). - Matt -- Matt Goodall, Pollenation Internet Ltd w: http://www.pollenation.net e: matt@pollenation.net From sheila at thinkspot.net Tue Jul 15 21:32:46 2003 From: sheila at thinkspot.net (Sheila King) Date: Tue, 15 Jul 2003 14:32:46 -0700 Subject: [albatross-users] Re: pre4 - Problems still ... In-Reply-To: <1058303532.8094.4.camel@localhost> References: <1900622.1058087856@SHEILA-LAPTOP> <6834747.1058275714@SHEILA-LAPTOP> <1058303532.8094.4.camel@localhost> Message-ID: <10687297.1058279566@SHEILA-LAPTOP> --On Tuesday, July 15, 2003 10:12 PM +0100 Matt Goodall wrote: > On Tue, 2003-07-15 at 21:28, Sheila King wrote: >> I've installed Ethereal () and am trying to >> learn how to use it to see the http response packets so that I can see >> these errors you are mentioning. > > If you're using Mozilla you might find the LiveHTTPHeaders tool a bit > more convenient than Ethereal. http://livehttpheaders.mozdev.org/ > > If you're not using Mozilla then you should be ;-). Thanks for the link. That looks quite interesting, and of course I'm using Mozilla. Although technically I will need to test my app in many different browsers before deployment. It does look like LiveHTTPHeaders may have some debugging/testing functionality that I cannot (easily) achieve by other means. It looks like that LiveHTTPHeaders doesn't provide all of the content, though? And I need to see the content to see the tracebacks, which lets me know exactly what is wrong with the script. So, I guess it's ethereal for now. -- Sheila King http://www.thinkspot.net/sheila/ http://www.k12groups.org From matt at pollenation.net Tue Jul 15 21:48:41 2003 From: matt at pollenation.net (Matt Goodall) Date: 15 Jul 2003 22:48:41 +0100 Subject: [albatross-users] Re: pre4 - Problems still ... In-Reply-To: <6834747.1058275714@SHEILA-LAPTOP> References: <1900622.1058087856@SHEILA-LAPTOP> <6834747.1058275714@SHEILA-LAPTOP> Message-ID: <1058305720.28841.19.camel@localhost> On Tue, 2003-07-15 at 21:28, Sheila King wrote: > But, even if I fix that problem, there are other errors I've found, such as > expressions not being defined in the local context name space. Before these > always took me to the default Albatross error page (which I've not tried to > overwrite) with a nice traceback. When this happened, I KNEW that something > in my code was wrong. > > Now it is not doing that. It is taking me to the expired session page in my > application and the only way I can see the tracebacks for anything (it > seems) is by sniffing packets. I just tried this here by deliberately changing the name in an expr. Is that what you mean by "expressions not being defined in the local context"? I get a traceback for a NameError exception as expected. I'm not sure what's happening for you but it might be worth **completely** removing the albatross directory from site-packages and reinstalling 1.10pre4. IIRC, you patched 1.10pre2 so maybe there is something that 1.10pre4 setup.py didn't replace. This is pure speculation but at least you will definitely know what's installed. If it still fails after that could you isolate the error in a totally trivial example and post it to the list. I'll _try_ to take a look if Dave and Andrew are too busy although I can't promise too much - lots to do myself. Cheers, Matt -- Matt Goodall, Pollenation Internet Ltd w: http://www.pollenation.net e: matt@pollenation.net From todd at slack.net Tue Jul 15 22:10:36 2003 From: todd at slack.net (Todd Grimason) Date: Tue, 15 Jul 2003 18:10:36 -0400 Subject: [albatross-users] Re: pre4 - Problems still ... In-Reply-To: <10687297.1058279566@SHEILA-LAPTOP>; from sheila@thinkspot.net on Tue, Jul 15, 2003 at 02:32:46PM -0700 References: <1900622.1058087856@SHEILA-LAPTOP> <6834747.1058275714@SHEILA-LAPTOP> <1058303532.8094.4.camel@localhost> <10687297.1058279566@SHEILA-LAPTOP> Message-ID: <20030715181036.B18619@crank.slack.net> * Sheila King [2003-07-15 17:34]: > > It looks like that LiveHTTPHeaders doesn't provide all of the content, > though? And I need to see the content to see the tracebacks, which lets me > know exactly what is wrong with the script. So, I guess it's ethereal for > now. tcpflow -- A TCP Flow Recorder http://www.circlemud.org/~jelson/software/tcpflow/ very handy, assuming(?) you're on a linux/bsd/osx platform. -- ___________________________ toddgrimason*todd@slack.net From sheila at thinkspot.net Tue Jul 15 22:52:17 2003 From: sheila at thinkspot.net (Sheila King) Date: Tue, 15 Jul 2003 15:52:17 -0700 Subject: [albatross-users] Re: pre4 - Problems still ... In-Reply-To: <1058305720.28841.19.camel@localhost> References: <1900622.1058087856@SHEILA-LAPTOP> <6834747.1058275714@SHEILA-LAPTOP> <1058305720.28841.19.camel@localhost> Message-ID: <15458017.1058284337@SHEILA-LAPTOP> --On Tuesday, July 15, 2003 10:48 PM +0100 Matt Goodall wrote: > I just tried this here by deliberately changing the name in an > expr. Is that what you mean by "expressions not being defined > in the local context"? I get a traceback for a NameError exception as > expected. > > I'm not sure what's happening for you but it might be worth > **completely** removing the albatross directory from site-packages and > reinstalling 1.10pre4. IIRC, you patched 1.10pre2 so maybe there is > something that 1.10pre4 setup.py didn't replace. This is pure > speculation but at least you will definitely know what's installed. > > If it still fails after that could you isolate the error in a totally > trivial example and post it to the list. I'll _try_ to take a look if > Dave and Andrew are too busy although I can't promise too much - lots to > do myself. Thank Matt for the tips and ideas. I will try to dig in a bit more tonight (providing my other tasks permit the time) and see if I can isolate what the problem is, exactly. -- Sheila King http://www.thinkspot.net/sheila/ http://www.k12groups.org From andrewm at object-craft.com.au Tue Jul 15 23:09:31 2003 From: andrewm at object-craft.com.au (Andrew McNamara) Date: Wed, 16 Jul 2003 09:09:31 +1000 Subject: [albatross-users] Re: pre4 - Problems still ... In-Reply-To: Message from Sheila King of "Tue, 15 Jul 2003 13:28:34 MST." <6834747.1058275714@SHEILA-LAPTOP> References: <1900622.1058087856@SHEILA-LAPTOP> <6834747.1058275714@SHEILA-LAPTOP> Message-ID: <20030715230931.4FDE23C421@coffee.object-craft.com.au> >OK, I've been working on this, and I do agree now that there is/are >error(s) in my code causing the session to drop. One thing I find useful is to comment out the call to remove_session in app.py, Application.handle_exception(). I'm not sure if this will be as helpful in a randompage app, but it's very handy for other deployment options. >There is definitely something different about the error handling in pre4 as >opposed to previous versions of Albatross. The error *handling* largely hasn't changed, but it could be that pre4 is picking up an error (and raising an exception) that previous versions let pass silently, or that pre4 is botching headers. >The error you mention above is essentially a 404 error. There was no al-img >tag, but my commonmacros.html file did have a normal HTML tag and the >image refereced was not on the server, and so should generate a 404 error. I wouldn't have thought that would cause the symptoms you are seeing. >But, even if I fix that problem, there are other errors I've found, such as >expressions not being defined in the local context name space. Before these >always took me to the default Albatross error page (which I've not tried to >overwrite) with a nice traceback. When this happened, I KNEW that something >in my code was wrong. > >Now it is not doing that. It is taking me to the expired session page in my >application and the only way I can see the tracebacks for anything (it >seems) is by sniffing packets. What can cause this is if the rendered html template contains references back to other albatross rendered content (so, for example, frames or images). What happens is that one frame or image gets an exception, and when the next one is fetched by the browser, the session has been removed. The fact that you are seeing a traceback going over the wire, but not seeing anything rendered in your browser strongly suggests a non-html object is to blame (an image?). Another possibility is that the traceback you're seeing go past is being interpreted by the browser as HTTP headers and hidden for that reason (which would tie in with the theory you mention below). Maybe you could mail a text dump of the trace to me and I see if I can tell which option it is? If you can't get ethereal to produce a text dump, do something like: # tcpdump -s 2000 -n -w /tmp/alba-dump port 80 Then gzip the /tmp/alba-dump file and mail it to me. >I'm not a neophyte cgi programmer, although I'm no expert either. But I >have a fair/modest amount of experience in this area, and I've never had >to sniff packets before to read the error messages sent by a Python cgi >script. > >:( It does tend to be a technique best used when all others have failed. The last time I used it in this context was debugging the "file" input handling (to see the mime headers)... 8-) >Is this again something peculiar to the redirect/random URL type of >applications? Well, they do have a lot of gotchyas that don't apply to other application models - I tend to try to avoid them for that reason. >It looks to me like this new send_redirect function could be the culprit? >Or is at least involved in some way? > > def send_redirect(self, loc): > cookie = self.get_header('Set-Cookie') > if cookie: > self.request.write_header('Set-Cookie', cookie) > return self.request.redirect(loc) > >Could this be the reason that after the handle_exception method prints out >the traceback, that the request is still redirected to the previously >requested redirect page? If so, IMO this behavior should be modified. >handle_exception should print the output (traceback) and then halt. Ah - that sounds like a good theory. Dave? >I'm just grasping about to try and think why it is so flipping hard for me >to see that there are errors in my code, when with previous versions of >Albatross it was easy. It certainly should be easy... -- Andrew McNamara, Senior Developer, Object Craft http://www.object-craft.com.au/ From djc at object-craft.com.au Tue Jul 15 23:42:13 2003 From: djc at object-craft.com.au (Dave Cole) Date: 16 Jul 2003 09:42:13 +1000 Subject: [albatross-users] Re: pre4 - Problems still ... In-Reply-To: <6834747.1058275714@SHEILA-LAPTOP> References: <1900622.1058087856@SHEILA-LAPTOP> <6834747.1058275714@SHEILA-LAPTOP> Message-ID: >>>>> "Sheila" == Sheila King writes: >> It looks like you have some tags somewhere (haven't looked >> at the source yet) because I can see requests like this: >> >> GET http://mathxy.com/cgi-bin/test/mgr.py/spacer.gif >> >> This is followed by a traceback response which you do not see >> because the browser thinks it should be getting an image. >> >> After the traceback Albatross deletes the session, so you get >> dropped back to a session expired state. Sheila> There is definitely something different about the error Sheila> handling in pre4 as opposed to previous versions of Albatross. I am interested to know what you see as being the difference. Sheila> The error you mention above is essentially a 404 error. There Sheila> was no al-img tag, but my commonmacros.html file did have a Sheila> normal HTML tag and the image refereced was not on the Sheila> server, and so should generate a 404 error. Another way that you might see the browser requesting the image from the application via http://mathxy.com/cgi-bin/test/mgr.py/spacer.gif is if you put a plain IMG tag in your template like this: The browser will treat this as a relative URL and will expand it to a full URL. Just looked at your code. commonmacros.html has this: Sheila> However, it has apparently been like that for a long time Sheila> (this image is also called in my full application program) and Sheila> has never caused session to drop before. Sheila> Maybe it should cause session to drop. Dunno. Your application does not recognise the request for the image and treat it as such - it responds with a python traceback. Sheila> But, even if I fix that problem, there are other errors I've Sheila> found, such as expressions not being defined in the local Sheila> context name space. Before these always took me to the default Sheila> Albatross error page (which I've not tried to overwrite) with Sheila> a nice traceback. When this happened, I KNEW that something in Sheila> my code was wrong. Did you manage to see the content being returned for the image requests? They certainly looked like a normal Albatross traceback to me. I did not look at the content of the traceback. Sheila> Now it is not doing that. It is taking me to the expired Sheila> session page in my application and the only way I can see the Sheila> tracebacks for anything (it seems) is by sniffing packets. This is not so much a problem of Albatross. The browser requests some image data and receives some text in response. It handles this by silently discarding the data from what I can see. Sheila> I'm not a neophyte cgi programmer, although I'm no expert Sheila> either. But I have a fair/modest amount of experience in this Sheila> area, and I've never had to sniff packets before to read the Sheila> error messages sent by a Python cgi script. You don't have to sniff packets - I just do it sometimes when I do not want to modify the source. Given that not all of what happens between the browser and application is visible, packet sniffing is a useful tool at times. Sheila> Is this again something peculiar to the redirect/random URL Sheila> type of applications? Nope. If you cause the browser to request an image of an application that is not prepared to serve images then you will not get good results. Sheila> It looks to me like this new send_redirect function could be Sheila> the culprit? Or is at least involved in some way? Shiela> def send_redirect(self, loc): Shiela> cookie = self.get_header('Set-Cookie') Shiela> if cookie: Shiela> self.request.write_header('Set-Cookie', cookie) Shiela> return self.request.redirect(loc) I would be a little surprised if it was having any impact on the problem. Sheila> Could this be the reason that after the handle_exception Sheila> method prints out the traceback, that the request is still Sheila> redirected to the previously requested redirect page? If so, Sheila> IMO this behavior should be modified. handle_exception should Sheila> print the output (traceback) and then halt. The redirect is caused by the Location header, not the Set-Cookie. Sheila> I'm just grasping about to try and think why it is so flipping Sheila> hard for me to see that there are errors in my code, when with Sheila> previous versions of Albatross it was easy. I am a bit confused about this. I cannot see how the 1.10pre4 release is different to previous releases in how it handles and reports errors. That does not mean that there are no differences, it just means I don't think anything that has changed to impact that behaviour. - Dave -- http://www.object-craft.com.au From djc at object-craft.com.au Wed Jul 16 00:12:09 2003 From: djc at object-craft.com.au (Dave Cole) Date: 16 Jul 2003 10:12:09 +1000 Subject: [albatross-users] Re: pre4 - Problems still ... In-Reply-To: <20030715230931.4FDE23C421@coffee.object-craft.com.au> References: <1900622.1058087856@SHEILA-LAPTOP> <6834747.1058275714@SHEILA-LAPTOP> <20030715230931.4FDE23C421@coffee.object-craft.com.au> Message-ID: >>>>> "Andrew" == Andrew McNamara writes: >> Could this be the reason that after the handle_exception method >> prints out the traceback, that the request is still redirected to >> the previously requested redirect page? If so, IMO this behavior >> should be modified. handle_exception should print the output >> (traceback) and then halt. Andrew> Ah - that sounds like a good theory. Dave? I can't see how setting a cookie would cause a redirect to occur when previously it didn't. Maybe some packet dumps will shed some light. - Dave -- http://www.object-craft.com.au From matt at pollenation.net Wed Jul 16 10:04:55 2003 From: matt at pollenation.net (Matt Goodall) Date: Wed, 16 Jul 2003 11:04:55 +0100 Subject: [albatross-users] Levelling the "random vs non-random" field Message-ID: <3F152347.1060002@pollenation.net> The other day I was thinking about what _I_ think could make Albatross better still. At some point (i.e. if I ever have the time) there are a few things I might experiment with in Albatross: * Provide random apps with the page lifecycle (specifically page_enter and page_leave) that non-random apps benefit from - it's a wonderful way to manage session data. This is probably more difficult but I suspect it's not impossible. The session already has __page__ so I think Albatross has enough to work out what's going on, it's just putting the hooks in the right place? * Make ctx.set_page() and ctx.redirect() work for both types of apps. I think this is one of the few cases where Albatross forces you to decide on an application type right at the start and I think that's a shame. Perhaps it's even unnecessary? I don't know yet. * Make a RandomPageObject mixin. Or better still, separate the random vs non-random and page object vs page module behaviours to allow whatever combination makes sense. I don't think this would be too difficult and it may be quite useful. * More request adapters. The one I'm probably most interested in is Twisted. Twisted is a lot of fun and has some some really nice features but woven (the web part of the framework) is more complex than something like Albatross. What are your thoughts on the above? Have you explored any of these already and decided its too difficult? Dave/Andrew, is there anything that you simply don't want to see happening in Albatross? Of course, I may never actually find any time to look into any of these ;-) Cheers, Matt -- Matt Goodall, Pollenation Internet Ltd w: http://www.pollenationinternet.com e: matt@pollenation.net From djc at object-craft.com.au Wed Jul 16 10:56:43 2003 From: djc at object-craft.com.au (Dave Cole) Date: 16 Jul 2003 20:56:43 +1000 Subject: [albatross-users] Levelling the "random vs non-random" field In-Reply-To: <3F152347.1060002@pollenation.net> References: <3F152347.1060002@pollenation.net> Message-ID: >>>>> "Matt" == Matt Goodall writes: Matt> The other day I was thinking about what _I_ think could make Matt> Albatross better still. At some point (i.e. if I ever have the Matt> time) there are a few things I might experiment with in Matt> Albatross: Matt> * Provide random apps with the page lifecycle (specifically Matt> page_enter and page_leave) that non-random apps benefit from - Matt> it's a wonderful way to manage session data. This is probably Matt> more difficult but I suspect it's not impossible. The session Matt> already has __page__ so I think Albatross has enough to work out Matt> what's going on, it's just putting the hooks in the right place? I am not sure that this would be general enough to rely upon in your application - users would be jumping all over the place. Does that matter though? Matt> * Make ctx.set_page() and ctx.redirect() work for both types of Matt> apps. I think this is one of the few cases where Albatross Matt> forces you to decide on an application type right at the start Matt> and I think that's a shame. Perhaps it's even unnecessary? I Matt> don't know yet. That seems like a really good idea. So good it makes me wonder why it does not already do that. Maybe I have forgotten why I thought the two were sufficiently different enough to warrant different names. Matt> * Make a RandomPageObject mixin. Or better still, separate the Matt> random vs non-random and page object vs page module behaviours Matt> to allow whatever combination makes sense. I don't think this Matt> would be too difficult and it may be quite useful. If we required Python 2.2 and changed RandomPageModuleMixin so that it did not inherit from any other class, then I think we could change the code to use the super() builtin function where it is currently calling PageModuleMixin.page_enter() and other methods. We would still need to do something about the call to self.load_page_module() though. Maybe just implement a stubbed method in the PageObjectMixin. Matt> * More request adapters. The one I'm probably most interested in Matt> is Twisted. Twisted is a lot of fun and has some some really Matt> nice features but woven (the web part of the framework) is more Matt> complex than something like Albatross. That would be cool to have. I spent a little time looking at Twisted when I had to build a forking server. I could not get Twisted to do what I wanted and did not have the time to figure it out. Matt> What are your thoughts on the above? Have you explored any of Matt> these already and decided its too difficult? Dave/Andrew, is Matt> there anything that you simply don't want to see happening in Matt> Albatross? My immediate response to that is no. Each time the classes are pushed in a new direction we are closer to my original goal with Albatross. I wanted to build a collection of classes that could be used to construct many different types of web applications. In my day dreams I imagined different layers on top of Albatross being used to narrow the focus and raise the functionality for different and smaller problem domains. It is still a day dream though. Matt> Of course, I may never actually find any time to look into any Matt> of these ;-) If only people would pay us money to play with this stuff all day :-) - Dave -- http://www.object-craft.com.au From matt at pollenation.net Wed Jul 16 12:54:56 2003 From: matt at pollenation.net (Matt Goodall) Date: Wed, 16 Jul 2003 13:54:56 +0100 Subject: [albatross-users] Levelling the "random vs non-random" field In-Reply-To: References: <3F152347.1060002@pollenation.net> Message-ID: <3F154B20.2020203@pollenation.net> Dave Cole wrote: >>>>>>"Matt" == Matt Goodall writes: >>>>>> >>>>>> >Matt> * Provide random apps with the page lifecycle (specifically >Matt> page_enter and page_leave) that non-random apps benefit from - >Matt> it's a wonderful way to manage session data. This is probably >Matt> more difficult but I suspect it's not impossible. The session >Matt> already has __page__ so I think Albatross has enough to work out >Matt> what's going on, it's just putting the hooks in the right place? > >I am not sure that this would be general enough to rely upon in your >application - users would be jumping all over the place. Does that >matter though? > In my eyes, I see the real benefit of page_enter and page_leave as somewhere to set up and tear down any session data for the page. This need is equally true for random apps as non-random apps. Are there any other uses of page_enter/leave that you have come across? Obviously, there's no way of knowing to clear up session data if someone closes their browser but at least you get the chance during normal application flow. Hmm, just a random thought, but would it be useful/possible to take the page_enter/leave concept and make pages with persistent state? I'm thinking along the lines of pickling the non-transient properties of a page instance to the session rather than mucking about with add_session_vars. Woah, best stop this train of thought now or I'll want to play even more ;-). >Matt> * Make ctx.set_page() and ctx.redirect() work for both types of >Matt> apps. I think this is one of the few cases where Albatross >Matt> forces you to decide on an application type right at the start >Matt> and I think that's a shame. Perhaps it's even unnecessary? I >Matt> don't know yet. > >That seems like a really good idea. So good it makes me wonder why it >does not already do that. Maybe I have forgotten why I thought the >two were sufficiently different enough to warrant different names. > Please don't get rid of one, both are required: set_page() essentially just changes which page actually gets displayed, redirect() allows you to change the URL or jump away from a form post. IIRC, Sheila mentioned that she didn't like _having_ to redirect in random apps, set_page() would help here but redirect() definitely has its uses as described above. >Matt> * Make a RandomPageObject mixin. Or better still, separate the >Matt> random vs non-random and page object vs page module behaviours >Matt> to allow whatever combination makes sense. I don't think this >Matt> would be too difficult and it may be quite useful. > >If we required Python 2.2 and changed RandomPageModuleMixin so that it >did not inherit from any other class, then I think we could change the >code to use the super() builtin function where it is currently calling >PageModuleMixin.page_enter() and other methods. We would still need >to do something about the call to self.load_page_module() though. >Maybe just implement a stubbed method in the PageObjectMixin. > Ah, super() ... so nice. I've lost count of the number of times I've tried to use it with Albatross before remembering that it's only available for new style classes ;-). >Matt> * More request adapters. The one I'm probably most interested in >Matt> is Twisted. Twisted is a lot of fun and has some some really >Matt> nice features but woven (the web part of the framework) is more >Matt> complex than something like Albatross. > >That would be cool to have. I spent a little time looking at Twisted >when I had to build a forking server. I could not get Twisted to do >what I wanted and did not have the time to figure it out. > Twisted doesn't fork, could that be why you had trouble? ;-). At least, I don't think it forks?! Seriously though, once Twisted is documented and there are more, well written example apps it could be a very nice application platform. The thought of integrating smtp, nntp, http etc into one application is just so lovely. But right now, I'm in the same boat as you - looking longingly in with not enough time to play and learn. By the way, have you looked at Twisted's LivePage stuff? All I can say is wow! I think scgi forks. I was wondering about that as yet another request adapter but its lacking that "itch to scratch" quality for me now that there is fastcgi support. Perhaps a FeatureRequest page to go alongside the ProposedChanges page on the wiki would be a good way of gathering ideas for future versions? That might also help keep track of things as people wander in and out of the project, as invariably happens with open source. >Matt> What are your thoughts on the above? Have you explored any of >Matt> these already and decided its too difficult? Dave/Andrew, is >Matt> there anything that you simply don't want to see happening in >Matt> Albatross? > >My immediate response to that is no. Each time the classes are pushed >in a new direction we are closer to my original goal with Albatross. >I wanted to build a collection of classes that could be used to >construct many different types of web applications. > >In my day dreams I imagined different layers on top of Albatross being >used to narrow the focus and raise the functionality for different and >smaller problem domains. It is still a day dream though. > >Matt> Of course, I may never actually find any time to look into any >Matt> of these ;-) > >If only people would pay us money to play with this stuff all day :-) > Yeah, well that's why I've gone a bit quiter on the list this last week - I did too much "playing" last week. Python is often like playing anyway though :). Cheers, Matt -- Matt Goodall, Pollenation Internet Ltd w: http://www.pollenationinternet.com e: matt@pollenation.net From djc at object-craft.com.au Thu Jul 17 01:34:32 2003 From: djc at object-craft.com.au (Dave Cole) Date: 17 Jul 2003 11:34:32 +1000 Subject: [albatross-users] Levelling the "random vs non-random" field In-Reply-To: <3F154B20.2020203@pollenation.net> References: <3F152347.1060002@pollenation.net> <3F154B20.2020203@pollenation.net> Message-ID: >>>>> "Matt" == Matt Goodall writes: Matt> Hmm, just a random thought, but would it be useful/possible to Matt> take the page_enter/leave concept and make pages with persistent Matt> state? I'm thinking along the lines of pickling the Matt> non-transient properties of a page instance to the session Matt> rather than mucking about with add_session_vars. Woah, best stop Matt> this train of thought now or I'll want to play even more ;-). You could get a poor mans version of the same thing by just placing all persistent information about each page in a single object. That single object could then be placed into the session. Some funny untested code: class MyCtx(albatross_ctx): def set_page_state(self, name): # Create a page state dictionary in the session if it does # not already exist if not hasattr(self.locals, '_page_state'): self.locals._page_state = {} self.add_session_vars('_page_state') # Find the state for the current page state = self.locals._page_state.get(name) if not state: state = Vars() self.locals._page_state[name] = state # Place current page state information in _state for # template access self.locals._state = state return state Then in your page module or whatever... def page_enter(ctx): ctx.set_page_state('blah') def page_process(ctx): ctx.locals._state.something = 'or other' def page_display(ctx): ctx.run_template('blah.html') The in blah.html... >> That would be cool to have. I spent a little time looking at >> Twisted when I had to build a forking server. I could not get >> Twisted to do what I wanted and did not have the time to figure it >> out. >> Matt> Twisted doesn't fork, could that be why you had trouble? ;-). At Matt> least, I don't think it forks?! I used the wrong term. What I meant to say was that the server had to talk a TCP protocol then fork and monitor child processes. Matt> I think scgi forks. I was wondering about that as yet another Matt> request adapter but its lacking that "itch to scratch" quality Matt> for me now that there is fastcgi support. Matt> Perhaps a FeatureRequest page to go alongside the Matt> ProposedChanges page on the wiki would be a good way of Matt> gathering ideas for future versions? That might also help keep Matt> track of things as people wander in and out of the project, as Matt> invariably happens with open source. Good idea. - Dave -- http://www.object-craft.com.au From matt at pollenation.net Thu Jul 17 09:55:52 2003 From: matt at pollenation.net (Matt Goodall) Date: Thu, 17 Jul 2003 10:55:52 +0100 Subject: [albatross-users] Levelling the "random vs non-random" field In-Reply-To: References: <3F152347.1060002@pollenation.net> <3F154B20.2020203@pollenation.net> Message-ID: <3F1672A8.7050103@pollenation.net> Dave Cole wrote: >>>>>>"Matt" == Matt Goodall writes: >>>>>> >>>>>> >Perhaps a FeatureRequest page to go alongside the >Matt> ProposedChanges page on the wiki would be a good way of >Matt> gathering ideas for future versions? That might also help keep >Matt> track of things as people wander in and out of the project, as >Matt> invariably happens with open source. > >Good idea. > Done. It only contains the ideas from this thread for now. I'm sure there are other ideas floating around out there though. -- Matt Goodall, Pollenation Internet Ltd w: http://www.pollenationinternet.com e: matt@pollenation.net From djc at object-craft.com.au Sun Jul 20 10:58:24 2003 From: djc at object-craft.com.au (Dave Cole) Date: 20 Jul 2003 20:58:24 +1000 Subject: [albatross-users] Albatross 1.10 released 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 less than 3000 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, FastCGI, mod_python, or BaseHTTPServer Request class. It should be possible to develop a Request class for Medusa or Twisted to allow applications to be deployed on those platforms with minimal changes. Albatross comes with over 160 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 CHANGES SINCE 1.01 There have been many improvements and bug fixes since release 1.01. The following page describes the changes in detail. http://www.object-craft.com.au/projects/albatross/albatross/rel-1.10.html (There were no changes to 1.10pre4) -- http://www.object-craft.com.au From matt at pollenation.net Sun Jul 20 15:44:04 2003 From: matt at pollenation.net (Matt Goodall) Date: 20 Jul 2003 16:44:04 +0100 Subject: [albatross-users] Albatross 1.10 released In-Reply-To: References: Message-ID: <1058715843.14480.74.camel@localhost> Dave, thanks for all the time you put into the release at weekends ... but don't assume that this means I won't be sending you anymore patches! ;-) Cheers, Matt -- Matt Goodall, Pollenation Internet Ltd w: http://www.pollenation.net e: matt@pollenation.net From gnb at itga.com.au Sun Jul 20 23:33:24 2003 From: gnb at itga.com.au (Gregory Bond) Date: Mon, 21 Jul 2003 09:33:24 +1000 Subject: [albatross-users] Albatross 1.10 released In-Reply-To: Your message of 20 Jul 2003 20:58:24 +1000. Message-ID: <200307202333.JAA17216@lightning.itga.com.au> This is a multipart MIME message. --==_Exmh_14668846380 Content-Type: text/plain; charset=us-ascii I've sent a PR to update the FreeBSD port (pr ports/54680). Or you can use the attached ports framework. To use it: - cd /usr/port (or somewhere handy) - run the attached file through "sh" - cd www/py-albatross && make - "make install" as root --==_Exmh_14668846380 Content-Type: application/x-shar ; name="albatross.shar" Content-Description: albatross.shar Content-Transfer-Encoding: base64 Content-Disposition: attachment; filename="albatross.shar" IyBUaGlzIGlzIGEgc2hlbGwgYXJjaGl2ZS4gIFNhdmUgaXQgaW4gYSBmaWxlLCByZW1vdmUg YW55dGhpbmcgYmVmb3JlCiMgdGhpcyBsaW5lLCBhbmQgdGhlbiB1bnBhY2sgaXQgYnkgZW50 ZXJpbmcgInNoIGZpbGUiLiAgTm90ZSwgaXQgbWF5CiMgY3JlYXRlIGRpcmVjdG9yaWVzOyBm aWxlcyBhbmQgZGlyZWN0b3JpZXMgd2lsbCBiZSBvd25lZCBieSB5b3UgYW5kCiMgaGF2ZSBk ZWZhdWx0IHBlcm1pc3Npb25zLgojCiMgVGhpcyBhcmNoaXZlIGNvbnRhaW5zOgojCiMJd3d3 L3B5LWFsYmF0cm9zcy9NYWtlZmlsZQojCXd3dy9weS1hbGJhdHJvc3MvZGlzdGluZm8KIwl3 d3cvcHktYWxiYXRyb3NzL3BrZy1kZXNjcgojCXd3dy9weS1hbGJhdHJvc3MvcGtnLXBsaXN0 CiMKZWNobyB4IC0gd3d3L3B5LWFsYmF0cm9zcwpta2RpciAtcCB3d3cvcHktYWxiYXRyb3Nz CmVjaG8geCAtIHd3dy9weS1hbGJhdHJvc3MvTWFrZWZpbGUKc2VkICdzL15YLy8nID53d3cv cHktYWxiYXRyb3NzL01ha2VmaWxlIDw8ICdFTkQtb2Ytd3d3L3B5LWFsYmF0cm9zcy9NYWtl ZmlsZScKWCMgTmV3IHBvcnRzIGNvbGxlY3Rpb24gbWFrZWZpbGUgZm9yOglhbGJhdHJvc3MK WCMgRGF0ZSBjcmVhdGVkOgkJMjkgQXVndXN0IDIwMDIKWCMgV2hvbToJICAgICAgCQlHcmVn b3J5IEJvbmQgPGduYkBpdGdhLmNvbS5hdT4KWCMKWCMgJEZyZWVCU0Q6IHBvcnRzL3d3dy9w eS1hbGJhdHJvc3MvTWFrZWZpbGUsdiAxLjMgMjAwMy8wMi8yMSAxNDowMTozMCBrbnUgRXhw ICQKWApYUE9SVE5BTUU9CWFsYmF0cm9zcwpYUE9SVFZFUlNJT049CTEuMTAKWENBVEVHT1JJ RVM9CXd3dyBweXRob24KWE1BU1RFUl9TSVRFUz0JaHR0cDovL29iamVjdC1jcmFmdC5jb20u YXUvcHJvamVjdHMvYWxiYXRyb3NzL2Rvd25sb2FkLwpYUEtHTkFNRVBSRUZJWD0JJHtQWVRI T05fUEtHTkFNRVBSRUZJWH0KWApYTUFJTlRBSU5FUj0JZ25iQGl0Z2EuY29tLmF1ClhDT01N RU5UPQlQeXRob24gdG9vbGtpdCBmb3IgZGV2ZWxvcGluZyBoaWdobHkgc3RhdGVmdWwgd2Vi IGFwcGxpY2F0aW9ucwpYClhVU0VfUFlUSE9OPQl5ZXMKWFVTRV9QWURJU1RVVElMUz0JeWVz ClgKWERJU1RGSUxFUyA9ICR7UE9SVE5BTUV9LSR7UE9SVFZFUlNJT059JHtFWFRSQUNUX1NV Rlh9ICR7UE9SVE5BTUV9LWh0bWwtJHtQT1JUVkVSU0lPTn0ke0VYVFJBQ1RfU1VGWH0KWApY cG9zdC1pbnN0YWxsOgpYLmlmICFkZWZpbmVkKE5PUE9SVERPQ1MpClgJQCR7TUtESVJ9ICR7 RE9DU0RJUn0gJHtFWEFNUExFU0RJUn0gJHtET0NTRElSfS9odG1sClgJQCR7VEFSfSAtY2Yg LSAtQyAke1dSS1NSQ30vZG9jIC4gfCAke1RBUn0gLXhmIC0gLUMgJHtET0NTRElSfQpYCUAk e1RBUn0gLWNmIC0gLUMgJHtXUktESVJ9L2FsYmF0cm9zcyAuIHwgJHtUQVJ9IC14ZiAtIC1D ICR7RE9DU0RJUn0vaHRtbApYCUAke1RBUn0gLWNmIC0gLUMgJHtXUktTUkN9L3NhbXBsZXMg LiB8ICR7VEFSfSAteGYgLSAtQyAke0VYQU1QTEVTRElSfQpYLmVuZGlmClgKWC5pbmNsdWRl IDxic2QucG9ydC5taz4KRU5ELW9mLXd3dy9weS1hbGJhdHJvc3MvTWFrZWZpbGUKZWNobyB4 IC0gd3d3L3B5LWFsYmF0cm9zcy9kaXN0aW5mbwpzZWQgJ3MvXlgvLycgPnd3dy9weS1hbGJh dHJvc3MvZGlzdGluZm8gPDwgJ0VORC1vZi13d3cvcHktYWxiYXRyb3NzL2Rpc3RpbmZvJwpY TUQ1IChhbGJhdHJvc3MtMS4xMC50YXIuZ3opID0gMTQ1OGU0NzkyNGRiNTFhZjAyZjJkYTVh NGVlMTg4MzUKWE1ENSAoYWxiYXRyb3NzLWh0bWwtMS4xMC50YXIuZ3opID0gMWY1Nzk4Yzc3 ZTkxOTdjMjJkODE2Y2Q2ZjA0MmE0ZDcKRU5ELW9mLXd3dy9weS1hbGJhdHJvc3MvZGlzdGlu Zm8KZWNobyB4IC0gd3d3L3B5LWFsYmF0cm9zcy9wa2ctZGVzY3IKc2VkICdzL15YLy8nID53 d3cvcHktYWxiYXRyb3NzL3BrZy1kZXNjciA8PCAnRU5ELW9mLXd3dy9weS1hbGJhdHJvc3Mv cGtnLWRlc2NyJwpYQWxiYXRyb3NzIGlzIGEgc21hbGwgYW5kIGZsZXhpYmxlIFB5dGhvbiB0 b29sa2l0IGZvciBkZXZlbG9waW5nClhoaWdobHkgc3RhdGVmdWwgd2ViIGFwcGxpY2F0aW9u cy4gVGhlIHRvb2xraXQgaGFzIGJlZW4gZGVzaWduZWQgdG8KWHRha2UgYSBsb3Qgb2YgdGhl IHBhaW4gb3V0IG9mIGNvbnN0cnVjdGluZyBpbnRyYW5ldCBhcHBsaWNhdGlvbnMKWGFsdGhv dWdoIHlvdSBjYW4gYWxzbyB1c2UgQWxiYXRyb3NzIGZvciBkZXBsb3lpbmcgcHVibGljbHkg YWNjZXNzZWQKWHdlYiBhcHBsaWNhdGlvbnMuClgKWEF1dGhvcjogRGF2ZSBDb2xlIDxkamNA b2JqZWN0LWNyYWZ0LmNvbS5hdT4KWFdXVzogICAgaHR0cDovL29iamVjdC1jcmFmdC5jb20u YXUvcHJvamVjdHMvYWxiYXRyb3NzLwpYClgtLSBHcmVnb3J5IEJvbmQgPGduYkBpdGdhLmNv bS5hdT4KRU5ELW9mLXd3dy9weS1hbGJhdHJvc3MvcGtnLWRlc2NyCmVjaG8geCAtIHd3dy9w eS1hbGJhdHJvc3MvcGtnLXBsaXN0CnNlZCAncy9eWC8vJyA+d3d3L3B5LWFsYmF0cm9zcy9w a2ctcGxpc3QgPDwgJ0VORC1vZi13d3cvcHktYWxiYXRyb3NzL3BrZy1wbGlzdCcKWGJpbi9h bC1zZXNzaW9uLWRhZW1vbgpYYmluL2FsLWh0dHBkClglJVBZVEhPTl9TSVRFTElCRElSJSUv YWxiYXRyb3NzL19faW5pdF9fLnB5ClglJVBZVEhPTl9TSVRFTElCRElSJSUvYWxiYXRyb3Nz L19faW5pdF9fLnB5YwpYJSVQWVRIT05fU0lURUxJQkRJUiUlL2FsYmF0cm9zcy9fX2luaXRf Xy5weW8KWCUlUFlUSE9OX1NJVEVMSUJESVIlJS9hbGJhdHJvc3MvYXBhY2hlYXBwLnB5Clgl JVBZVEhPTl9TSVRFTElCRElSJSUvYWxiYXRyb3NzL2FwYWNoZWFwcC5weWMKWCUlUFlUSE9O X1NJVEVMSUJESVIlJS9hbGJhdHJvc3MvYXBhY2hlYXBwLnB5bwpYJSVQWVRIT05fU0lURUxJ QkRJUiUlL2FsYmF0cm9zcy9hcHAucHkKWCUlUFlUSE9OX1NJVEVMSUJESVIlJS9hbGJhdHJv c3MvYXBwLnB5YwpYJSVQWVRIT05fU0lURUxJQkRJUiUlL2FsYmF0cm9zcy9hcHAucHlvClgl JVBZVEhPTl9TSVRFTElCRElSJSUvYWxiYXRyb3NzL2NnaWFwcC5weQpYJSVQWVRIT05fU0lU RUxJQkRJUiUlL2FsYmF0cm9zcy9jZ2lhcHAucHljClglJVBZVEhPTl9TSVRFTElCRElSJSUv YWxiYXRyb3NzL2NnaWFwcC5weW8KWCUlUFlUSE9OX1NJVEVMSUJESVIlJS9hbGJhdHJvc3Mv Y29tbW9uLnB5ClglJVBZVEhPTl9TSVRFTElCRElSJSUvYWxiYXRyb3NzL2NvbW1vbi5weWMK WCUlUFlUSE9OX1NJVEVMSUJESVIlJS9hbGJhdHJvc3MvY29tbW9uLnB5bwpYJSVQWVRIT05f U0lURUxJQkRJUiUlL2FsYmF0cm9zcy9jb250ZXh0LnB5ClglJVBZVEhPTl9TSVRFTElCRElS JSUvYWxiYXRyb3NzL2NvbnRleHQucHljClglJVBZVEhPTl9TSVRFTElCRElSJSUvYWxiYXRy b3NzL2NvbnRleHQucHlvClglJVBZVEhPTl9TSVRFTElCRElSJSUvYWxiYXRyb3NzL2ZjZ2lh cHAucHkKWCUlUFlUSE9OX1NJVEVMSUJESVIlJS9hbGJhdHJvc3MvZmNnaWFwcC5weWMKWCUl UFlUSE9OX1NJVEVMSUJESVIlJS9hbGJhdHJvc3MvZmNnaWFwcC5weW8KWCUlUFlUSE9OX1NJ VEVMSUJESVIlJS9hbGJhdHJvc3MvaHR0cGRhcHAucHkKWCUlUFlU