11 replies [Last post]
Souvent22@drupal.org's picture
Offline
Joined: 10/17/2007
Juice: 73
Was this information Helpful?

The product files implementation is pretty good. However, I think it is too tied into a "file" being something on disk.
First, one needs to abstract out the files to use hook/implementations instead of relying on the fact that the file is on disk. "File" is an abstract term. The "file" could be an S3 file, etc. The common element of a file though is a stream and/or path to the data. Weather that path comes as a web url, s3 url, of path on a disk does not matter.
With that said, I am going to modify the product-files module to do this. Instead of looking on disk, it will file uc_file_hooks of some sort ( thinking hook_uc_files_api or something )to let other modules know what is going on, and let them act appropriately. Each module will show as a "drop down" with its title, and then will thus show its attributes that are needed for that type of file.
Thus, after that patch, on the attributes screen, one would see a drop down saying:
- "On Disk" ( the current implementation )
- "S3"
- "Network"
...etc.
I'll post a patch and write up on this soon.

Ryan's picture
Offline
Joined: 08/07/2007
Juice: 15438
Re: Product "files" should be more abstract

I think this may have been one of the original desires for the file downloads module... will be interested to see what you come up with. Smiling

torgosPizza's picture
Offline
Bug FinderEarly adopter... addicted to alphas.Getting busy with the Ubercode.
Joined: 08/14/2007
Juice: 4110
Re: Re: Product "files" should be more abstract

I would also chime in to say that this is a good idea - it would open the door for people to sell other intangible items that could be tied to nodes. Job postings, for instance. Looking forward to your work, souvent!

--
Help directly fund development: Donate via PayPal!

Souvent22@drupal.org's picture
Offline
Joined: 10/17/2007
Juice: 73
Patch just about Complete...with an issue

Patch is just about done.
Bascially, uc_file has turned into a very then "catalog". Just holds an ID, and reference information to load more inforamtion about a "file" from the appropriate module (think how nodes are setup).
1 problem though...the drop down shows the availiable options. So when the form is shown, it says: "Select a type" from the drop down. When you select a type, the form elements are dynamically loaded.
However, when the form is submitted, none of the dynamically loaded form elements are there? Anyone give any insight? I thought we could load dynamic elements. Heck, it's how check works when you select a type of payment.
Insight is appreciated Smiling.

- Earnest

Ryan's picture
Offline
Joined: 08/07/2007
Juice: 15438
Re: Patch just about Complete...with an issue

Yeah, unfortunately for dynamically loaded elements you have to look for them in $_POST directly on the form submission. I've heard this is bad practice, and it's certainly not ideal, but it's unavoidable unless we want to implement our own D6 styled AHAH stuff to the 1.0... which probably won't happen. Sticking out tongue

Lemme know if you aren't seeing the info in $_POST either.

Souvent22@drupal.org's picture
Offline
Joined: 10/17/2007
Juice: 73
Work around

Yeah, it was in the post. Intead though, I found another work around that still satisifes Drupal's need to have the form structure match when it sent out, but still be dynamic, and not have to look at $_POST, and just use the usual FAPI suspects (hook_submit, _validate, etc.). Smiling

- Earnest

Souvent22@drupal.org's picture
Offline
Joined: 10/17/2007
Juice: 73
Re: Work around

Should I be doing patches off of the drupal.org rc5 release?

Lyle's picture
Offline
AdministratoreLiTe!
Joined: 08/07/2007
Juice: 6846
Re: Re: Work around

RC5 would probably work, but going off the Bazaar version would be better.

descott's picture
Offline
Joined: 05/27/2008
Juice: 50
Re: Re: Re: Work around

I'm excited for this module. So by amazons3 file, you mean a url to a file hosted via amazon? Smiling (or any "url" for that matter)

Souvent22@drupal.org's picture
Offline
Joined: 10/17/2007
Juice: 73
"Link" is API Relative

Descott,

"Any" url. When I mentioned that, it was more from a low-level "API Abstraction" level. Meaning, that all uc_file does now is ask the appropriate module or a "link" (think stream) to the file, and then that is displayed to the user.

This means that uc_diskfile displays returns a direct link to the file. A uc_amazons3 displays a link to the amazon file, or perhaps a tokenized url and redirects to the amazon file (this is to better hide the direct link to the amazon file ). Etc. etc.

descott's picture
Offline
Joined: 05/27/2008
Juice: 50
Re: "Link" is API Relative

Ah excellent. I would want to do something similar using a cdn that supports token authentication (similar to amazon's s3 service).

thx

Souvent22@drupal.org's picture
Offline
Joined: 10/17/2007
Juice: 73
Distractions

Hey, sorry, i became distracted with some projects.
Here's a *ROUGH* draft of the updated uc_file.
Included/attached is a uc_file patch to patch the current uc_files module.
Also included is a "uc_diskfile" module that implements the "default" implementation of files on disk.

I still need to add the last component, which is an abstraction of when a file is called for, the module presents a link, and then the module takes care of "transfering" the file. Look for that to come soon.

Then I'd love some comments and then perhaps get this into core? Pretty please with sugar on top? Smiling.

Again, there is still some MAJOR work to be done on this module/patch, so I'm looking for early feed back.

- Earnest

P.S. Oh, and I need to test an "upgrade path" for those that have uc_files implemented. This should be too hard as the upgrade should/will only involved placing the implemented uc_files to use the uc_diskfile instead.

AttachmentSize
uc_file_patch.patch 121.08 KB
uc_diskfile.zip 2.13 KB