Hi guy!
> > See my trouble:
> >
> > I created a class and used the action funcionality, i.e:
> >
> > class SomeClass(Page):
> > def writeContent(self):
> > self.writeln('some initial content')
> >
> > def action(self):
> > return Page.actions() + ['test1', 'test2']
> >
> > def test1(self):
> > self.writeContent=lambda s=self: s.writeln('function test1 not
> > implemented')
> > self.writeHTML()
> >
> > def test2(self):
> > self.writeContent=lambda s=self: s.writeln('function test2 not
> > implemented')
> > self.writeHTML()
> >
> > The problem is when I access the action test1 (with a submit
> > button), the page will show me always "function test1 not
> > implemented"...
>
> This is what the code shows that it should be doing i.e
>
> in def test1, you assign writeContent to your lambda function, which
> writes
> "function test1 not implemented".
>
> What output were you expecting ?
When I click the test1 input button, the writeContent should writes
"function not implemented" but when I return to the SomeClass Page, it
should uses the SomeClass writeContent...
I tried to create a quick way to say short messages...
> > How can I avoid this problem? The same occours for list
> > objects inside the class. I have the self._error list, I
> > store in this list some error messages (form not completed,
> > you have to fill your name, etc). If the self._error is false
> > (not self._error) i do nothing, but if there is an error, I
> > execute the writeContent of the Form class (I have 2 classes,
> > a Form class and a Process class, the Process class
> > inhiterits the Form class.
> >
> > One time I had an error, this error will be always shown, how
> > can I avoid this?
>
> Where did you define your _error list ? If you it's in __init__, then
> you
> must remember to clear it after every request, or you can clear it
> out in
> def awake() before each requests starts. This is because each servlet
> is
> __init__ only once.
I preferred to not use __init__, I define the error before writeHTML...
> Are your error messages session specific ? Do they need to persist
> across
> requests ? If yes, you may need a different approach altogether
No, i have a Form and a Process class, the process class are derivated
of the Form class, I test the variables using a method like this:
...
def writeHTML(self):
if not self.request().hasValue('somevalue'):
self.appendError('some error')
if self.request().('another_value')=='-1':
self.appendError('some another error')
baseClass.writeHTML(self)
def writeContent(self):
if self.hasError():
base.writeContent(self)
return
... do something else ...
...
So I defined the appendError method and the hasError, this methods
control the ._error list... This is the methods:
def appendError(self, mensagem):
try:
error=self._error
except AttributeError:
error=[]
error.append(mensagem)
self._error=error
def hasError(self):
try:
error=self._error
except AttributeError:
error=None
if not error:
return False
else:
return True
Understand? My problem is that the error is not cleaned throught
requests... I enter the section with a error one time, so I return, fix
the error and submit again, the erros still existing...
Is there a way to not cache this error without need to clean the error
on the Form? I having the same problem with all atributes I define...
I have 2 sites, a SiteA and a SiteB, the SiteA is the running system,
the SiteB is a alpha test, I develop the system in the SiteB, the SiteA
access a database_backup, the SiteB access a database... When I access
the SiteA and so go to SiteB, the database attribute stored is the
database_backup (from SiteA)...
I want to automatically clean this attributes, the WebWare doc have
something about, but the section appoints to a fixme...
If there is no way, I will clean it manually, but before I want to know
if there is no way...
thanks for the patience :) and for the help! Seeeya
=====
--
Michel Thadeu Sabchuk
Curitiba/PR
______________________________________________________________________
Yahoo! Messenger - Fale com seus amigos online. Instale agora!
http://br.download.yahoo.com/messenger/
|