|
From: Brad P. <br...@ro...> - 2002-09-25 00:03:39
|
Ah ha! Makes perfect sense, and it is not counterintuitive. It's funny
how I can fail to see things sometimes. I looked directly at the
setValue method and was looking at how it uploaded files. I just didn't
make the connection between that and setFieldValues. /me is feeling
silly.
That is a good idea to put it in the "consturctor". I will give that a
try. Using Modus has been a fun way for me to try and get back up to
speed with CF after a little hiatus.
What happened to the framework discussion?? =)
On Tue, 2002-09-24 at 17:45, Nathan Dintenfass wrote:
> Brad:
>
> First, I am psyched to see someone actually trying to use Modus!
>
> setDirectory() is probably something that should actually be refactored in
> some way. I think a "defaultFileDirectory" might also be appropriate for
> the config file. But, to your question . . .
>
> I am not sure why it's counterintuitive that you would need to set the
> directory before setting the value. Remember, the setFieldValues() calls
> the setValue() on each field, and for the baseFile the setValue() method is
> what actually deals with the upload of the file. Thus, it needs to
> understand what directory it is going to use before the value gets set.
>
> I wish there was a super() in CFC's, because then the baseFile would have
> it's own init() method that called the init() of the baseField and then
> added a setDefaultDirectory() method that could be overridden in
> implementations of a base file. But, I digress.
>
> I also would probably put the setDirectory() declaration inside of your
> "code" component -- in the "constructor". That should work nicely (assuming
> all "code" instances should store their files in the same place!) and hide
> the need to know much about the location on the front.
>
> Make sense?
>
>
> > -----Original Message-----
> > From: mod...@li...
> > [mailto:mod...@li...]On Behalf Of Brad Pauly
> > Sent: Tuesday, September 24, 2002 4:28 PM
> > To: modus devs
> > Subject: [Modus-devs] file upload
> >
> >
> > Hi all... I was playing around some more and I noticed something
> > interesting. I have dug into it a little, but thought I would post here
> > and see what came of it.
> >
> > I made a code object that uses basefile to upload files. (I have been
> > recreating some of the things on the bacfug site, hence the code object,
> > in hopes that my exploring will produce some documentation on how to
> > create a simple site with Modus) The code object has a three fields:
> > title, file, and description. I wanted to change where the file was
> > uploaded, so I took advantage of the setDirectory method. Here is the
> > snippet that does this:
> >
> >
> > // create an initizlie a code object
> > code = createObject("component","bacfug.contentobjects.code").init();
> >
> > // if the form was POSTed process it
> > if (isDefined("form.fieldnames")) {
> >
> > // set the id
> > // i need to explore this more, but it
> > // seems to work in place of a isNew field
> > code.setID(form.id);
> >
> > // set the directory to upload to
> > code.getField("file").setDirectory("#expandPath("/bacfug/code/")#");
> >
> > // set the field values based on the form
> > code.setFieldValues(argumentCollection=form);
> >
> > // if there are no errors, commit it to the database
> > if(NOT code.hasErrors()){
> >
> > // send it to the database
> > code.store();
> >
> > // reinitialize
> > code.init();
> > }
> > }
> >
> >
> > This works fine. However, if I call setFieldValues before setDirectory,
> > the file is uploaded into the default directory ("/"). This is almost
> > counterintuitive to me. I thought perhaps the setValue calls in
> > setFieldValues might overwrite something. Looking into these two
> > methods, I couldn't find anything that would cause one to overwrite the
> > other. That makes me think that I should be able to call these in either
> > order and get the desired outcome.
> >
> > Any thoughs?
> >
> > Brad
> >
> >
> >
> >
> >
> > -------------------------------------------------------
> > This sf.net email is sponsored by:ThinkGeek
> > Welcome to geek heaven.
> > http://thinkgeek.com/sf
> > _______________________________________________
> > Modus-devs mailing list
> > Mod...@li...
> > https://lists.sourceforge.net/lists/listinfo/modus-devs
> >
>
>
>
> -------------------------------------------------------
> This sf.net email is sponsored by:ThinkGeek
> Welcome to geek heaven.
> http://thinkgeek.com/sf
> _______________________________________________
> Modus-devs mailing list
> Mod...@li...
> https://lists.sourceforge.net/lists/listinfo/modus-devs
>
>
|